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

Commit f76b9d49 authored by Sameer's avatar Sameer
Browse files

Add TvWatchdogSettings, IoOveruseHandler

Bug: 335423167
Test: m
Flag: android.media.tv.flags.enable_tv_watchdog_emmc_protection
Change-Id: I5dce111a63817acbaa9388af967c9c41f9c7630c
parent c74da9dc
Loading
Loading
Loading
Loading
+58 −0
Original line number Diff line number Diff line
/*
 * Copyright 2025 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.server.tv.watchdogservice;

import android.annotation.UserIdInt;
import android.text.TextUtils;
import android.util.ArraySet;

import java.util.StringJoiner;

/**
 * This is a temporary stub class to allow the main service to compile. It will be replaced with the
 * real IoOveruseHandler generated via genrules from CarWatchdog.
 */
public final class IoOveruseHandler {

    /** Parses a semicolon-separated string of package names. */
    public static ArraySet<String> extractPackages(String settingsString) {
        ArraySet<String> packages = new ArraySet<>();
        if (TextUtils.isEmpty(settingsString)) {
            return packages;
        }
        for (String pkg : settingsString.split(";")) {
            if (!TextUtils.isEmpty(pkg)) {
                packages.add(pkg);
            }
        }
        return packages;
    }

    /** Constructs a semicolon-separated string from a set of packages. */
    public static String constructSettingsString(ArraySet<String> packages) {
        StringJoiner joiner = new StringJoiner(";");
        for (String pkg : packages) {
            joiner.add(pkg);
        }
        return joiner.toString();
    }

    /** Creates a unique identifier for a user-package combination. */
    public static String getUserPackageUniqueId(@UserIdInt int userId, String packageName) {
        return userId + ":" + packageName;
    }
}
+37 −0
Original line number Diff line number Diff line
/*
 * Copyright 2025 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.server.tv.watchdogservice;

import android.provider.Settings;

/**
 * TV-specific settings, stored as name-value pairs.
 *
 * @hide
 */
public final class TvWatchdogSettings {
    /** Secure settings, containing system preferences that applications can read. */
    public static final class Secure extends Settings.NameValueTable {
        /**
         * A semicolon-separated list of packages disabled due to resource overuse.
         *
         * <p>Example: {@code "com.example.app1;com.vendor.service2"}
         */
        public static final String KEY_PACKAGES_DISABLED_ON_RESOURCE_OVERUSE =
                "android.tv.KEY_PACKAGES_DISABLED_ON_RESOURCE_OVERUSE";
    }
}