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

Commit e93c4a1e authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes Ib201260f,Ib3cd7e42 into main

* changes:
  Moving CrashRecoveryFiles to a separate Folder
  Introduce CrashRecovery Adaptor
parents b2be1ae5 a9d66fc7
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
filegroup {
    name: "crashrecovery-platform-adaptor-srcs",
    srcs: select(soong_config_variable("ANDROID", "release_crashrecovery_module"), {
        "true": [
            "postModularization/java/**/*.java",
        ],
        default: [
            "preModularization/java/**/*.java",
        ],
    }),
    visibility: ["//frameworks/base:__subpackages__"],
}
+72 −0
Original line number 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.server.crashrecovery;

import android.content.Context;

import com.android.server.PackageWatchdog;
import com.android.server.SystemServiceManager;

import java.util.List;

/**
 * This class mediates calls to hidden APIs in CrashRecovery module.
 * This class is used when the CrashRecovery classes are moved to separate module.
 *
 * @hide
 */
public class CrashRecoveryAdaptor {
    private static final String TAG = "CrashRecoveryAdaptor";
    private static final String CRASHRECOVERY_MODULE_LIFECYCLE_CLASS =
            "com.android.server.crashrecovery.CrashRecoveryModule$Lifecycle";

    /**  Start CrashRecoveryModule LifeCycleService */
    public static void initializeCrashrecoveryModuleService(
            SystemServiceManager mSystemServiceManager) {
        mSystemServiceManager.startService(CRASHRECOVERY_MODULE_LIFECYCLE_CLASS);
    }

    /**  Does Nothing */
    public static void packageWatchdogNoteBoot(Context mSystemContext) {
        // do nothing
    }

    /**  Does Nothing */
    public static void packageWatchdogWriteNow(Context mContext) {
        // do nothing
    }

    /**  Does Nothing */
    public static void packageWatchdogOnPackagesReady(PackageWatchdog mPackageWatchdog) {
        // do nothing
    }

    /**  Does Nothing */
    public static void rescuePartyRegisterHealthObserver(Context mSystemContext) {
        // do nothing
    }

    /**  Does Nothing */
    public static void rescuePartyOnSettingsProviderPublished(Context mContext) {
        // do nothing
    }

    /**  Does Nothing */
    public static void rescuePartyResetDeviceConfigForPackages(List<String> packageNames) {
        // do nothing
    }
}
+71 −0
Original line number 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.server.crashrecovery;

import android.content.Context;

import com.android.server.PackageWatchdog;
import com.android.server.RescueParty;
import com.android.server.SystemServiceManager;

import java.util.List;

/**
 * This class mediates calls to hidden APIs in CrashRecovery module.
 * This class is used when CrashRecovery classes are still in platform.
 *
 * @hide
 */
public class CrashRecoveryAdaptor {
    private static final String TAG = "CrashRecoveryAdaptor";

    /**  Start CrashRecoveryModule LifeCycleService */
    public static void initializeCrashrecoveryModuleService(
            SystemServiceManager mSystemServiceManager) {
        mSystemServiceManager.startService(CrashRecoveryModule.Lifecycle.class);
    }

    /**  Forward calls to PackageWatchdog noteboot  */
    public static void packageWatchdogNoteBoot(Context mSystemContext) {
        PackageWatchdog.getInstance(mSystemContext).noteBoot();
    }

    /**  Forward calls to PackageWatchdog writeNow */
    public static void packageWatchdogWriteNow(Context mContext) {
        PackageWatchdog.getInstance(mContext).writeNow();
    }

    /**  Forward calls to PackageWatchdog OnPackagesReady */
    public static void packageWatchdogOnPackagesReady(PackageWatchdog mPackageWatchdog) {
        mPackageWatchdog.onPackagesReady();
    }

    /**  Forward calls to RescueParty RegisterHealthObserver */
    public static void rescuePartyRegisterHealthObserver(Context mSystemContext) {
        RescueParty.registerHealthObserver(mSystemContext);
    }

    /**  Forward calls to RescueParty OnSettingsProviderPublished */
    public static void rescuePartyOnSettingsProviderPublished(Context mContext) {
        RescueParty.onSettingsProviderPublished(mContext);
    }

    /**  Forward calls to RescueParty ResetDeviceConfigForPackages */
    public static void rescuePartyResetDeviceConfigForPackages(List<String> packageNames) {
        RescueParty.resetDeviceConfigForPackages(packageNames);
    }
}
+10 −46
Original line number Diff line number Diff line
soong_config_module_type {
    name: "platform_filegroup",
    module_type: "filegroup",
    config_namespace: "ANDROID",
    bool_variables: [
        "crashrecovery_files_in_platform",
    ],
    properties: [
        "srcs",
    ],
}

platform_filegroup {
filegroup {
    name: "services-crashrecovery-sources",
    soong_config_variables: {
        // if this flag is enabled, then files are part of platform
        crashrecovery_files_in_platform: {
    srcs: [
                "java/**/*.java",
                "java/**/*.aidl",
        ":crashrecovery-platform-adaptor-srcs",
        ":statslog-crashrecovery-java-gen",
            ],
        },
    },
    ] + select(soong_config_variable("ANDROID", "release_crashrecovery_module"), {
        "true": [],
        default: ["platform/java/**/*.java"],
    }),
    visibility: ["//frameworks/base:__subpackages__"],
}

soong_config_module_type {
    name: "module_filegroup",
    module_type: "filegroup",
    config_namespace: "ANDROID",
    bool_variables: [
        "crashrecovery_files_in_module",
    ],
    properties: [
        "srcs",
    ],
}

module_filegroup {
filegroup {
    name: "services-crashrecovery-module-sources",
    soong_config_variables: {
        // if this flag is enabled, then files are part of module
        crashrecovery_files_in_module: {
            srcs: [
                "java/**/*.java",
                "java/**/*.aidl",
                ":statslog-crashrecovery-java-gen",
            ],
        },
    },
    srcs: ["module/java/**/*.java"],
    visibility: ["//packages/modules/CrashRecovery/service"],
}

+0 −0

File moved.

Loading