blob: e53f964688c824827cedbb0f72b2d44bcef8cae7 [file] [log] [blame]
Jeff Sharkey56c34e82019-11-21 15:56:37 -07001/*
2 * Copyright (C) 2019 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
17package com.android.providers.media.scan;
18
19import android.content.Context;
20import android.net.Uri;
21import android.provider.MediaStore;
22import android.util.Log;
23
Sahana Rao73c358c2020-02-17 10:34:42 +000024import androidx.annotation.Nullable;
25
Martijn Coenenb5d6dde2021-04-01 16:17:41 +020026import com.android.providers.media.MediaVolume;
27
Jeff Sharkey56c34e82019-11-21 15:56:37 -070028import java.io.File;
29
30/**
31 * Null scanner that ignores all scanning requests. Can be useful when running
32 * as {@link MediaStore#AUTHORITY_LEGACY} or during unit tests.
33 */
34public class NullMediaScanner implements MediaScanner {
35 private static final String TAG = "NullMediaScanner";
36
37 private final Context mContext;
38
39 public NullMediaScanner(Context context) {
40 mContext = context;
41 }
42
43 @Override
44 public Context getContext() {
45 return mContext;
46 }
47
48 @Override
49 public void scanDirectory(File file, int reason) {
50 Log.w(TAG, "Ignoring scan request for " + file);
51 }
52
53 @Override
54 public Uri scanFile(File file, int reason) {
55 Log.w(TAG, "Ignoring scan request for " + file);
56 return null;
57 }
58
59 @Override
Martijn Coenenb5d6dde2021-04-01 16:17:41 +020060 public void onDetachVolume(MediaVolume volume) {
Jeff Sharkey56c34e82019-11-21 15:56:37 -070061 // Ignored
62 }
Zim32d6b152020-09-30 18:33:22 +010063
64 @Override
65 public void onIdleScanStopped() {
66 // Ignored
67 }
Zim7e730f32020-09-30 11:38:50 +010068
69 @Override
70 public void onDirectoryDirty(File file) {
71 // Ignored
72 }
Jeff Sharkey56c34e82019-11-21 15:56:37 -070073}