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

Commit 72d08dbd authored by Alex Buynytskyy's avatar Alex Buynytskyy Committed by Automerger Merge Worker
Browse files

Merge "Lifecycle: detecting blocked and unhealthy." into rvc-dev am: 4e5ff2eb am: 1ad65218

Change-Id: Ida85b0b2c223906abb532860c16f1267200327c0
parents 129c17ee 1ad65218
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1007,6 +1007,8 @@ filegroup {
    srcs: [
        "core/java/android/os/incremental/IIncrementalService.aidl",
        "core/java/android/os/incremental/IncrementalNewFileParams.aidl",
        "core/java/android/os/incremental/IStorageHealthListener.aidl",
        "core/java/android/os/incremental/StorageHealthCheckParams.aidl",
    ],
    path: "core/java",
}
+6 −1
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package android.os.incremental;
import android.content.pm.DataLoaderParamsParcel;
import android.content.pm.IDataLoaderStatusListener;
import android.os.incremental.IncrementalNewFileParams;
import android.os.incremental.IStorageHealthListener;
import android.os.incremental.StorageHealthCheckParams;

/** @hide */
interface IIncrementalService {
@@ -34,7 +36,10 @@ interface IIncrementalService {
     * Opens or creates a storage given a target path and data loader params. Returns the storage ID.
     */
    int openStorage(in @utf8InCpp String path);
    int createStorage(in @utf8InCpp String path, in DataLoaderParamsParcel params, in IDataLoaderStatusListener listener, int createMode);
    int createStorage(in @utf8InCpp String path, in DataLoaderParamsParcel params, int createMode,
                      in IDataLoaderStatusListener statusListener,
                      in StorageHealthCheckParams healthCheckParams,
                      in IStorageHealthListener healthListener);
    int createLinkedStorage(in @utf8InCpp String path, int otherStorageId, int createMode);

    /**
+35 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 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 android.os.incremental;

/** @hide */
oneway interface IStorageHealthListener {
    /** OK status, no pending reads. */
    const int HEALTH_STATUS_OK = 0;
    /* Statuses depend on timeouts defined in StorageHealthCheckParams. */
    /** Pending reads detected, waiting for params.blockedTimeoutMs to confirm blocked state. */
    const int HEALTH_STATUS_READS_PENDING = 1;
    /** There are reads pending for params.blockedTimeoutMs, waiting till
    *   params.unhealthyTimeoutMs to confirm unhealthy state. */
    const int HEALTH_STATUS_BLOCKED = 2;
    /** There are reads pending for params.unhealthyTimeoutMs>,
    *   marking storage as unhealthy. */
    const int HEALTH_STATUS_UNHEALTHY = 3;

    /** Health status callback. */
    void onHealthStatus(in int storageId, in int status);
}
+12 −9
Original line number Diff line number Diff line
@@ -65,7 +65,9 @@ public final class IncrementalFileStorages {
    public static IncrementalFileStorages initialize(Context context,
            @NonNull File stageDir,
            @NonNull DataLoaderParams dataLoaderParams,
            @Nullable IDataLoaderStatusListener dataLoaderStatusListener,
            @Nullable IDataLoaderStatusListener statusListener,
            @Nullable StorageHealthCheckParams healthCheckParams,
            @Nullable IStorageHealthListener healthListener,
            List<InstallationFileParcel> addedFiles) throws IOException {
        // TODO(b/136132412): sanity check if session should not be incremental
        IncrementalManager incrementalManager = (IncrementalManager) context.getSystemService(
@@ -75,9 +77,9 @@ public final class IncrementalFileStorages {
            throw new IOException("Failed to obtain incrementalManager.");
        }

        final IncrementalFileStorages result =
                new IncrementalFileStorages(stageDir, incrementalManager, dataLoaderParams,
                                            dataLoaderStatusListener);
        final IncrementalFileStorages result = new IncrementalFileStorages(stageDir,
                incrementalManager, dataLoaderParams, statusListener, healthCheckParams,
                healthListener);
        for (InstallationFileParcel file : addedFiles) {
            if (file.location == LOCATION_DATA_APP) {
                try {
@@ -100,7 +102,9 @@ public final class IncrementalFileStorages {
    private IncrementalFileStorages(@NonNull File stageDir,
            @NonNull IncrementalManager incrementalManager,
            @NonNull DataLoaderParams dataLoaderParams,
            @Nullable IDataLoaderStatusListener dataLoaderStatusListener) throws IOException {
            @Nullable IDataLoaderStatusListener statusListener,
            @Nullable StorageHealthCheckParams healthCheckParams,
            @Nullable IStorageHealthListener healthListener) throws IOException {
        try {
            mStageDir = stageDir;
            mIncrementalManager = incrementalManager;
@@ -117,10 +121,9 @@ public final class IncrementalFileStorages {
                mDefaultStorage.bind(stageDir.getAbsolutePath());
            } else {
                mDefaultStorage = mIncrementalManager.createStorage(stageDir.getAbsolutePath(),
                        dataLoaderParams,
                        dataLoaderStatusListener,
                        IncrementalManager.CREATE_MODE_CREATE
                                | IncrementalManager.CREATE_MODE_TEMPORARY_BIND, false);
                        dataLoaderParams, IncrementalManager.CREATE_MODE_CREATE
                                | IncrementalManager.CREATE_MODE_TEMPORARY_BIND, false,
                        statusListener, healthCheckParams, healthListener);
                if (mDefaultStorage == null) {
                    throw new IOException(
                            "Couldn't create incremental storage at " + stageDir);
+7 −3
Original line number Diff line number Diff line
@@ -110,11 +110,15 @@ public final class IncrementalManager {
     */
    @Nullable
    public IncrementalStorage createStorage(@NonNull String path,
            @NonNull DataLoaderParams params, @Nullable IDataLoaderStatusListener listener,
            @NonNull DataLoaderParams params,
            @CreateMode int createMode,
            boolean autoStartDataLoader) {
            boolean autoStartDataLoader,
            @Nullable IDataLoaderStatusListener statusListener,
            @Nullable StorageHealthCheckParams healthCheckParams,
            @Nullable IStorageHealthListener healthListener) {
        try {
            final int id = mService.createStorage(path, params.getData(), listener, createMode);
            final int id = mService.createStorage(path, params.getData(), createMode,
                    statusListener, healthCheckParams, healthListener);
            if (id < 0) {
                return null;
            }
Loading