am 2435eb9c: Avoid NPE when finding common MIME type.
Jeff Sharkey [Thu, 9 May 2013 23:23:24 +0000 (16:23 -0700)]
* commit '2435eb9c89bd46511624b9d89ab22766f82dbfcb':
  Avoid NPE when finding common MIME type.

tests/src/com/android/providers/downloads/AbstractDownloadProviderFunctionalTest.java
tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
ui/src/com/android/providers/downloads/ui/DownloadList.java

index e59aff0..3b93738 100644 (file)
@@ -34,7 +34,6 @@ import android.test.mock.MockContentResolver;
 import android.util.Log;
 
 import com.google.mockwebserver.MockResponse;
-import com.google.mockwebserver.MockStreamResponse;
 import com.google.mockwebserver.MockWebServer;
 import com.google.mockwebserver.RecordedRequest;
 import com.google.mockwebserver.SocketPolicy;
@@ -221,10 +220,6 @@ public abstract class AbstractDownloadProviderFunctionalTest extends
         mServer.enqueue(resp);
     }
 
-    void enqueueResponse(MockStreamResponse resp) {
-        mServer.enqueue(resp);
-    }
-
     MockResponse buildResponse(int status, String body) {
         return new MockResponse().setResponseCode(status).setBody(body)
                 .setHeader("Content-type", "text/plain")
index b6fd611..bde9581 100644 (file)
@@ -50,7 +50,6 @@ import android.test.suitebuilder.annotation.Suppress;
 import android.text.format.DateUtils;
 
 import com.google.mockwebserver.MockResponse;
-import com.google.mockwebserver.MockStreamResponse;
 import com.google.mockwebserver.RecordedRequest;
 import com.google.mockwebserver.SocketPolicy;
 
@@ -141,7 +140,7 @@ public class PublicApiFunctionalTest extends AbstractPublicApiTest {
         final long length = 3 * GB_IN_BYTES;
         final InputStream body = new FakeInputStream(length);
 
-        enqueueResponse(new MockStreamResponse().setResponseCode(HTTP_OK).setBody(body, length)
+        enqueueResponse(new MockResponse().setResponseCode(HTTP_OK).setBody(body, length)
                 .setHeader("Content-type", "text/plain")
                 .setSocketPolicy(SocketPolicy.DISCONNECT_AT_END));
 
index fd000d3..05b5d75 100644 (file)
@@ -431,8 +431,10 @@ public class DownloadList extends Activity {
 
         if (mDateSortedCursor == null || mDateSortedCursor.getCount() == 0) {
             mEmptyView.setVisibility(View.VISIBLE);
+            mSortOption.setVisibility(View.GONE);
         } else {
             mEmptyView.setVisibility(View.GONE);
+            mSortOption.setVisibility(View.VISIBLE);
             ListView lv = activeListView();
             lv.setVisibility(View.VISIBLE);
             lv.invalidateViews(); // ensure checkboxes get updated
@@ -765,7 +767,9 @@ public class DownloadList extends Activity {
         // are all prefixes of the given mimetypes the same?
         ArrayList<String> mimeTypePrefixes = new ArrayList<String>();
         for (String s : mimeTypes) {
-            mimeTypePrefixes.add(s.substring(0, s.indexOf('/')));
+            if (s != null) {
+                mimeTypePrefixes.add(s.substring(0, s.indexOf('/')));
+            }
         }
         str = findCommonString(mimeTypePrefixes);
         if (str != null) {