blob: b8af3eadfd93fd6357571ab34a159e225085aadd [file] [log] [blame]
Paul McLean84b491302018-05-09 10:03:57 -06001/*
2 * Copyright (C) 2018 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
17#define LOG_TAG "NativeMIDI_JNI"
18
19#include <core_jni_helpers.h>
20
21namespace android { namespace midi {
22// MidiDevice Fields
23static jobject gMidiDeviceClassGlobalRef = nullptr; // A GlobalRef for MidiDevice Class
24jfieldID gFidMidiNativeHandle = nullptr; // MidiDevice.mNativeHandle
25jfieldID gFidMidiDeviceServerBinder = nullptr; // MidiDevice.mDeviceServerBinder
26jfieldID gFidMidiDeviceInfo = nullptr; // MidiDevice.mDeviceInfo
27
28// MidiDeviceInfo Fields
29static jobject gMidiDeviceInfoClassGlobalRef = nullptr; // A GlobalRef for MidiDeviceInfoClass
30jfieldID mFidMidiDeviceId = nullptr; // MidiDeviceInfo.mId
31}}
32
33using namespace android::midi;
34
35int register_android_media_midi(JNIEnv *env) {
36 jclass deviceClass = android::FindClassOrDie(env, "android/media/midi/MidiDevice");
37 gMidiDeviceClassGlobalRef = env->NewGlobalRef(deviceClass);
38
39 // MidiDevice Field IDs
40 gFidMidiNativeHandle = android::GetFieldIDOrDie(env, deviceClass, "mNativeHandle", "J");
41 gFidMidiDeviceServerBinder = android::GetFieldIDOrDie(env, deviceClass,
42 "mDeviceServerBinder", "Landroid/os/IBinder;");
43 gFidMidiDeviceInfo = android::GetFieldIDOrDie(env, deviceClass,
44 "mDeviceInfo", "Landroid/media/midi/MidiDeviceInfo;");
45
46 // MidiDeviceInfo Field IDs
47 jclass deviceInfoClass = android::FindClassOrDie(env, "android/media/midi/MidiDeviceInfo");
48 gMidiDeviceInfoClassGlobalRef = env->NewGlobalRef(deviceInfoClass);
49 mFidMidiDeviceId = android::GetFieldIDOrDie(env, deviceInfoClass, "mId", "I");
50
51 return 0;
52}