Prevent Content Provider usage before API 25

Bug: 123529934
Test: unit tests
Bug: 129431284
Change-Id: I9e0baa8202f7bb712ff5c02bc3e33e5fc23b823a
Merged-In: I9e0baa8202f7bb712ff5c02bc3e33e5fc23b823a
diff --git a/src/com/android/tradefed/device/NativeDevice.java b/src/com/android/tradefed/device/NativeDevice.java
index 8dcd201..462ac41 100644
--- a/src/com/android/tradefed/device/NativeDevice.java
+++ b/src/com/android/tradefed/device/NativeDevice.java
@@ -4141,6 +4141,10 @@
     /** Returns the {@link ContentProviderHandler} or null if not available. */
     @VisibleForTesting
     ContentProviderHandler getContentProvider() throws DeviceNotAvailableException {
+        // Prevent usage of content provider before API 25 as it would not work well.
+        if (getApiLevel() < 25) {
+            return null;
+        }
         if (mContentProvider == null) {
             mContentProvider = new ContentProviderHandler(this);
         }