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.systemui.assist; 18 19 import android.content.Context; 20 import android.os.Handler; 21 import android.os.HandlerThread; 22 import android.os.SystemClock; 23 24 import androidx.slice.Clock; 25 26 import com.android.internal.app.AssistUtils; 27 import com.android.systemui.dagger.SysUISingleton; 28 29 import dagger.Module; 30 import dagger.Provides; 31 32 import javax.inject.Named; 33 34 /** Module for dagger injections related to the Assistant. */ 35 @Module 36 public abstract class AssistModule { 37 38 static final String ASSIST_HANDLE_THREAD_NAME = "assist_handle_thread"; 39 static final String UPTIME_NAME = "uptime"; 40 41 @Provides 42 @SysUISingleton 43 @Named(ASSIST_HANDLE_THREAD_NAME) provideBackgroundHandler()44 static Handler provideBackgroundHandler() { 45 final HandlerThread backgroundHandlerThread = 46 new HandlerThread("AssistHandleThread"); 47 backgroundHandlerThread.start(); 48 return backgroundHandlerThread.getThreadHandler(); 49 } 50 51 @Provides 52 @SysUISingleton provideAssistUtils(Context context)53 static AssistUtils provideAssistUtils(Context context) { 54 return new AssistUtils(context); 55 } 56 57 @Provides 58 @SysUISingleton 59 @Named(UPTIME_NAME) provideSystemClock()60 static Clock provideSystemClock() { 61 return SystemClock::uptimeMillis; 62 } 63 } 64