1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.media;
18 
19 import android.compat.annotation.UnsupportedAppUsage;
20 import android.content.ContentValues;
21 import android.content.Context;
22 import android.net.Uri;
23 import android.os.Build;
24 import android.os.RemoteException;
25 
26 /**
27  * @hide
28  * @deprecated this media scanner has served faithfully for many years, but it's
29  *             become tedious to test and maintain, mainly due to the way it
30  *             weaves obscurely between managed and native code. It's been
31  *             replaced by {@code ModernMediaScanner} in the
32  *             {@code MediaProvider} package.
33  */
34 @Deprecated
35 public class MediaScanner implements AutoCloseable {
36     @Deprecated
37     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
38     private static final String[] FILES_PRESCAN_PROJECTION = new String[] {
39     };
40 
41     @Deprecated
42     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
43     private final Context mContext;
44     @Deprecated
45     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
46     private final String mPackageName;
47     @Deprecated
48     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
49     private final Uri mAudioUri;
50     @Deprecated
51     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
52     private final Uri mFilesUri;
53 
54     @Deprecated
55     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
56     private String mDefaultRingtoneFilename;
57     @Deprecated
58     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
59     private String mDefaultNotificationFilename;
60     @Deprecated
61     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
62     private String mDefaultAlarmAlertFilename;
63 
64     private static class FileEntry {
65         @Deprecated
66         @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
67         long mRowId;
68         @Deprecated
69         @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
70         boolean mLastModifiedChanged;
71 
72         @Deprecated
73         @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
FileEntry(long rowId, String path, long lastModified, int format)74         FileEntry(long rowId, String path, long lastModified, int format) {
75             throw new UnsupportedOperationException();
76         }
77     }
78 
79     @Deprecated
80     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
81     private MediaInserter mMediaInserter;
82 
83     @Deprecated
84     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
MediaScanner(Context c, String volumeName)85     public MediaScanner(Context c, String volumeName) {
86         throw new UnsupportedOperationException();
87     }
88 
89     @Deprecated
90     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
91     private final MyMediaScannerClient mClient = new MyMediaScannerClient();
92 
93     @Deprecated
94     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
isDrmEnabled()95     private boolean isDrmEnabled() {
96         throw new UnsupportedOperationException();
97     }
98 
99     private class MyMediaScannerClient implements MediaScannerClient {
100         @Deprecated
101         @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
102         private String mMimeType;
103         @Deprecated
104         @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
105         private int mFileType;
106         @Deprecated
107         @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
108         private String mPath;
109         @Deprecated
110         @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
111         private boolean mIsDrm;
112         @Deprecated
113         @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
114         private boolean mNoMedia;
115 
MyMediaScannerClient()116         public MyMediaScannerClient() {
117             throw new UnsupportedOperationException();
118         }
119 
120         @Deprecated
121         @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
beginFile(String path, String mimeType, long lastModified, long fileSize, boolean isDirectory, boolean noMedia)122         public FileEntry beginFile(String path, String mimeType, long lastModified,
123                 long fileSize, boolean isDirectory, boolean noMedia) {
124             throw new UnsupportedOperationException();
125         }
126 
127         @Deprecated
128         @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
scanFile(String path, long lastModified, long fileSize, boolean isDirectory, boolean noMedia)129         public void scanFile(String path, long lastModified, long fileSize,
130                 boolean isDirectory, boolean noMedia) {
131             throw new UnsupportedOperationException();
132         }
133 
134         @Deprecated
135         @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
doScanFile(String path, String mimeType, long lastModified, long fileSize, boolean isDirectory, boolean scanAlways, boolean noMedia)136         public Uri doScanFile(String path, String mimeType, long lastModified,
137                 long fileSize, boolean isDirectory, boolean scanAlways, boolean noMedia) {
138             throw new UnsupportedOperationException();
139         }
140 
141         @Deprecated
142         @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
handleStringTag(String name, String value)143         public void handleStringTag(String name, String value) {
144             throw new UnsupportedOperationException();
145         }
146 
147         @Deprecated
148         @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
setMimeType(String mimeType)149         public void setMimeType(String mimeType) {
150             throw new UnsupportedOperationException();
151         }
152 
153         @Deprecated
154         @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
toValues()155         private ContentValues toValues() {
156             throw new UnsupportedOperationException();
157         }
158 
159         @Deprecated
160         @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
endFile(FileEntry entry, boolean ringtones, boolean notifications, boolean alarms, boolean podcasts, boolean audiobooks, boolean music)161         private Uri endFile(FileEntry entry, boolean ringtones, boolean notifications,
162                 boolean alarms, boolean podcasts, boolean audiobooks, boolean music)
163                 throws RemoteException {
164             throw new UnsupportedOperationException();
165         }
166 
167         @Deprecated
168         @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
getFileTypeFromDrm(String path)169         private int getFileTypeFromDrm(String path) {
170             throw new UnsupportedOperationException();
171         }
172     }
173 
174     @Deprecated
175     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
prescan(String filePath, boolean prescanFiles)176     private void prescan(String filePath, boolean prescanFiles) throws RemoteException {
177         throw new UnsupportedOperationException();
178     }
179 
180     @Deprecated
181     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
postscan(final String[] directories)182     private void postscan(final String[] directories) throws RemoteException {
183         throw new UnsupportedOperationException();
184     }
185 
186     @Deprecated
187     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
scanSingleFile(String path, String mimeType)188     public Uri scanSingleFile(String path, String mimeType) {
189         throw new UnsupportedOperationException();
190     }
191 
192     @Deprecated
193     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
isNoMediaPath(String path)194     public static boolean isNoMediaPath(String path) {
195         throw new UnsupportedOperationException();
196     }
197 
198     @Deprecated
199     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
makeEntryFor(String path)200     FileEntry makeEntryFor(String path) {
201         throw new UnsupportedOperationException();
202     }
203 
204     @Deprecated
205     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "All scanning requests should be performed through {@link android.media.MediaScannerConnection}")
setLocale(String locale)206     private void setLocale(String locale) {
207         throw new UnsupportedOperationException();
208     }
209 
210     @Override
close()211     public void close() {
212         throw new UnsupportedOperationException();
213     }
214 }
215