blob: 5a2fa3388e1284b822173788b4f0c769a044caec [file] [log] [blame]
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.wallpaper.module
import android.content.Context
import android.content.Intent
import android.content.Intent.ACTION_SET_WALLPAPER
import android.content.pm.PackageManager.MATCH_DEFAULT_ONLY
import android.provider.Settings.*
/**
* Utility class to check the support of multi panes integration (trampoline)
*/
class LargeScreenMultiPanesChecker : MultiPanesChecker {
companion object {
private const val TAG = "LargeScreenMultiPanesChecker"
private const val VALUE_HIGHLIGHT_MENU = "top_level_wallpaper"
}
override fun isMultiPanesEnabled(context: Context): Boolean {
val pm = context.packageManager
val intent = getMultiPanesIntent(context)
val resolveInfo = pm.resolveActivity(intent, MATCH_DEFAULT_ONLY)?.activityInfo?.enabled
return resolveInfo != null
}
override fun getMultiPanesIntent(context: Context): Intent {
val intentUri = Intent(ACTION_SET_WALLPAPER)
.setPackage(context.packageName).toUri(Intent.URI_INTENT_SCHEME)
return Intent(ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY).apply {
putExtra(EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_HIGHLIGHT_MENU_KEY, VALUE_HIGHLIGHT_MENU)
putExtra(EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI, intentUri)
};
}
}