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

Commit 31852212 authored by Songchun Fan's avatar Songchun Fan Committed by Android (Google) Code Review
Browse files

Merge "[incremental] native implementation of Incremental Service"

parents 4ce772db 3c82a306
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -328,7 +328,9 @@ public final class IncrementalManager {
     * Checks if path is mounted on Incremental File System.
     */
    public static boolean isIncrementalPath(@NonNull String path) {
        // TODO(b/136132412): add jni implementation
        return false;
        return nativeIsIncrementalPath(path);
    }

    /* Native methods */
    private static native boolean nativeIsIncrementalPath(@NonNull String path);
}
+1 −0
Original line number Diff line number Diff line
@@ -141,6 +141,7 @@ cc_library_shared {
                "android_os_UEventObserver.cpp",
                "android_os_VintfObject.cpp",
                "android_os_VintfRuntimeInfo.cpp",
                "android_os_incremental_IncrementalManager.cpp",
                "android_net_LocalSocketImpl.cpp",
                "android_net_NetUtils.cpp",
                "android_service_DataLoaderService.cpp",
+2 −0
Original line number Diff line number Diff line
@@ -152,6 +152,7 @@ extern int register_android_os_HidlMemory(JNIEnv* env);
extern int register_android_os_MemoryFile(JNIEnv* env);
extern int register_android_os_SharedMemory(JNIEnv* env);
extern int register_android_service_DataLoaderService(JNIEnv* env);
extern int register_android_os_incremental_IncrementalManager(JNIEnv* env);
extern int register_android_net_LocalSocketImpl(JNIEnv* env);
extern int register_android_net_NetworkUtils(JNIEnv* env);
extern int register_android_text_AndroidCharacter(JNIEnv *env);
@@ -1496,6 +1497,7 @@ static const RegJNIRec gRegJNI[] = {
    REG_JNI(register_android_net_NetworkUtils),
    REG_JNI(register_android_os_MemoryFile),
    REG_JNI(register_android_os_SharedMemory),
    REG_JNI(register_android_os_incremental_IncrementalManager),
    REG_JNI(register_com_android_internal_os_ClassLoaderFactory),
    REG_JNI(register_com_android_internal_os_Zygote),
    REG_JNI(register_com_android_internal_os_ZygoteInit),
+46 −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.
 */

#define LOG_TAG "incremental_manager-jni"

#include "core_jni_helpers.h"
#include "incfs_ndk.h"
#include "jni.h"
#include "nativehelper/JNIHelp.h"

#include <iterator>
#include <memory>

namespace android {

static jboolean nativeIsIncrementalPath(JNIEnv* env,
                                    jobject clazz,
                                    jstring javaPath) {
    ScopedUtfChars path(env, javaPath);
    return (jboolean)IncFs_IsIncFsPath(path.c_str());
}

static const JNINativeMethod method_table[] = {
        {"nativeIsIncrementalPath", "(Ljava/lang/String;)Z",
         (void*)nativeIsIncrementalPath},
};

int register_android_os_incremental_IncrementalManager(JNIEnv* env) {
    return jniRegisterNativeMethods(env, "android/os/incremental/IncrementalManager",
                                    method_table, std::size(method_table));
}

} // namespace android
+7 −2
Original line number Diff line number Diff line
@@ -67,13 +67,14 @@ public class IncrementalManagerService extends IIncrementalManager.Stub {
        mDataLoaderManager = mContext.getSystemService(DataLoaderManager.class);
        ServiceManager.addService(BINDER_SERVICE_NAME, this);
        // Starts and register IIncrementalManagerNative service
        // TODO(b/136132412): add jni implementation
        mNativeInstance = nativeStartService();
    }

    /**
     * Notifies native IIncrementalManager service that system is ready.
     */
    public void systemReady() {
        // TODO(b/136132412): add jni implementation
        nativeSystemReady(mNativeInstance);
    }

    /**
@@ -152,4 +153,8 @@ public class IncrementalManagerService extends IIncrementalManager.Stub {
        (new IncrementalManagerShellCommand(mContext)).exec(
                this, in, out, err, args, callback, resultReceiver);
    }

    private static native long nativeStartService();

    private static native void nativeSystemReady(long nativeInstance);
}
Loading