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.launcher3.testing; 18 19 import android.content.ContentProvider; 20 import android.content.ContentValues; 21 import android.database.Cursor; 22 import android.net.Uri; 23 import android.os.Bundle; 24 import android.util.Log; 25 26 import com.android.launcher3.Utilities; 27 28 public class TestInformationProvider extends ContentProvider { 29 30 private static final String TAG = "TestInformationProvider"; 31 32 @Override onCreate()33 public boolean onCreate() { 34 return true; 35 } 36 37 @Override update(Uri uri, ContentValues contentValues, String s, String[] strings)38 public int update(Uri uri, ContentValues contentValues, String s, String[] strings) { 39 return 0; 40 } 41 42 @Override delete(Uri uri, String s, String[] strings)43 public int delete(Uri uri, String s, String[] strings) { 44 return 0; 45 } 46 47 @Override insert(Uri uri, ContentValues contentValues)48 public Uri insert(Uri uri, ContentValues contentValues) { 49 return null; 50 } 51 52 @Override getType(Uri uri)53 public String getType(Uri uri) { 54 return null; 55 } 56 57 @Override query(Uri uri, String[] strings, String s, String[] strings1, String s1)58 public Cursor query(Uri uri, String[] strings, String s, String[] strings1, String s1) { 59 return null; 60 } 61 62 @Override call(String method, String arg, Bundle extras)63 public Bundle call(String method, String arg, Bundle extras) { 64 if (Utilities.isRunningInTestHarness()) { 65 TestInformationHandler handler = TestInformationHandler.newInstance(getContext()); 66 handler.init(getContext()); 67 68 Bundle response = handler.call(method, arg, extras); 69 if (response == null) { 70 Log.e(TAG, "Couldn't handle method: " + method + "; current handler=" 71 + handler.getClass().getSimpleName()); 72 } 73 return response; 74 } 75 return null; 76 } 77 } 78