1 /* 2 * Copyright (C) 2018 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.dialer.contacts; 18 19 import android.content.Context; 20 import android.os.UserManager; 21 import com.android.dialer.contacts.displaypreference.ContactDisplayPreferences; 22 import com.android.dialer.contacts.displaypreference.ContactDisplayPreferencesImpl; 23 import com.android.dialer.contacts.displaypreference.ContactDisplayPreferencesStub; 24 import com.android.dialer.contacts.hiresphoto.HighResolutionPhotoRequester; 25 import com.android.dialer.contacts.hiresphoto.HighResolutionPhotoRequesterImpl; 26 import com.android.dialer.inject.ApplicationContext; 27 import com.android.dialer.inject.DialerVariant; 28 import com.android.dialer.inject.InstallIn; 29 import dagger.Binds; 30 import dagger.Lazy; 31 import dagger.Module; 32 import dagger.Provides; 33 34 /** Module for standard {@link ContactsComponent} */ 35 @InstallIn(variants = {DialerVariant.DIALER_TEST}) 36 @Module 37 public abstract class ContactsModule { 38 @Provides provideContactDisplayPreferences( @pplicationContext Context appContext, Lazy<ContactDisplayPreferencesImpl> impl, ContactDisplayPreferencesStub stub)39 public static ContactDisplayPreferences provideContactDisplayPreferences( 40 @ApplicationContext Context appContext, 41 Lazy<ContactDisplayPreferencesImpl> impl, 42 ContactDisplayPreferencesStub stub) { 43 if (appContext.getSystemService(UserManager.class).isUserUnlocked()) { 44 return impl.get(); 45 } 46 return stub; 47 } 48 49 @Binds toHighResolutionPhotoRequesterImpl( HighResolutionPhotoRequesterImpl impl)50 public abstract HighResolutionPhotoRequester toHighResolutionPhotoRequesterImpl( 51 HighResolutionPhotoRequesterImpl impl); 52 } 53