Remove URI from Audio/Video

Test: manual
Bug: 128868297
Change-Id: I4e55e7473effe12eea22b6b8a8ed87d3215268ab
diff --git a/java/com/android/pump/db/Audio.java b/java/com/android/pump/db/Audio.java
index f1b06a2..4d4d0f1 100644
--- a/java/com/android/pump/db/Audio.java
+++ b/java/com/android/pump/db/Audio.java
@@ -16,8 +16,6 @@
 
 package com.android.pump.db;
 
-import android.net.Uri;
-
 import androidx.annotation.AnyThread;
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
@@ -25,7 +23,6 @@
 @AnyThread
 public class Audio {
     private final long mId;
-    private final Uri mUri;
     private final String mMimeType;
 
     // TODO(b/123706949) Lock mutable fields to ensure consistent updates
@@ -34,9 +31,8 @@
     private Album mAlbum;
     private boolean mLoaded;
 
-    Audio(long id, @NonNull Uri uri, @NonNull String mimeType) {
+    Audio(long id, @NonNull String mimeType) {
         mId = id;
-        mUri = uri;
         mMimeType = mimeType;
     }
 
@@ -44,19 +40,12 @@
         return mId;
     }
 
-    public @NonNull Uri getUri() {
-        return mUri;
-    }
-
     public @NonNull String getMimeType() {
         return mMimeType;
     }
 
-    public @NonNull String getTitle() {
-        if (mTitle != null) {
-            return mTitle;
-        }
-        return mUri.getLastPathSegment();
+    public @Nullable String getTitle() {
+        return mTitle;
     }
 
     public @Nullable Artist getArtist() {
diff --git a/java/com/android/pump/db/AudioStore.java b/java/com/android/pump/db/AudioStore.java
index 5acac70..4cd569b 100644
--- a/java/com/android/pump/db/AudioStore.java
+++ b/java/com/android/pump/db/AudioStore.java
@@ -141,7 +141,6 @@
             Uri contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
             String[] projection = {
                 MediaStore.Audio.Media._ID,
-                MediaStore.Audio.Media.DATA,
                 MediaStore.Audio.Media.MIME_TYPE,
                 MediaStore.Audio.Media.ARTIST_ID,
                 MediaStore.Audio.Media.ALBUM_ID
@@ -152,18 +151,15 @@
             if (cursor != null) {
                 try {
                     int idColumn = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media._ID);
-                    int dataColumn = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA);
                     int mimeTypeColumn = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.MIME_TYPE);
                     int artistIdColumn = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST_ID);
                     int albumIdColumn = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM_ID);
 
                     for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
                         long id = cursor.getLong(idColumn);
-                        String data = cursor.getString(dataColumn);
                         String mimeType = cursor.getString(mimeTypeColumn);
 
-                        Uri uri = Uri.fromFile(new File(data));
-                        Audio audio = new Audio(id, uri, mimeType);
+                        Audio audio = new Audio(id, mimeType);
                         audios.add(audio);
 
                         if (!cursor.isNull(artistIdColumn)) {
diff --git a/java/com/android/pump/db/Episode.java b/java/com/android/pump/db/Episode.java
index 7d119fc..9b553ff 100644
--- a/java/com/android/pump/db/Episode.java
+++ b/java/com/android/pump/db/Episode.java
@@ -34,9 +34,9 @@
     private String mDescription;
     private boolean mLoaded;
 
-    Episode(long id, @NonNull Uri uri, @NonNull String mimeType, @NonNull Series series,
+    Episode(long id, @NonNull String mimeType, @NonNull Series series,
             int season, int episode) {
-        super(id, uri, mimeType);
+        super(id, mimeType);
 
         mSeries = series;
         if (season <= 0 || episode <= 0) {
diff --git a/java/com/android/pump/db/Movie.java b/java/com/android/pump/db/Movie.java
index 54176e5..9d58bf4 100644
--- a/java/com/android/pump/db/Movie.java
+++ b/java/com/android/pump/db/Movie.java
@@ -34,15 +34,15 @@
     private String mDescription;
     private boolean mLoaded;
 
-    Movie(long id, @NonNull Uri uri, @NonNull String mimeType, @NonNull String title) {
-        super(id, uri, mimeType);
+    Movie(long id, @NonNull String mimeType, @NonNull String title) {
+        super(id, mimeType);
 
         mTitle = title;
         mYear = Integer.MIN_VALUE;
     }
 
-    Movie(long id, @NonNull Uri uri, @NonNull String mimeType, @NonNull String title, int year) {
-        super(id, uri, mimeType);
+    Movie(long id, @NonNull String mimeType, @NonNull String title, int year) {
+        super(id, mimeType);
 
         mTitle = title;
         if (year <= 0) {
diff --git a/java/com/android/pump/db/Other.java b/java/com/android/pump/db/Other.java
index 4efe11a..ecd8ade 100644
--- a/java/com/android/pump/db/Other.java
+++ b/java/com/android/pump/db/Other.java
@@ -33,8 +33,8 @@
     private Uri mThumbnailUri;
     private boolean mLoaded;
 
-    Other(long id, @NonNull Uri uri, @NonNull String mimeType, @NonNull String title) {
-        super(id, uri, mimeType);
+    Other(long id, @NonNull String mimeType, @NonNull String title) {
+        super(id, mimeType);
 
         mTitle = title;
         mDuration = Long.MIN_VALUE;
diff --git a/java/com/android/pump/db/Video.java b/java/com/android/pump/db/Video.java
index 80bddb8..0610e27 100644
--- a/java/com/android/pump/db/Video.java
+++ b/java/com/android/pump/db/Video.java
@@ -16,8 +16,6 @@
 
 package com.android.pump.db;
 
-import android.net.Uri;
-
 import androidx.annotation.AnyThread;
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
@@ -25,12 +23,10 @@
 @AnyThread
 public abstract class Video {
     private final long mId;
-    private final Uri mUri;
     private final String mMimeType;
 
-    Video(long id, @NonNull Uri uri, @NonNull String mimeType) {
+    Video(long id, @NonNull String mimeType) {
         mId = id;
-        mUri = uri;
         mMimeType = mimeType;
     }
 
@@ -38,10 +34,6 @@
         return mId;
     }
 
-    public @NonNull Uri getUri() {
-        return mUri;
-    }
-
     public @NonNull String getMimeType() {
         return mMimeType;
     }
diff --git a/java/com/android/pump/db/VideoStore.java b/java/com/android/pump/db/VideoStore.java
index 7affd95..657c0c1 100644
--- a/java/com/android/pump/db/VideoStore.java
+++ b/java/com/android/pump/db/VideoStore.java
@@ -150,14 +150,13 @@
                             String data = cursor.getString(dataColumn);
                             file = new File(data);
                         }
-                        Uri uri = Uri.fromFile(file);
-                        Query query = Query.parse(uri);
+                        Query query = Query.parse(Uri.fromFile(file));
                         if (query.isMovie()) {
                             Movie movie;
                             if (query.hasYear()) {
-                                movie = new Movie(id, uri, mimeType, query.getName(), query.getYear());
+                                movie = new Movie(id, mimeType, query.getName(), query.getYear());
                             } else {
-                                movie = new Movie(id, uri, mimeType, query.getName());
+                                movie = new Movie(id, mimeType, query.getName());
                             }
                             movies.add(movie);
                         } else if (query.isEpisode()) {
@@ -179,13 +178,13 @@
                                 series.add(serie);
                             }
 
-                            Episode episode = new Episode(id, uri, mimeType, serie,
+                            Episode episode = new Episode(id, mimeType, serie,
                                     query.getSeason(), query.getEpisode());
                             episodes.add(episode);
 
                             serie.addEpisode(episode);
                         } else {
-                            Other other = new Other(id, uri, mimeType, query.getName());
+                            Other other = new Other(id, mimeType, query.getName());
                             others.add(other);
                         }
                     }