Merge "Change the way how we call setStorageParams." into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-04-08 00:48:58 +00:00
committed by Android (Google) Code Review
10 changed files with 52 additions and 56 deletions

View File

@@ -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",

View File

@@ -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;
}

View File

@@ -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.
*/

View File

@@ -0,0 +1,27 @@
/*
* 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);
}

View File

@@ -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);

View File

@@ -21,7 +21,6 @@ import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.pm.DataLoaderParams;
import android.content.pm.DataLoaderParamsParcel;
@@ -32,8 +31,6 @@ import android.content.pm.InstallationFile;
import android.content.pm.InstallationFileParcel;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import android.os.incremental.IncrementalManager;
import android.system.ErrnoException;
import android.util.ExceptionUtils;
import android.util.Slog;
@@ -211,25 +208,6 @@ public abstract class DataLoaderService extends Service {
private final long mNativeInstance;
}
/* Used by native FileSystemConnector. */
private boolean setStorageParams(int storageId, boolean enableReadLogs) {
IncrementalManager incrementalManager = (IncrementalManager) getSystemService(
Context.INCREMENTAL_SERVICE);
if (incrementalManager == null) {
Slog.e(TAG, "Failed to obtain incrementalManager: " + storageId);
return false;
}
try {
// This has to be done directly in incrementalManager as the storage
// might be missing still.
incrementalManager.setStorageParams(storageId, enableReadLogs);
} catch (ErrnoException e) {
Slog.e(TAG, "Failed to set params for storage: " + storageId, e);
return false;
}
return true;
}
/* Native methods */
private native boolean nativeCreateDataLoader(int storageId,
@NonNull FileSystemControlParcel control,

View File

@@ -155,11 +155,6 @@ binder::Status BinderIncrementalService::deleteStorage(int32_t storageId) {
return ok();
}
binder::Status BinderIncrementalService::setStorageParams(int32_t storage, bool enableReadLogs, int32_t* _aidl_return) {
*_aidl_return = mImpl.setStorageParams(storage, enableReadLogs);
return ok();
}
binder::Status BinderIncrementalService::makeDirectory(int32_t storageId, const std::string& path,
int32_t* _aidl_return) {
*_aidl_return = mImpl.makeDir(storageId, path);

View File

@@ -71,7 +71,6 @@ public:
binder::Status configureNativeBinaries(int32_t storageId, const std::string& apkFullPath,
const std::string& libDirRelativePath,
const std::string& abi, bool* _aidl_return) final;
binder::Status setStorageParams(int32_t storage, bool enableReadLogs, int32_t* _aidl_return) final;
private:
android::incremental::IncrementalService mImpl;

View File

@@ -1153,6 +1153,7 @@ bool IncrementalService::prepareDataLoader(IncrementalService::IncFsMount& ifs,
fsControlParcel.incremental->pendingReads.reset(
base::unique_fd(::dup(ifs.control.pendingReads())));
fsControlParcel.incremental->log.reset(base::unique_fd(::dup(ifs.control.logs())));
fsControlParcel.service = new IncrementalServiceConnector(*this, ifs.mountId);
sp<IncrementalDataLoaderListener> listener =
new IncrementalDataLoaderListener(*this,
externalListener ? *externalListener
@@ -1451,4 +1452,10 @@ void IncrementalService::AppOpsListener::opChanged(int32_t, const String16&) {
incrementalService.onAppOpChanged(packageName);
}
binder::Status IncrementalService::IncrementalServiceConnector::setStorageParams(
bool enableReadLogs, int32_t* _aidl_return) {
*_aidl_return = incrementalService.setStorageParams(storage, enableReadLogs);
return binder::Status::ok();
}
} // namespace android::incremental

View File

@@ -39,6 +39,7 @@
#include "ServiceWrappers.h"
#include "android/content/pm/BnDataLoaderStatusListener.h"
#include "android/os/incremental/BnIncrementalServiceConnector.h"
#include "incfs.h"
#include "path.h"
@@ -139,7 +140,7 @@ public:
DataLoaderStatusListener externalListener)
: incrementalService(incrementalService), externalListener(externalListener) {}
// Callbacks interface
binder::Status onStatusChanged(MountId mount, int newStatus) override;
binder::Status onStatusChanged(MountId mount, int newStatus) final;
private:
IncrementalService& incrementalService;
@@ -149,13 +150,24 @@ public:
class AppOpsListener : public android::BnAppOpsCallback {
public:
AppOpsListener(IncrementalService& incrementalService, std::string packageName) : incrementalService(incrementalService), packageName(std::move(packageName)) {}
void opChanged(int32_t op, const String16& packageName) override;
void opChanged(int32_t op, const String16& packageName) final;
private:
IncrementalService& incrementalService;
const std::string packageName;
};
class IncrementalServiceConnector : public BnIncrementalServiceConnector {
public:
IncrementalServiceConnector(IncrementalService& incrementalService, int32_t storage)
: incrementalService(incrementalService) {}
binder::Status setStorageParams(bool enableReadLogs, int32_t* _aidl_return) final;
private:
IncrementalService& incrementalService;
int32_t storage;
};
private:
static const bool sEnablePerfLogging;