1 /* 2 * Copyright (C) 2021 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 package com.android.wallpaper.module 17 18 import android.content.Context 19 import android.content.Intent 20 import android.content.Intent.ACTION_SET_WALLPAPER 21 import android.content.pm.PackageManager.MATCH_DEFAULT_ONLY 22 import android.provider.Settings.* 23 import com.android.wallpaper.util.DisplayUtils 24 25 /** Utility class to check the support of multi panes integration (trampoline) */ 26 class LargeScreenMultiPanesChecker : MultiPanesChecker { 27 companion object { 28 private const val TAG = "LargeScreenMultiPanesChecker" 29 private const val VALUE_HIGHLIGHT_MENU = "top_level_wallpaper" 30 } 31 isMultiPanesEnablednull32 override fun isMultiPanesEnabled(context: Context): Boolean { 33 val pm = context.packageManager 34 val intent = 35 getMultiPanesIntent(Intent(ACTION_SET_WALLPAPER).setPackage(context.packageName)) 36 37 val resolveInfo = pm.resolveActivity(intent, MATCH_DEFAULT_ONLY)?.activityInfo 38 return resolveInfo != null && DisplayUtils(context).isLargeScreenDevice() 39 } 40 getMultiPanesIntentnull41 override fun getMultiPanesIntent(intent: Intent): Intent { 42 return Intent(ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY).apply { 43 intent.extras?.let { putExtras(it) } 44 putExtra(EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_HIGHLIGHT_MENU_KEY, VALUE_HIGHLIGHT_MENU) 45 putExtra( 46 EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI, 47 intent.toUri(Intent.URI_INTENT_SCHEME) 48 ) 49 } 50 } 51 } 52