1/*
2 * Copyright (C) 2013 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
17package android.media;
18
19import android.media.MediaDrmException;
20import java.lang.ref.WeakReference;
21import java.util.UUID;
22import java.util.HashMap;
23import java.util.List;
24import android.os.Handler;
25import android.os.Looper;
26import android.os.Message;
27import android.os.Bundle;
28import android.os.Parcel;
29import android.util.Log;
30
31/**
32 * MediaDrm can be used to obtain keys for decrypting protected media streams, in
33 * conjunction with {@link android.media.MediaCrypto}.  The MediaDrm APIs
34 * are designed to support the ISO/IEC 23001-7: Common Encryption standard, but
35 * may also be used to implement other encryption schemes.
36 * <p>
37 * Encrypted content is prepared using an encryption server and stored in a content
38 * library. The encrypted content is streamed or downloaded from the content library to
39 * client devices via content servers.  Licenses to view the content are obtained from
40 * a License Server.
41 * <p>
42 * <p><img src="../../../images/mediadrm_overview.png"
43 *      alt="MediaDrm Overview diagram"
44 *      border="0" /></p>
45 * <p>
46 * Keys are requested from the license server using a key request. The key
47 * response is delivered to the client app, which provides the response to the
48 * MediaDrm API.
49 * <p>
50 * A Provisioning server may be required to distribute device-unique credentials to
51 * the devices.
52 * <p>
53 * Enforcing requirements related to the number of devices that may play content
54 * simultaneously can be performed either through key renewal or using the secure
55 * stop methods.
56 * <p>
57 * The following sequence diagram shows the interactions between the objects
58 * involved while playing back encrypted content:
59 * <p>
60 * <p><img src="../../../images/mediadrm_decryption_sequence.png"
61 *         alt="MediaDrm Overview diagram"
62 *         border="0" /></p>
63 * <p>
64 * The app first constructs {@link android.media.MediaExtractor} and
65 * {@link android.media.MediaCodec} objects. It accesses the DRM-scheme-identifying UUID,
66 * typically from metadata in the content, and uses this UUID to construct an instance
67 * of a MediaDrm object that is able to support the DRM scheme required by the content.
68 * Crypto schemes are assigned 16 byte UUIDs.  The method {@link #isCryptoSchemeSupported}
69 * can be used to query if a given scheme is supported on the device.
70 * <p>
71 * The app calls {@link #openSession} to generate a sessionId that will uniquely identify
72 * the session in subsequent interactions. The app next uses the MediaDrm object to
73 * obtain a key request message and send it to the license server, then provide
74 * the server's response to the MediaDrm object.
75 * <p>
76 * Once the app has a sessionId, it can construct a MediaCrypto object from the UUID and
77 * sessionId.  The MediaCrypto object is registered with the MediaCodec in the
78 * {@link MediaCodec.#configure} method to enable the codec to decrypt content.
79 * <p>
80 * When the app has constructed {@link android.media.MediaExtractor},
81 * {@link android.media.MediaCodec} and {@link android.media.MediaCrypto} objects,
82 * it proceeds to pull samples from the extractor and queue them into the decoder.  For
83 * encrypted content, the samples returned from the extractor remain encrypted, they
84 * are only decrypted when the samples are delivered to the decoder.
85 * <p>
86 * <a name="Callbacks"></a>
87 * <h3>Callbacks</h3>
88 * <p>Applications should register for informational events in order
89 * to be informed of key state updates during playback or streaming.
90 * Registration for these events is done via a call to
91 * {@link #setOnEventListener}. In order to receive the respective
92 * callback associated with this listener, applications are required to create
93 * MediaDrm objects on a thread with its own Looper running (main UI
94 * thread by default has a Looper running).
95 */
96public final class MediaDrm {
97
98    private final static String TAG = "MediaDrm";
99
100    private EventHandler mEventHandler;
101    private OnEventListener mOnEventListener;
102
103    private int mNativeContext;
104
105    /**
106     * Query if the given scheme identified by its UUID is supported on
107     * this device.
108     * @param uuid The UUID of the crypto scheme.
109     */
110    public static final boolean isCryptoSchemeSupported(UUID uuid) {
111        return isCryptoSchemeSupportedNative(getByteArrayFromUUID(uuid));
112    }
113
114    private static final byte[] getByteArrayFromUUID(UUID uuid) {
115        long msb = uuid.getMostSignificantBits();
116        long lsb = uuid.getLeastSignificantBits();
117
118        byte[] uuidBytes = new byte[16];
119        for (int i = 0; i < 8; ++i) {
120            uuidBytes[i] = (byte)(msb >>> (8 * (7 - i)));
121            uuidBytes[8 + i] = (byte)(lsb >>> (8 * (7 - i)));
122        }
123
124        return uuidBytes;
125    }
126
127    private static final native boolean isCryptoSchemeSupportedNative(byte[] uuid);
128
129    /**
130     * Instantiate a MediaDrm object
131     *
132     * @param uuid The UUID of the crypto scheme.
133     *
134     * @throws UnsupportedSchemeException if the device does not support the
135     * specified scheme UUID
136     */
137    public MediaDrm(UUID uuid) throws UnsupportedSchemeException {
138        Looper looper;
139        if ((looper = Looper.myLooper()) != null) {
140            mEventHandler = new EventHandler(this, looper);
141        } else if ((looper = Looper.getMainLooper()) != null) {
142            mEventHandler = new EventHandler(this, looper);
143        } else {
144            mEventHandler = null;
145        }
146
147        /* Native setup requires a weak reference to our object.
148         * It's easier to create it here than in C++.
149         */
150        native_setup(new WeakReference<MediaDrm>(this),
151                     getByteArrayFromUUID(uuid));
152    }
153
154    /**
155     * Register a callback to be invoked when an event occurs
156     *
157     * @param listener the callback that will be run
158     */
159    public void setOnEventListener(OnEventListener listener)
160    {
161        mOnEventListener = listener;
162    }
163
164    /**
165     * Interface definition for a callback to be invoked when a drm event
166     * occurs
167     */
168    public interface OnEventListener
169    {
170        /**
171         * Called when an event occurs that requires the app to be notified
172         *
173         * @param md the MediaDrm object on which the event occurred
174         * @param sessionId the DRM session ID on which the event occurred
175         * @param event indicates the event type
176         * @param extra an secondary error code
177         * @param data optional byte array of data that may be associated with the event
178         */
179        void onEvent(MediaDrm md, byte[] sessionId, int event, int extra, byte[] data);
180    }
181
182    /**
183     * This event type indicates that the app needs to request a certificate from
184     * the provisioning server.  The request message data is obtained using
185     * {@link #getProvisionRequest}
186     */
187    public static final int EVENT_PROVISION_REQUIRED = 1;
188
189    /**
190     * This event type indicates that the app needs to request keys from a license
191     * server.  The request message data is obtained using {@link #getKeyRequest}.
192     */
193    public static final int EVENT_KEY_REQUIRED = 2;
194
195    /**
196     * This event type indicates that the licensed usage duration for keys in a session
197     * has expired.  The keys are no longer valid.
198     */
199    public static final int EVENT_KEY_EXPIRED = 3;
200
201    /**
202     * This event may indicate some specific vendor-defined condition, see your
203     * DRM provider documentation for details
204     */
205    public static final int EVENT_VENDOR_DEFINED = 4;
206
207    private static final int DRM_EVENT = 200;
208
209    private class EventHandler extends Handler
210    {
211        private MediaDrm mMediaDrm;
212
213        public EventHandler(MediaDrm md, Looper looper) {
214            super(looper);
215            mMediaDrm = md;
216        }
217
218        @Override
219        public void handleMessage(Message msg) {
220            if (mMediaDrm.mNativeContext == 0) {
221                Log.w(TAG, "MediaDrm went away with unhandled events");
222                return;
223            }
224            switch(msg.what) {
225
226            case DRM_EVENT:
227                Log.i(TAG, "Drm event (" + msg.arg1 + "," + msg.arg2 + ")");
228
229                if (mOnEventListener != null) {
230                    if (msg.obj != null && msg.obj instanceof Parcel) {
231                        Parcel parcel = (Parcel)msg.obj;
232                        byte[] sessionId = parcel.createByteArray();
233                        if (sessionId.length == 0) {
234                            sessionId = null;
235                        }
236                        byte[] data = parcel.createByteArray();
237                        if (data.length == 0) {
238                            data = null;
239                        }
240                        mOnEventListener.onEvent(mMediaDrm, sessionId, msg.arg1, msg.arg2, data);
241                    }
242                }
243                return;
244
245            default:
246                Log.e(TAG, "Unknown message type " + msg.what);
247                return;
248            }
249        }
250    }
251
252    /*
253     * This method is called from native code when an event occurs.  This method
254     * just uses the EventHandler system to post the event back to the main app thread.
255     * We use a weak reference to the original MediaPlayer object so that the native
256     * code is safe from the object disappearing from underneath it.  (This is
257     * the cookie passed to native_setup().)
258     */
259    private static void postEventFromNative(Object mediadrm_ref,
260                                            int eventType, int extra, Object obj)
261    {
262        MediaDrm md = (MediaDrm)((WeakReference)mediadrm_ref).get();
263        if (md == null) {
264            return;
265        }
266        if (md.mEventHandler != null) {
267            Message m = md.mEventHandler.obtainMessage(DRM_EVENT, eventType, extra, obj);
268            md.mEventHandler.sendMessage(m);
269        }
270    }
271
272    /**
273     * Open a new session with the MediaDrm object.  A session ID is returned.
274     *
275     * @throws NotProvisionedException if provisioning is needed
276     */
277    public native byte[] openSession() throws NotProvisionedException;
278
279    /**
280     * Close a session on the MediaDrm object that was previously opened
281     * with {@link #openSession}.
282     */
283    public native void closeSession(byte[] sessionId);
284
285    /**
286     * This key request type species that the keys will be for online use, they will
287     * not be saved to the device for subsequent use when the device is not connected
288     * to a network.
289     */
290    public static final int KEY_TYPE_STREAMING = 1;
291
292    /**
293     * This key request type specifies that the keys will be for offline use, they
294     * will be saved to the device for use when the device is not connected to a network.
295     */
296    public static final int KEY_TYPE_OFFLINE = 2;
297
298    /**
299     * This key request type specifies that previously saved offline keys should be released.
300     */
301    public static final int KEY_TYPE_RELEASE = 3;
302
303    /**
304     * Contains the opaque data an app uses to request keys from a license server
305     */
306    public final static class KeyRequest {
307        KeyRequest() {}
308
309        /**
310         * Get the opaque message data
311         */
312        public byte[] getData() { return mData; }
313
314        /**
315         * Get the default URL to use when sending the key request message to a
316         * server, if known.  The app may prefer to use a different license
317         * server URL from other sources.
318         */
319        public String getDefaultUrl() { return mDefaultUrl; }
320
321        private byte[] mData;
322        private String mDefaultUrl;
323    };
324
325    /**
326     * A key request/response exchange occurs between the app and a license server
327     * to obtain or release keys used to decrypt encrypted content.
328     * <p>
329     * getKeyRequest() is used to obtain an opaque key request byte array that is
330     * delivered to the license server.  The opaque key request byte array is returned
331     * in KeyRequest.data.  The recommended URL to deliver the key request to is
332     * returned in KeyRequest.defaultUrl.
333     * <p>
334     * After the app has received the key request response from the server,
335     * it should deliver to the response to the DRM engine plugin using the method
336     * {@link #provideKeyResponse}.
337     *
338     * @param scope may be a sessionId or a keySetId, depending on the specified keyType.
339     * When the keyType is KEY_TYPE_STREAMING or KEY_TYPE_OFFLINE,
340     * scope should be set to the sessionId the keys will be provided to.  When the keyType
341     * is KEY_TYPE_RELEASE, scope should be set to the keySetId of the keys
342     * being released. Releasing keys from a device invalidates them for all sessions.
343     * @param init container-specific data, its meaning is interpreted based on the
344     * mime type provided in the mimeType parameter.  It could contain, for example,
345     * the content ID, key ID or other data obtained from the content metadata that is
346     * required in generating the key request. init may be null when keyType is
347     * KEY_TYPE_RELEASE.
348     * @param mimeType identifies the mime type of the content
349     * @param keyType specifes the type of the request. The request may be to acquire
350     * keys for streaming or offline content, or to release previously acquired
351     * keys, which are identified by a keySetId.
352     * @param optionalParameters are included in the key request message to
353     * allow a client application to provide additional message parameters to the server.
354     *
355     * @throws NotProvisionedException if reprovisioning is needed, due to a
356     * problem with the certifcate
357     */
358    public native KeyRequest getKeyRequest(byte[] scope, byte[] init,
359                                           String mimeType, int keyType,
360                                           HashMap<String, String> optionalParameters)
361        throws NotProvisionedException;
362
363
364    /**
365     * A key response is received from the license server by the app, then it is
366     * provided to the DRM engine plugin using provideKeyResponse.  When the
367     * response is for an offline key request, a keySetId is returned that can be
368     * used to later restore the keys to a new session with the method
369     * {@link #restoreKeys}.
370     * When the response is for a streaming or release request, null is returned.
371     *
372     * @param scope may be a sessionId or keySetId depending on the type of the
373     * response.  Scope should be set to the sessionId when the response is for either
374     * streaming or offline key requests.  Scope should be set to the keySetId when
375     * the response is for a release request.
376     * @param response the byte array response from the server
377     *
378     * @throws NotProvisionedException if the response indicates that
379     * reprovisioning is required
380     * @throws DeniedByServerException if the response indicates that the
381     * server rejected the request
382     */
383    public native byte[] provideKeyResponse(byte[] scope, byte[] response)
384        throws NotProvisionedException, DeniedByServerException;
385
386
387    /**
388     * Restore persisted offline keys into a new session.  keySetId identifies the
389     * keys to load, obtained from a prior call to {@link #provideKeyResponse}.
390     *
391     * @param sessionId the session ID for the DRM session
392     * @param keySetId identifies the saved key set to restore
393     */
394    public native void restoreKeys(byte[] sessionId, byte[] keySetId);
395
396    /**
397     * Remove the current keys from a session.
398     *
399     * @param sessionId the session ID for the DRM session
400     */
401    public native void removeKeys(byte[] sessionId);
402
403    /**
404     * Request an informative description of the key status for the session.  The status is
405     * in the form of {name, value} pairs.  Since DRM license policies vary by vendor,
406     * the specific status field names are determined by each DRM vendor.  Refer to your
407     * DRM provider documentation for definitions of the field names for a particular
408     * DRM engine plugin.
409     *
410     * @param sessionId the session ID for the DRM session
411     */
412    public native HashMap<String, String> queryKeyStatus(byte[] sessionId);
413
414    /**
415     * Contains the opaque data an app uses to request a certificate from a provisioning
416     * server
417     */
418    public final static class ProvisionRequest {
419        ProvisionRequest() {}
420
421        /**
422         * Get the opaque message data
423         */
424        public byte[] getData() { return mData; }
425
426        /**
427         * Get the default URL to use when sending the provision request
428         * message to a server, if known. The app may prefer to use a different
429         * provisioning server URL obtained from other sources.
430         */
431        public String getDefaultUrl() { return mDefaultUrl; }
432
433        private byte[] mData;
434        private String mDefaultUrl;
435    }
436
437    /**
438     * A provision request/response exchange occurs between the app and a provisioning
439     * server to retrieve a device certificate.  If provisionining is required, the
440     * EVENT_PROVISION_REQUIRED event will be sent to the event handler.
441     * getProvisionRequest is used to obtain the opaque provision request byte array that
442     * should be delivered to the provisioning server. The provision request byte array
443     * is returned in ProvisionRequest.data. The recommended URL to deliver the provision
444     * request to is returned in ProvisionRequest.defaultUrl.
445     */
446    public native ProvisionRequest getProvisionRequest();
447
448    /**
449     * After a provision response is received by the app, it is provided to the DRM
450     * engine plugin using this method.
451     *
452     * @param response the opaque provisioning response byte array to provide to the
453     * DRM engine plugin.
454     *
455     * @throws DeniedByServerException if the response indicates that the
456     * server rejected the request
457     */
458    public native void provideProvisionResponse(byte[] response)
459        throws DeniedByServerException;
460
461    /**
462     * A means of enforcing limits on the number of concurrent streams per subscriber
463     * across devices is provided via SecureStop. This is achieved by securely
464     * monitoring the lifetime of sessions.
465     * <p>
466     * Information from the server related to the current playback session is written
467     * to persistent storage on the device when each MediaCrypto object is created.
468     * <p>
469     * In the normal case, playback will be completed, the session destroyed and the
470     * Secure Stops will be queried. The app queries secure stops and forwards the
471     * secure stop message to the server which verifies the signature and notifies the
472     * server side database that the session destruction has been confirmed. The persisted
473     * record on the client is only removed after positive confirmation that the server
474     * received the message using releaseSecureStops().
475     */
476    public native List<byte[]> getSecureStops();
477
478
479    /**
480     * Process the SecureStop server response message ssRelease.  After authenticating
481     * the message, remove the SecureStops identified in the response.
482     *
483     * @param ssRelease the server response indicating which secure stops to release
484     */
485    public native void releaseSecureStops(byte[] ssRelease);
486
487
488    /**
489     * String property name: identifies the maker of the DRM engine plugin
490     */
491    public static final String PROPERTY_VENDOR = "vendor";
492
493    /**
494     * String property name: identifies the version of the DRM engine plugin
495     */
496    public static final String PROPERTY_VERSION = "version";
497
498    /**
499     * String property name: describes the DRM engine plugin
500     */
501    public static final String PROPERTY_DESCRIPTION = "description";
502
503    /**
504     * String property name: a comma-separated list of cipher and mac algorithms
505     * supported by CryptoSession.  The list may be empty if the DRM engine
506     * plugin does not support CryptoSession operations.
507     */
508    public static final String PROPERTY_ALGORITHMS = "algorithms";
509
510    /**
511     * Read a DRM engine plugin String property value, given the property name string.
512     * <p>
513     * Standard fields names are:
514     * {@link #PROPERTY_VENDOR}, {@link #PROPERTY_VERSION},
515     * {@link #PROPERTY_DESCRIPTION}, {@link #PROPERTY_ALGORITHMS}
516     */
517    public native String getPropertyString(String propertyName);
518
519
520    /**
521     * Byte array property name: the device unique identifier is established during
522     * device provisioning and provides a means of uniquely identifying each device.
523     */
524    public static final String PROPERTY_DEVICE_UNIQUE_ID = "deviceUniqueId";
525
526    /**
527     * Read a DRM engine plugin byte array property value, given the property name string.
528     * <p>
529     * Standard fields names are {@link #PROPERTY_DEVICE_UNIQUE_ID}
530     */
531    public native byte[] getPropertyByteArray(String propertyName);
532
533
534    /**
535     * Set a DRM engine plugin String property value.
536     */
537    public native void setPropertyString(String propertyName, String value);
538
539    /**
540     * Set a DRM engine plugin byte array property value.
541     */
542    public native void setPropertyByteArray(String propertyName, byte[] value);
543
544
545    private static final native void setCipherAlgorithmNative(MediaDrm drm, byte[] sessionId,
546                                                              String algorithm);
547
548    private static final native void setMacAlgorithmNative(MediaDrm drm, byte[] sessionId,
549                                                           String algorithm);
550
551    private static final native byte[] encryptNative(MediaDrm drm, byte[] sessionId,
552                                                     byte[] keyId, byte[] input, byte[] iv);
553
554    private static final native byte[] decryptNative(MediaDrm drm, byte[] sessionId,
555                                                     byte[] keyId, byte[] input, byte[] iv);
556
557    private static final native byte[] signNative(MediaDrm drm, byte[] sessionId,
558                                                  byte[] keyId, byte[] message);
559
560    private static final native boolean verifyNative(MediaDrm drm, byte[] sessionId,
561                                                     byte[] keyId, byte[] message,
562                                                     byte[] signature);
563
564    /**
565     * In addition to supporting decryption of DASH Common Encrypted Media, the
566     * MediaDrm APIs provide the ability to securely deliver session keys from
567     * an operator's session key server to a client device, based on the factory-installed
568     * root of trust, and then perform encrypt, decrypt, sign and verify operations
569     * with the session key on arbitrary user data.
570     * <p>
571     * The CryptoSession class implements generic encrypt/decrypt/sign/verify methods
572     * based on the established session keys.  These keys are exchanged using the
573     * getKeyRequest/provideKeyResponse methods.
574     * <p>
575     * Applications of this capability could include securing various types of
576     * purchased or private content, such as applications, books and other media,
577     * photos or media delivery protocols.
578     * <p>
579     * Operators can create session key servers that are functionally similar to a
580     * license key server, except that instead of receiving license key requests and
581     * providing encrypted content keys which are used specifically to decrypt A/V media
582     * content, the session key server receives session key requests and provides
583     * encrypted session keys which can be used for general purpose crypto operations.
584     * <p>
585     * A CryptoSession is obtained using {@link #getCryptoSession}
586     */
587    public final class CryptoSession {
588        private MediaDrm mDrm;
589        private byte[] mSessionId;
590
591        CryptoSession(MediaDrm drm, byte[] sessionId,
592                      String cipherAlgorithm, String macAlgorithm)
593        {
594            mSessionId = sessionId;
595            mDrm = drm;
596            setCipherAlgorithmNative(drm, sessionId, cipherAlgorithm);
597            setMacAlgorithmNative(drm, sessionId, macAlgorithm);
598        }
599
600        /**
601         * Encrypt data using the CryptoSession's cipher algorithm
602         *
603         * @param keyid specifies which key to use
604         * @param input the data to encrypt
605         * @param iv the initialization vector to use for the cipher
606         */
607        public byte[] encrypt(byte[] keyid, byte[] input, byte[] iv) {
608            return encryptNative(mDrm, mSessionId, keyid, input, iv);
609        }
610
611        /**
612         * Decrypt data using the CryptoSessions's cipher algorithm
613         *
614         * @param keyid specifies which key to use
615         * @param input the data to encrypt
616         * @param iv the initialization vector to use for the cipher
617         */
618        public byte[] decrypt(byte[] keyid, byte[] input, byte[] iv) {
619            return decryptNative(mDrm, mSessionId, keyid, input, iv);
620        }
621
622        /**
623         * Sign data using the CryptoSessions's mac algorithm.
624         *
625         * @param keyid specifies which key to use
626         * @param message the data for which a signature is to be computed
627         */
628        public byte[] sign(byte[] keyid, byte[] message) {
629            return signNative(mDrm, mSessionId, keyid, message);
630        }
631
632        /**
633         * Verify a signature using the CryptoSessions's mac algorithm. Return true
634         * if the signatures match, false if they do no.
635         *
636         * @param keyid specifies which key to use
637         * @param message the data to verify
638         * @param signature the reference signature which will be compared with the
639         *        computed signature
640         */
641        public boolean verify(byte[] keyid, byte[] message, byte[] signature) {
642            return verifyNative(mDrm, mSessionId, keyid, message, signature);
643        }
644    };
645
646    /**
647     * Obtain a CryptoSession object which can be used to encrypt, decrypt,
648     * sign and verify messages or data using the session keys established
649     * for the session using methods {@link #getKeyRequest} and
650     * {@link #provideKeyResponse} using a session key server.
651     *
652     * @param sessionId the session ID for the session containing keys
653     * to be used for encrypt, decrypt, sign and/or verify
654     * @param cipherAlgorithm the algorithm to use for encryption and
655     * decryption ciphers. The algorithm string conforms to JCA Standard
656     * Names for Cipher Transforms and is case insensitive.  For example
657     * "AES/CBC/NoPadding".
658     * @param macAlgorithm the algorithm to use for sign and verify
659     * The algorithm string conforms to JCA Standard Names for Mac
660     * Algorithms and is case insensitive.  For example "HmacSHA256".
661     * <p>
662     * The list of supported algorithms for a DRM engine plugin can be obtained
663     * using the method {@link #getPropertyString} with the property name
664     * "algorithms".
665     */
666    public CryptoSession getCryptoSession(byte[] sessionId,
667                                          String cipherAlgorithm,
668                                          String macAlgorithm)
669    {
670        return new CryptoSession(this, sessionId, cipherAlgorithm, macAlgorithm);
671    }
672
673    @Override
674    protected void finalize() {
675        native_finalize();
676    }
677
678    public native final void release();
679    private static native final void native_init();
680
681    private native final void native_setup(Object mediadrm_this, byte[] uuid);
682
683    private native final void native_finalize();
684
685    static {
686        System.loadLibrary("media_jni");
687        native_init();
688    }
689}
690