[WVDRM] Support new Java API crypto HAL
Implements WV crypto plugin core lib build Change-Id: I4f3fb06a4a9cf7c9c663d3dcee9cfd2c2900ebc2 related-to-bug: 5986621
This commit is contained in:
committed by
Jeff Tinker
parent
aaa8479c34
commit
6473768dcb
89
proprietary/cryptoPlugin/WVCryptoPlugin.h
Normal file
89
proprietary/cryptoPlugin/WVCryptoPlugin.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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.
|
||||
*/
|
||||
|
||||
#ifndef WV_CRYPTO_PLUGIN_H_
|
||||
|
||||
#define WV_CRYPTO_PLUGIN_H_
|
||||
|
||||
#include <media/hardware/CryptoAPI.h>
|
||||
#include <utils/threads.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
struct WVCryptoPlugin : public CryptoPlugin {
|
||||
WVCryptoPlugin(const void *data, size_t size);
|
||||
virtual ~WVCryptoPlugin();
|
||||
|
||||
status_t initCheck() const;
|
||||
|
||||
virtual bool requiresSecureDecoderComponent(const char *mime) const;
|
||||
|
||||
virtual status_t decrypt(
|
||||
bool secure,
|
||||
const uint8_t key[16],
|
||||
const uint8_t iv[16],
|
||||
Mode mode,
|
||||
const void *srcPtr,
|
||||
const SubSample *subSamples, size_t numSubSamples,
|
||||
void *dstPtr,
|
||||
AString *errorDetailMsg);
|
||||
|
||||
private:
|
||||
Mutex mLock;
|
||||
|
||||
status_t mInitCheck;
|
||||
|
||||
WVCryptoPlugin(const WVCryptoPlugin &);
|
||||
WVCryptoPlugin &operator=(const WVCryptoPlugin &);
|
||||
};
|
||||
|
||||
struct WVCryptoFactory : public CryptoFactory {
|
||||
static const uint8_t kUUIDWidevine[16];
|
||||
|
||||
virtual bool isCryptoSchemeSupported(
|
||||
const uint8_t uuid[16]) const {
|
||||
return !memcmp(uuid, kUUIDWidevine, 16);
|
||||
}
|
||||
|
||||
virtual status_t createPlugin(
|
||||
const uint8_t uuid[16], const void *data, size_t size,
|
||||
CryptoPlugin **out) {
|
||||
*out = NULL;
|
||||
|
||||
if (memcmp(uuid, kUUIDWidevine, 16)) {
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
WVCryptoPlugin *plugin = new WVCryptoPlugin(data, size);
|
||||
|
||||
status_t err;
|
||||
if ((err = plugin->initCheck()) != OK) {
|
||||
delete plugin;
|
||||
plugin = NULL;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
*out = plugin;
|
||||
|
||||
return OK;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
|
||||
#endif // WV_CRYPTO_PLUGIN_H_
|
||||
|
||||
Reference in New Issue
Block a user