Merge "Change the way how we call setStorageParams." into rvc-dev am: 9f16f2665a am: 14e544cd4d am: c7b9366a00
Change-Id: Id8921abfd0193da477770c00d07713474d626ac7
This commit is contained in:
@@ -911,6 +911,7 @@ cc_library {
|
|||||||
filegroup {
|
filegroup {
|
||||||
name: "incremental_aidl",
|
name: "incremental_aidl",
|
||||||
srcs: [
|
srcs: [
|
||||||
|
"core/java/android/os/incremental/IIncrementalServiceConnector.aidl",
|
||||||
"core/java/android/os/incremental/IncrementalFileSystemControlParcel.aidl",
|
"core/java/android/os/incremental/IncrementalFileSystemControlParcel.aidl",
|
||||||
],
|
],
|
||||||
path: "core/java",
|
path: "core/java",
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package android.content.pm;
|
package android.content.pm;
|
||||||
|
|
||||||
import android.content.pm.IPackageInstallerSessionFileSystemConnector;
|
import android.content.pm.IPackageInstallerSessionFileSystemConnector;
|
||||||
|
import android.os.incremental.IIncrementalServiceConnector;
|
||||||
import android.os.incremental.IncrementalFileSystemControlParcel;
|
import android.os.incremental.IncrementalFileSystemControlParcel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,6 +27,8 @@ import android.os.incremental.IncrementalFileSystemControlParcel;
|
|||||||
parcelable FileSystemControlParcel {
|
parcelable FileSystemControlParcel {
|
||||||
// Incremental FS control descriptors.
|
// Incremental FS control descriptors.
|
||||||
@nullable IncrementalFileSystemControlParcel incremental;
|
@nullable IncrementalFileSystemControlParcel incremental;
|
||||||
|
// Incremental FS service.
|
||||||
|
@nullable IIncrementalServiceConnector service;
|
||||||
// Callback-based installation connector.
|
// Callback-based installation connector.
|
||||||
@nullable IPackageInstallerSessionFileSystemConnector callback;
|
@nullable IPackageInstallerSessionFileSystemConnector callback;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,13 +37,6 @@ interface IIncrementalService {
|
|||||||
int createStorage(in @utf8InCpp String path, in DataLoaderParamsParcel params, in IDataLoaderStatusListener listener, int createMode);
|
int createStorage(in @utf8InCpp String path, in DataLoaderParamsParcel params, in IDataLoaderStatusListener listener, int createMode);
|
||||||
int createLinkedStorage(in @utf8InCpp String path, int otherStorageId, 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.
|
* Bind-mounts a path under a storage to a full path. Can be permanent or temporary.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
@@ -19,13 +19,11 @@ package android.os.incremental;
|
|||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.RequiresPermission;
|
|
||||||
import android.annotation.SystemService;
|
import android.annotation.SystemService;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.DataLoaderParams;
|
import android.content.pm.DataLoaderParams;
|
||||||
import android.content.pm.IDataLoaderStatusListener;
|
import android.content.pm.IDataLoaderStatusListener;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.system.ErrnoException;
|
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
|
|
||||||
import com.android.internal.annotations.GuardedBy;
|
import com.android.internal.annotations.GuardedBy;
|
||||||
@@ -321,23 +319,6 @@ public final class IncrementalManager {
|
|||||||
return nativeUnsafeGetFileSignature(path);
|
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 */
|
/* Native methods */
|
||||||
private static native boolean nativeIsEnabled();
|
private static native boolean nativeIsEnabled();
|
||||||
private static native boolean nativeIsIncrementalPath(@NonNull String path);
|
private static native boolean nativeIsIncrementalPath(@NonNull String path);
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import android.annotation.Nullable;
|
|||||||
import android.annotation.RequiresPermission;
|
import android.annotation.RequiresPermission;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.DataLoaderParams;
|
import android.content.pm.DataLoaderParams;
|
||||||
import android.content.pm.DataLoaderParamsParcel;
|
import android.content.pm.DataLoaderParamsParcel;
|
||||||
@@ -32,8 +31,6 @@ import android.content.pm.InstallationFile;
|
|||||||
import android.content.pm.InstallationFileParcel;
|
import android.content.pm.InstallationFileParcel;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.os.incremental.IncrementalManager;
|
|
||||||
import android.system.ErrnoException;
|
|
||||||
import android.util.ExceptionUtils;
|
import android.util.ExceptionUtils;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
|
|
||||||
@@ -211,25 +208,6 @@ public abstract class DataLoaderService extends Service {
|
|||||||
private final long mNativeInstance;
|
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 */
|
/* Native methods */
|
||||||
private native boolean nativeCreateDataLoader(int storageId,
|
private native boolean nativeCreateDataLoader(int storageId,
|
||||||
@NonNull FileSystemControlParcel control,
|
@NonNull FileSystemControlParcel control,
|
||||||
|
|||||||
@@ -155,11 +155,6 @@ binder::Status BinderIncrementalService::deleteStorage(int32_t storageId) {
|
|||||||
return ok();
|
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,
|
binder::Status BinderIncrementalService::makeDirectory(int32_t storageId, const std::string& path,
|
||||||
int32_t* _aidl_return) {
|
int32_t* _aidl_return) {
|
||||||
*_aidl_return = mImpl.makeDir(storageId, path);
|
*_aidl_return = mImpl.makeDir(storageId, path);
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ public:
|
|||||||
binder::Status configureNativeBinaries(int32_t storageId, const std::string& apkFullPath,
|
binder::Status configureNativeBinaries(int32_t storageId, const std::string& apkFullPath,
|
||||||
const std::string& libDirRelativePath,
|
const std::string& libDirRelativePath,
|
||||||
const std::string& abi, bool* _aidl_return) final;
|
const std::string& abi, bool* _aidl_return) final;
|
||||||
binder::Status setStorageParams(int32_t storage, bool enableReadLogs, int32_t* _aidl_return) final;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
android::incremental::IncrementalService mImpl;
|
android::incremental::IncrementalService mImpl;
|
||||||
|
|||||||
@@ -1153,6 +1153,7 @@ bool IncrementalService::prepareDataLoader(IncrementalService::IncFsMount& ifs,
|
|||||||
fsControlParcel.incremental->pendingReads.reset(
|
fsControlParcel.incremental->pendingReads.reset(
|
||||||
base::unique_fd(::dup(ifs.control.pendingReads())));
|
base::unique_fd(::dup(ifs.control.pendingReads())));
|
||||||
fsControlParcel.incremental->log.reset(base::unique_fd(::dup(ifs.control.logs())));
|
fsControlParcel.incremental->log.reset(base::unique_fd(::dup(ifs.control.logs())));
|
||||||
|
fsControlParcel.service = new IncrementalServiceConnector(*this, ifs.mountId);
|
||||||
sp<IncrementalDataLoaderListener> listener =
|
sp<IncrementalDataLoaderListener> listener =
|
||||||
new IncrementalDataLoaderListener(*this,
|
new IncrementalDataLoaderListener(*this,
|
||||||
externalListener ? *externalListener
|
externalListener ? *externalListener
|
||||||
@@ -1451,4 +1452,10 @@ void IncrementalService::AppOpsListener::opChanged(int32_t, const String16&) {
|
|||||||
incrementalService.onAppOpChanged(packageName);
|
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
|
} // namespace android::incremental
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
#include "ServiceWrappers.h"
|
#include "ServiceWrappers.h"
|
||||||
#include "android/content/pm/BnDataLoaderStatusListener.h"
|
#include "android/content/pm/BnDataLoaderStatusListener.h"
|
||||||
|
#include "android/os/incremental/BnIncrementalServiceConnector.h"
|
||||||
#include "incfs.h"
|
#include "incfs.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
|
||||||
@@ -139,7 +140,7 @@ public:
|
|||||||
DataLoaderStatusListener externalListener)
|
DataLoaderStatusListener externalListener)
|
||||||
: incrementalService(incrementalService), externalListener(externalListener) {}
|
: incrementalService(incrementalService), externalListener(externalListener) {}
|
||||||
// Callbacks interface
|
// Callbacks interface
|
||||||
binder::Status onStatusChanged(MountId mount, int newStatus) override;
|
binder::Status onStatusChanged(MountId mount, int newStatus) final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IncrementalService& incrementalService;
|
IncrementalService& incrementalService;
|
||||||
@@ -149,13 +150,24 @@ public:
|
|||||||
class AppOpsListener : public android::BnAppOpsCallback {
|
class AppOpsListener : public android::BnAppOpsCallback {
|
||||||
public:
|
public:
|
||||||
AppOpsListener(IncrementalService& incrementalService, std::string packageName) : incrementalService(incrementalService), packageName(std::move(packageName)) {}
|
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:
|
private:
|
||||||
IncrementalService& incrementalService;
|
IncrementalService& incrementalService;
|
||||||
const std::string packageName;
|
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:
|
private:
|
||||||
static const bool sEnablePerfLogging;
|
static const bool sEnablePerfLogging;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user