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

Commit f4156792 authored by Alex Buynytskyy's avatar Alex Buynytskyy
Browse files

Change the way how we call setStorageParams.

Now it's unified with callback FS connector - we are passing the
callback pointer directly to dataloader. This restricts access only
to methods we want and only by someone we want.

Bug: b/153468113
Test: atest PackageManagerShellCommandTest PackageManagerShellCommandIncrementalTest IncrementalServiceTest
Change-Id: Ib557ebbe7c6c5ce92140eb20534a3626b3ac96d3
parent 21f4dd5c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -911,6 +911,7 @@ cc_library {
filegroup {
    name: "incremental_aidl",
    srcs: [
        "core/java/android/os/incremental/IIncrementalServiceConnector.aidl",
        "core/java/android/os/incremental/IncrementalFileSystemControlParcel.aidl",
    ],
    path: "core/java",
+3 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.content.pm;

import android.content.pm.IPackageInstallerSessionFileSystemConnector;
import android.os.incremental.IIncrementalServiceConnector;
import android.os.incremental.IncrementalFileSystemControlParcel;

/**
@@ -26,6 +27,8 @@ import android.os.incremental.IncrementalFileSystemControlParcel;
parcelable FileSystemControlParcel {
    // Incremental FS control descriptors.
    @nullable IncrementalFileSystemControlParcel incremental;
    // Incremental FS service.
    @nullable IIncrementalServiceConnector service;
    // Callback-based installation connector.
    @nullable IPackageInstallerSessionFileSystemConnector callback;
}
+0 −7
Original line number Diff line number Diff line
@@ -37,13 +37,6 @@ interface IIncrementalService {
    int createStorage(in @utf8InCpp String path, in DataLoaderParamsParcel params, in IDataLoaderStatusListener listener, int createMode);
    int createLinkedStorage(in @utf8InCpp String path, int otherStorageId, int createMode);

    /**
     * Changes storage params. Returns 0 on success, and -errno on failure.
     * Use enableReadLogs to switch pages read logs reporting on and off.
     * Returns 0 on success, and - errno on failure: permission check or remount.
     */
    int setStorageParams(int storageId, boolean enableReadLogs);

    /**
     * Bind-mounts a path under a storage to a full path. Can be permanent or temporary.
     */
+27 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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 */
interface IIncrementalServiceConnector {
    /**
     * Changes storage params. Returns 0 on success, and -errno on failure.
     * Use enableReadLogs to switch pages read logs reporting on and off.
     * Returns 0 on success, and - errno on failure: permission check or remount.
     */
    int setStorageParams(boolean enableReadLogs);
}
+0 −19
Original line number Diff line number Diff line
@@ -19,13 +19,11 @@ package android.os.incremental;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemService;
import android.content.Context;
import android.content.pm.DataLoaderParams;
import android.content.pm.IDataLoaderStatusListener;
import android.os.RemoteException;
import android.system.ErrnoException;
import android.util.SparseArray;

import com.android.internal.annotations.GuardedBy;
@@ -321,23 +319,6 @@ public final class IncrementalManager {
        return nativeUnsafeGetFileSignature(path);
    }

    /**
     * Sets storage parameters.
     *
     * @param enableReadLogs - enables or disables read logs. Caller has to have a permission.
     */
    @RequiresPermission(android.Manifest.permission.LOADER_USAGE_STATS)
    public void setStorageParams(int storageId, boolean enableReadLogs) throws ErrnoException {
        try {
            int res = mService.setStorageParams(storageId, enableReadLogs);
            if (res < 0) {
                throw new ErrnoException("setStorageParams", -res);
            }
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
    }

    /* Native methods */
    private static native boolean nativeIsEnabled();
    private static native boolean nativeIsIncrementalPath(@NonNull String path);
Loading