1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #pragma once 17 18 #include <dataloader.h> 19 20 __BEGIN_DECLS 21 22 // This simulates legacy dataloader (compiled with previous version of libincfs_dataloader). 23 // We still need to be able to support them. 24 struct LegacyDataLoader { 25 bool (*onStart)(struct LegacyDataLoader* self); 26 void (*onStop)(struct LegacyDataLoader* self); 27 void (*onDestroy)(struct LegacyDataLoader* self); 28 29 bool (*onPrepareImage)(struct LegacyDataLoader* self, 30 const DataLoaderInstallationFile addedFiles[], int addedFilesCount); 31 32 void (*onPendingReads)(struct LegacyDataLoader* self, const IncFsReadInfo pendingReads[], 33 int pendingReadsCount); 34 void (*onPageReads)(struct LegacyDataLoader* self, const IncFsReadInfo pageReads[], 35 int pageReadsCount); 36 }; 37 38 __END_DECLS 39 40 namespace android::dataloader { 41 42 // Default DataLoader redirects everything back to Java. 43 struct ManagedDataLoader : private LegacyDataLoader { 44 static LegacyDataLoader* create(JavaVM* jvm, android::dataloader::FilesystemConnectorPtr ifs, 45 android::dataloader::StatusListenerPtr listener, 46 android::dataloader::ServiceConnectorPtr service, 47 android::dataloader::ServiceParamsPtr params); 48 49 private: 50 ManagedDataLoader(JavaVM* jvm, jobject dataLoader); 51 52 // Lifecycle. 53 void onDestroy(); 54 55 // Installation. 56 bool onPrepareImage(DataLoaderInstallationFiles addedFiles); 57 58 JavaVM* const mJvm; 59 jobject mDataLoader = nullptr; 60 }; 61 62 struct ManagedDataLoaderFactory : public ::DataLoaderFactory { 63 ManagedDataLoaderFactory(); 64 }; 65 66 } // namespace android::dataloader 67