1 /* 2 * Copyright (C) 2022 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 18 package com.android.systemui.util.service.dagger; 19 20 import android.content.res.Resources; 21 22 import com.android.systemui.R; 23 import com.android.systemui.dagger.qualifiers.Main; 24 25 import javax.inject.Named; 26 27 import dagger.Module; 28 import dagger.Provides; 29 30 /** 31 * Module containing components and parameters for 32 * {@link com.android.systemui.util.service.ObservableServiceConnection} 33 * and {@link com.android.systemui.util.service.PersistentConnectionManager}. 34 */ 35 @Module(subcomponents = { 36 PackageObserverComponent.class, 37 }) 38 public class ObservableServiceModule { 39 public static final String MAX_RECONNECT_ATTEMPTS = "max_reconnect_attempts"; 40 public static final String BASE_RECONNECT_DELAY_MS = "base_reconnect_attempts"; 41 public static final String MIN_CONNECTION_DURATION_MS = "min_connection_duration_ms"; 42 public static final String SERVICE_CONNECTION = "service_connection"; 43 public static final String OBSERVER = "observer"; 44 45 @Provides 46 @Named(MAX_RECONNECT_ATTEMPTS) providesMaxReconnectAttempts(@ain Resources resources)47 static int providesMaxReconnectAttempts(@Main Resources resources) { 48 return resources.getInteger( 49 R.integer.config_communalSourceMaxReconnectAttempts); 50 } 51 52 @Provides 53 @Named(BASE_RECONNECT_DELAY_MS) provideBaseReconnectDelayMs(@ain Resources resources)54 static int provideBaseReconnectDelayMs(@Main Resources resources) { 55 return resources.getInteger( 56 R.integer.config_communalSourceReconnectBaseDelay); 57 } 58 59 @Provides 60 @Named(MIN_CONNECTION_DURATION_MS) providesMinConnectionDuration(@ain Resources resources)61 static int providesMinConnectionDuration(@Main Resources resources) { 62 return resources.getInteger( 63 R.integer.config_connectionMinDuration); 64 } 65 } 66