Configure the LensResolverActivity intent with right music player

The music does not play because LensResolverActivity always
use the default intent to start activity, correct it to use the
ResolveInfo component.

In the test case below, take AOSP Music app as example, the ResovleInfo
will be:
{act=android.intent.action.VIEW
dat=content://com.android.providers.media.documents/document/audio:34
typ=audio/mp4 flg=0x1
cmp=com.android.support.car.lenspicker/.LensResolverActivity}

Expected Activity should be AudioPreview.
Actual return from LensPickerUtils.getLaunchIntent() is MusicBrowserActivity

Test: 1. Install multiple music players
Test: 2. Copy music files to DUT.
Test: 3. Open Settings -> Go to Storage.
Test: 4. Go to Internal storage or external storage.
Test: 5. Tap on any music file and select Google music player for playback.

Bug: 119290864

Change-Id: Id760c0e94857cda8659b3f3bcc5ae8359370884e
Signed-off-by: Wang, ArvinX <arvinx.wang@intel.com>
Signed-off-by: Guobin Zhang <guobin.zhang@intel.com>
diff --git a/src/com/android/support/car/lenspicker/ResolverAdapter.java b/src/com/android/support/car/lenspicker/ResolverAdapter.java
index d9324c8..d85453b 100644
--- a/src/com/android/support/car/lenspicker/ResolverAdapter.java
+++ b/src/com/android/support/car/lenspicker/ResolverAdapter.java
@@ -18,7 +18,6 @@
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
-import android.content.SharedPreferences;
 import android.content.pm.ActivityInfo;
 import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageManager;
@@ -91,7 +90,6 @@
             List<LensPickerItem> items = new ArrayList<>();
 
             PackageManager packageManager = mContext.getPackageManager();
-            SharedPreferences sharedPref = LensPickerUtils.getFacetSharedPrefs(mContext);
 
             for (ResolveInfo info : mResolveInfos) {
                 String packageName = LensPickerUtils.getPackageName(info);
@@ -114,19 +112,21 @@
                     if (displayName.equals("")) {
                         displayName = getComponentLabel(packageManager, aInfo);
                     }
-                    Intent launchIntent = LensPickerUtils.getLaunchIntent(packageName, info,
-                            packageManager);
-                    // If launchIntent is null, create an intent from the ResolverInfo
-                    if (launchIntent == null) {
-                        launchIntent = new Intent();
+
+                    Intent intent;
+                    if (LensPickerUtils.isMediaService(info)) {
+                        intent = LensPickerUtils.getMediaLaunchIntent(packageManager, packageName,
+                                info.serviceInfo.name);
+                    } else {
+                        intent = new Intent();
                         ActivityInfo activity = info.activityInfo;
-                        launchIntent.setComponent(
+                        intent.setComponent(
                                 new ComponentName(activity.applicationInfo.packageName,
-                                activity.name));
+                                        activity.name));
                     }
 
                     items.add(new LensPickerItem(displayName,
-                            getComponentIcon(packageManager, aInfo), launchIntent,
+                            getComponentIcon(packageManager, aInfo), intent,
                             null /* facetId */));
                 } catch (PackageManager.NameNotFoundException e) {
                     // skip this package.