Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 95ed338a authored by Jacky Wang's avatar Jacky Wang Committed by Android (Google) Code Review
Browse files

Merge "Import SettingsLib/Service library" into main

parents 2c52955a 0ea110c1
Loading
Loading
Loading
Loading
+20 −0
Original line number Original line Diff line number Diff line
package {
    default_applicable_licenses: ["frameworks_base_license"],
}

filegroup {
    name: "SettingsLibService-srcs",
    srcs: ["src/**/*.kt"],
}

android_library {
    name: "SettingsLibService",
    defaults: [
        "SettingsLintDefaults",
    ],
    srcs: [":SettingsLibService-srcs"],
    static_libs: [
        "SettingsLibGraph",
    ],
    kotlincflags: ["-Xjvm-default=all"],
}
+6 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.settingslib.service">

  <uses-sdk android:minSdkVersion="21" />
</manifest>
+37 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2024 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.settingslib.service

import android.app.Application
import com.android.settingslib.graph.GetPreferenceGraphApiHandler
import com.android.settingslib.graph.GetPreferenceGraphRequest

/** Api to get preference graph. */
internal class PreferenceGraphApi(activityClasses: Set<String>) :
    GetPreferenceGraphApiHandler(activityClasses) {
    override val id: Int
        get() = API_GET_PREFERENCE_GRAPH

    override fun hasPermission(
        application: Application,
        myUid: Int,
        callingUid: Int,
        request: GetPreferenceGraphRequest,
    ): Boolean {
        return true // TODO: add permission check
    }
}
+37 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2024 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.settingslib.service

import com.android.settingslib.ipc.ApiHandler
import com.android.settingslib.ipc.MessengerService
import com.android.settingslib.ipc.PermissionChecker

/**
 * Preference service providing a bunch of APIs.
 *
 * In AndroidManifest.xml, the <service> must specify <intent-filter> with action
 * [PREFERENCE_SERVICE_ACTION].
 */
open class PreferenceService(
    permissionChecker: PermissionChecker,
    name: String = "PreferenceService",
) :
    MessengerService(
        listOf<ApiHandler<*, *>>(PreferenceGraphApi(setOf())),
        permissionChecker,
        name,
    )
+21 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2024 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.settingslib.service

const val PREFERENCE_SERVICE_ACTION = "com.android.settingslib.PREFERENCE_SERVICE"

internal const val API_GET_PREFERENCE_GRAPH = 1