am 080563ad: When pausing, also cancel the in-progress fade in if there was one. b/3209106

* commit '080563ad0a9376c96354c552571561ff8df566fb':
  When pausing, also cancel the in-progress fade in if there was one. b/3209106
diff --git a/src/com/android/music/PlaylistBrowserActivity.java b/src/com/android/music/PlaylistBrowserActivity.java
index 8c79e64..6149aa0 100644
--- a/src/com/android/music/PlaylistBrowserActivity.java
+++ b/src/com/android/music/PlaylistBrowserActivity.java
@@ -98,18 +98,27 @@
         mToken = MusicUtils.bindToService(this, new ServiceConnection() {
             public void onServiceConnected(ComponentName classname, IBinder obj) {
                 if (Intent.ACTION_VIEW.equals(action)) {
-                    long id = Long.parseLong(intent.getExtras().getString("playlist"));
-                    if (id == RECENTLY_ADDED_PLAYLIST) {
-                        playRecentlyAdded();
-                    } else if (id == PODCASTS_PLAYLIST) {
-                        playPodcasts();
-                    } else if (id == ALL_SONGS_PLAYLIST) {
-                        long [] list = MusicUtils.getAllSongs(PlaylistBrowserActivity.this);
-                        if (list != null) {
-                            MusicUtils.playAll(PlaylistBrowserActivity.this, list, 0);
-                        }
+                    Bundle b = intent.getExtras();
+                    if (b == null) {
+                        Log.w(TAG, "Unexpected:getExtras() returns null.");
                     } else {
-                        MusicUtils.playPlaylist(PlaylistBrowserActivity.this, id);
+                        try {
+                            long id = Long.parseLong(b.getString("playlist"));
+                            if (id == RECENTLY_ADDED_PLAYLIST) {
+                                playRecentlyAdded();
+                            } else if (id == PODCASTS_PLAYLIST) {
+                                playPodcasts();
+                            } else if (id == ALL_SONGS_PLAYLIST) {
+                                long[] list = MusicUtils.getAllSongs(PlaylistBrowserActivity.this);
+                                if (list != null) {
+                                    MusicUtils.playAll(PlaylistBrowserActivity.this, list, 0);
+                                }
+                            } else {
+                                MusicUtils.playPlaylist(PlaylistBrowserActivity.this, id);
+                            }
+                        } catch (NumberFormatException e) {
+                            Log.w(TAG, "Playlist id missing or broken");
+                        }
                     }
                     finish();
                     return;
diff --git a/src/com/android/music/VideoBrowserActivity.java b/src/com/android/music/VideoBrowserActivity.java
index e8aaf74..ee062f0 100644
--- a/src/com/android/music/VideoBrowserActivity.java
+++ b/src/com/android/music/VideoBrowserActivity.java
@@ -105,6 +105,14 @@
         }
     }
 
+    @Override
+    public void onDestroy() {
+        if (mCursor != null) {
+            mCursor.close();
+        }
+        super.onDestroy();
+    }
+
     private Cursor mCursor;
     private String mWhereClause;
     private String mSortOrder;
diff --git a/tests/src/com/android/music/MusicPlayerNames.java b/tests/src/com/android/music/MusicPlayerNames.java
index f5f5d48..655d578 100644
--- a/tests/src/com/android/music/MusicPlayerNames.java
+++ b/tests/src/com/android/music/MusicPlayerNames.java
@@ -16,34 +16,36 @@
 
 package com.android.music.tests;
 
+import android.os.Environment;
+
 /**
- * 
- * This class has the names of the all the activity name and variables 
+ *
+ * This class has the names of the all the activity name and variables
  * in the instrumentation test.
  *
  */
 public class MusicPlayerNames {
-  
+
   //Expected result of the sorted playlistname
     public static final String expectedPlaylistTitle[] = { "**1E?:|}{[]~~.,;'",
         "//><..", "0123456789",
         "0random@112", "MyPlaylist", "UPPERLETTER",
         "combination011", "loooooooog",
-        "normal", "~!@#$%^&*()_+"    
-    }; 
-  
+        "normal", "~!@#$%^&*()_+"
+    };
+
   //Unsorted input playlist name
     public static final String unsortedPlaylistTitle[] = { "//><..","MyPlaylist",
-        "0random@112", "UPPERLETTER","normal", 
+        "0random@112", "UPPERLETTER","normal",
         "combination011", "0123456789",
         "~!@#$%^&*()_+","**1E?:|}{[]~~.,;'",
-        "loooooooog"    
+        "loooooooog"
     };
-    
+
     public static final String DELETE_PLAYLIST_NAME = "testDeletPlaylist";
     public static final String ORIGINAL_PLAYLIST_NAME = "original_playlist_name";
     public static final String RENAMED_PLAYLIST_NAME = "rename_playlist_name";
-    
+
     public static int NO_OF_PLAYLIST = 10;
     public static int WAIT_SHORT_TIME = 1000;
     public static int WAIT_LONG_TIME = 2000;
@@ -52,10 +54,12 @@
     public static int DEFAULT_PLAYLIST_LENGTH = 15;
     public static int NO_ALBUMS_TOBE_PLAYED = 50;
     public static int NO_SKIPPING_SONGS = 500;
-    
-    public static final String DELETESONG = "/sdcard/toBeDeleted.amr"; 
-    public static final String GOLDENSONG = "/sdcard/media_api/music/AMRNB.amr";
-    public static final String TOBEDELETESONGNAME = "toBeDeleted";   
-    
+
+    public static final String EXTERNAL_DIR =
+        Environment.getExternalStorageDirectory().toString();
+    public static final String DELETESONG = EXTERNAL_DIR + "/toBeDeleted.amr";
+    public static final String GOLDENSONG = EXTERNAL_DIR + "/media_api/music/AMRNB.amr";
+    public static final String TOBEDELETESONGNAME = "toBeDeleted";
+
     public static int EXPECTED_NO_RINGTONE = 1;
 }
diff --git a/tests/src/com/android/music/stress/AlbumsPlaybackStress.java b/tests/src/com/android/music/stress/AlbumsPlaybackStress.java
index f396317..46e1d9f 100644
--- a/tests/src/com/android/music/stress/AlbumsPlaybackStress.java
+++ b/tests/src/com/android/music/stress/AlbumsPlaybackStress.java
@@ -19,6 +19,7 @@
 import android.app.ActivityManager;
 import android.app.Instrumentation;
 import android.app.Instrumentation.ActivityMonitor;
+import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
 import android.os.SystemClock;
@@ -83,7 +84,7 @@
     
       //Verification: check if it is in low memory
       ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
-      ((ActivityManager)getActivity().getSystemService("activity")).getMemoryInfo(mi);
+      ((ActivityManager)getActivity().getSystemService(Context.ACTIVITY_SERVICE)).getMemoryInfo(mi);
       assertFalse(TAG, mi.lowMemory); 
      
    
diff --git a/tests/src/com/android/music/stress/MusicPlaybackStress.java b/tests/src/com/android/music/stress/MusicPlaybackStress.java
index 9e7fd74..ea916f6 100644
--- a/tests/src/com/android/music/stress/MusicPlaybackStress.java
+++ b/tests/src/com/android/music/stress/MusicPlaybackStress.java
@@ -80,7 +80,7 @@
       }
       //Verification: check if it is in low memory
       ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
-      ((ActivityManager)getActivity().getSystemService("activity")).getMemoryInfo(mi);
+      ((ActivityManager)getActivity().getSystemService(Context.ACTIVITY_SERVICE)).getMemoryInfo(mi);
       assertFalse(TAG, mi.lowMemory);      
     }
 }