summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2017-12-06 23:18:30 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-12-06 23:18:30 +0000
commit98417af42c96b11a77f61f2a936775a9259a63c4 (patch)
tree8e9e08d4247f0ed38e03ed24df198d9ad97d3c8a
parent8a85d46930ad6c9e63b03957ff68db9c2619bf9e (diff)
parent8c9a191065c88b575e4b553f231a8fcb397d9886 (diff)
downloadandroid_packages_wallpapers_LivePicker-98417af42c96b11a77f61f2a936775a9259a63c4.tar.gz
android_packages_wallpapers_LivePicker-98417af42c96b11a77f61f2a936775a9259a63c4.tar.bz2
android_packages_wallpapers_LivePicker-98417af42c96b11a77f61f2a936775a9259a63c4.zip
Merge "DO NOT MERGE: Merge Oreo MR1 into master"
-rw-r--r--src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java b/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java
index 6dab5c6..25ce3a4 100644
--- a/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java
+++ b/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java
@@ -27,6 +27,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
+import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources.NotFoundException;
import android.graphics.Rect;
@@ -71,9 +72,9 @@ public class LiveWallpaperPreview extends Activity {
private WallpaperManager mWallpaperManager;
private WallpaperConnection mWallpaperConnection;
- private String mSettings;
private String mPackageName;
private Intent mWallpaperIntent;
+ private Intent mSettingsIntent;
private TextView mAttributionTitle;
private TextView mAttributionSubtitle1;
@@ -115,11 +116,23 @@ public class LiveWallpaperPreview extends Activity {
mSpacer = findViewById(R.id.spacer);
mLoading = findViewById(R.id.loading);
- mSettings = info.getSettingsActivity();
mPackageName = info.getPackageName();
mWallpaperIntent = new Intent(WallpaperService.SERVICE_INTERFACE)
.setClassName(info.getPackageName(), info.getServiceName());
+ final String settingsActivity = info.getSettingsActivity();
+ if (settingsActivity != null) {
+ mSettingsIntent = new Intent();
+ mSettingsIntent.setComponent(new ComponentName(mPackageName, settingsActivity));
+ mSettingsIntent.putExtra(WallpaperSettingsActivity.EXTRA_PREVIEW_MODE, true);
+ final PackageManager pm = getPackageManager();
+ final ActivityInfo activityInfo = mSettingsIntent.resolveActivityInfo(pm, 0);
+ if (activityInfo == null) {
+ Log.e(LOG_TAG, "Couldn't find settings activity: " + settingsActivity);
+ mSettingsIntent = null;
+ }
+ }
+
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setActionBar(toolbar);
getActionBar().setDisplayHomeAsUpEnabled(true);
@@ -253,7 +266,7 @@ public class LiveWallpaperPreview extends Activity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_preview, menu);
- menu.findItem(R.id.configure).setVisible(mSettings != null);
+ menu.findItem(R.id.configure).setVisible(mSettingsIntent != null);
menu.findItem(R.id.set_wallpaper).getActionView().setOnClickListener(
this::setLiveWallpaper);
return super.onCreateOptionsMenu(menu);
@@ -308,10 +321,7 @@ public class LiveWallpaperPreview extends Activity {
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.configure) {
- Intent intent = new Intent();
- intent.setComponent(new ComponentName(mPackageName, mSettings));
- intent.putExtra(WallpaperSettingsActivity.EXTRA_PREVIEW_MODE, true);
- startActivity(intent);
+ startActivity(mSettingsIntent);
return true;
} else if (id == R.id.set_wallpaper) {
setLiveWallpaper(getWindow().getDecorView());