1 /* 2 * Copyright (C) 2024 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.wallpaper.testing 18 19 import android.app.WallpaperInfo 20 import android.content.ComponentName 21 import android.content.Context 22 import android.content.pm.ResolveInfo 23 import android.content.pm.ServiceInfo 24 import org.robolectric.annotation.Implementation 25 import org.robolectric.annotation.Implements 26 27 @Implements(WallpaperInfo::class) 28 class ShadowWallpaperInfo { 29 private lateinit var context: Context 30 private lateinit var resolveInfo: ResolveInfo 31 32 // CHECKSTYLE:OFF Generated code 33 @Implementation __constructor__null34 fun __constructor__(context: Context, resolveInfo: ResolveInfo) { 35 this.context = context 36 this.resolveInfo = resolveInfo 37 } 38 39 @Implementation getPackageNamenull40 fun getPackageName(): String { 41 return resolveInfo.serviceInfo.packageName 42 } 43 44 @Implementation getServiceInfonull45 fun getServiceInfo(): ServiceInfo { 46 return resolveInfo.serviceInfo 47 } 48 49 @Implementation getComponentnull50 fun getComponent(): ComponentName { 51 return ComponentName(resolveInfo.serviceInfo.packageName, resolveInfo.serviceInfo.name) 52 } 53 54 @Implementation getServiceNamenull55 fun getServiceName(): String { 56 return resolveInfo.serviceInfo.name 57 } 58 } 59