• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
24 /** Utility class to check the support of multi panes integration (trampoline) */
25 class LargeScreenMultiPanesChecker : MultiPanesChecker {
26     companion object {
27         private const val TAG = "LargeScreenMultiPanesChecker"
28         private const val VALUE_HIGHLIGHT_MENU = "top_level_wallpaper"
29     }
30 
isMultiPanesEnablednull31     override fun isMultiPanesEnabled(context: Context): Boolean {
32         val pm = context.packageManager
33         val intent =
34             getMultiPanesIntent(Intent(ACTION_SET_WALLPAPER).setPackage(context.packageName))
35 
36         val resolveInfo = pm.resolveActivity(intent, MATCH_DEFAULT_ONLY)?.activityInfo?.enabled
37         return resolveInfo != null
38     }
39 
getMultiPanesIntentnull40     override fun getMultiPanesIntent(intent: Intent): Intent {
41         return Intent(ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY).apply {
42             intent.extras?.let { putExtras(it) }
43             putExtra(EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_HIGHLIGHT_MENU_KEY, VALUE_HIGHLIGHT_MENU)
44             putExtra(
45                 EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI,
46                 intent.toUri(Intent.URI_INTENT_SCHEME)
47             )
48         }
49     }
50 }
51