Extract getSystemUpdateIntent, and add unit test. Bug: 311110616 Test: manual - on "Software updates" page Test: unit test Change-Id: Ic7c06490d1d324705f547b2394794605e85485a4
39 lines
1.3 KiB
Kotlin
39 lines
1.3 KiB
Kotlin
/*
|
|
* Copyright (C) 2023 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.settings.system
|
|
|
|
import android.content.Context
|
|
import android.content.Intent
|
|
import android.content.pm.PackageManager
|
|
import android.provider.Settings
|
|
|
|
class SystemUpdateRepository(context: Context) {
|
|
private val packageManager = context.packageManager
|
|
|
|
/**
|
|
* Finds a matching activity for the system update intent.
|
|
*/
|
|
fun getSystemUpdateIntent(): Intent? {
|
|
val intent = Intent(Settings.ACTION_SYSTEM_UPDATE_SETTINGS)
|
|
return packageManager.resolveActivity(intent, PackageManager.MATCH_SYSTEM_ONLY)
|
|
?.activityInfo
|
|
?.let { activityInfo ->
|
|
Intent().setClassName(activityInfo.packageName, activityInfo.name)
|
|
}
|
|
}
|
|
}
|