Jeff Sharkey | 56c34e8 | 2019-11-21 15:56:37 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.providers.media.scan; |
| 18 | |
| 19 | import android.content.Context; |
| 20 | import android.net.Uri; |
| 21 | import android.provider.MediaStore; |
| 22 | import android.util.Log; |
| 23 | |
Sahana Rao | 73c358c | 2020-02-17 10:34:42 +0000 | [diff] [blame] | 24 | import androidx.annotation.Nullable; |
| 25 | |
Martijn Coenen | b5d6dde | 2021-04-01 16:17:41 +0200 | [diff] [blame] | 26 | import com.android.providers.media.MediaVolume; |
| 27 | |
Jeff Sharkey | 56c34e8 | 2019-11-21 15:56:37 -0700 | [diff] [blame] | 28 | import 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 | */ |
| 34 | public 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 Coenen | b5d6dde | 2021-04-01 16:17:41 +0200 | [diff] [blame] | 60 | public void onDetachVolume(MediaVolume volume) { |
Jeff Sharkey | 56c34e8 | 2019-11-21 15:56:37 -0700 | [diff] [blame] | 61 | // Ignored |
| 62 | } |
Zim | 32d6b15 | 2020-09-30 18:33:22 +0100 | [diff] [blame] | 63 | |
| 64 | @Override |
| 65 | public void onIdleScanStopped() { |
| 66 | // Ignored |
| 67 | } |
Zim | 7e730f3 | 2020-09-30 11:38:50 +0100 | [diff] [blame] | 68 | |
| 69 | @Override |
| 70 | public void onDirectoryDirty(File file) { |
| 71 | // Ignored |
| 72 | } |
Jeff Sharkey | 56c34e8 | 2019-11-21 15:56:37 -0700 | [diff] [blame] | 73 | } |