Merge "Update of DRM framework."
This commit is contained in:
533
api/current.xml
533
api/current.xml
@@ -55630,6 +55630,161 @@
|
|||||||
>
|
>
|
||||||
</field>
|
</field>
|
||||||
</class>
|
</class>
|
||||||
|
<class name="DrmErrorEvent"
|
||||||
|
extends="android.drm.DrmEvent"
|
||||||
|
abstract="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<constructor name="DrmErrorEvent"
|
||||||
|
type="android.drm.DrmErrorEvent"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="uniqueId" type="int">
|
||||||
|
</parameter>
|
||||||
|
<parameter name="type" type="int">
|
||||||
|
</parameter>
|
||||||
|
<parameter name="message" type="java.lang.String">
|
||||||
|
</parameter>
|
||||||
|
</constructor>
|
||||||
|
<field name="TYPE_DRM_INFO_ACQUISITION_FAILED"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="2012"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="TYPE_FINALIZE_FAILED"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="2010"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="TYPE_INITIALIZE_FAILED"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="2009"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="TYPE_NOT_SUPPORTED"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="2003"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="TYPE_NO_INTERNET_CONNECTION"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="2005"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="TYPE_OUT_OF_MEMORY"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="2004"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="TYPE_REGISTRATION_FAILED"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="2006"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="TYPE_REMOVE_ALL_RIGHTS_FAILED"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="2011"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="TYPE_RIGHTS_ACQUISITION_FAILED"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="2008"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="TYPE_RIGHTS_NOT_INSTALLED"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="2001"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="TYPE_RIGHTS_RENEWAL_NOT_ALLOWED"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="2002"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="TYPE_UNREGISTRATION_FAILED"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="2007"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
</class>
|
||||||
<class name="DrmEvent"
|
<class name="DrmEvent"
|
||||||
extends="java.lang.Object"
|
extends="java.lang.Object"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
@@ -55685,6 +55840,105 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</method>
|
</method>
|
||||||
|
<field name="DRM_INFO_OBJECT"
|
||||||
|
type="java.lang.String"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value=""drm_info_object""
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="DRM_INFO_STATUS_OBJECT"
|
||||||
|
type="java.lang.String"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value=""drm_info_status_object""
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="TYPE_ALL_RIGHTS_REMOVED"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="1006"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="TYPE_DRM_INFO_ACQUIRED"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="1007"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="TYPE_FINALIZED"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="1001"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="TYPE_INITIALIZED"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="1003"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="TYPE_REGISTERED"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="1002"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="TYPE_RIGHTS_ACQUIRED"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="1005"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="TYPE_UNREGISTERED"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="1004"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
</class>
|
</class>
|
||||||
<class name="DrmInfo"
|
<class name="DrmInfo"
|
||||||
extends="java.lang.Object"
|
extends="java.lang.Object"
|
||||||
@@ -55828,6 +56082,17 @@
|
|||||||
<parameter name="message" type="java.lang.String">
|
<parameter name="message" type="java.lang.String">
|
||||||
</parameter>
|
</parameter>
|
||||||
</constructor>
|
</constructor>
|
||||||
|
<field name="TYPE_ACCOUNT_ALREADY_REGISTERED"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="5"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
<field name="TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT"
|
<field name="TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT"
|
||||||
type="int"
|
type="int"
|
||||||
transient="false"
|
transient="false"
|
||||||
@@ -55839,39 +56104,6 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</field>
|
</field>
|
||||||
<field name="TYPE_NOT_SUPPORTED"
|
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="6"
|
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
<field name="TYPE_NO_INTERNET_CONNECTION"
|
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="9"
|
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
<field name="TYPE_OUT_OF_MEMORY"
|
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="8"
|
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
<field name="TYPE_REMOVE_RIGHTS"
|
<field name="TYPE_REMOVE_RIGHTS"
|
||||||
type="int"
|
type="int"
|
||||||
transient="false"
|
transient="false"
|
||||||
@@ -55894,33 +56126,11 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</field>
|
</field>
|
||||||
<field name="TYPE_RIGHTS_NOT_INSTALLED"
|
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="4"
|
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
<field name="TYPE_RIGHTS_RENEWAL_NOT_ALLOWED"
|
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="5"
|
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
<field name="TYPE_WAIT_FOR_RIGHTS"
|
<field name="TYPE_WAIT_FOR_RIGHTS"
|
||||||
type="int"
|
type="int"
|
||||||
transient="false"
|
transient="false"
|
||||||
volatile="false"
|
volatile="false"
|
||||||
value="7"
|
value="4"
|
||||||
static="true"
|
static="true"
|
||||||
final="true"
|
final="true"
|
||||||
deprecated="not deprecated"
|
deprecated="not deprecated"
|
||||||
@@ -56181,7 +56391,7 @@
|
|||||||
</parameter>
|
</parameter>
|
||||||
</constructor>
|
</constructor>
|
||||||
<method name="acquireDrmInfo"
|
<method name="acquireDrmInfo"
|
||||||
return="android.drm.DrmInfo"
|
return="int"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
native="false"
|
native="false"
|
||||||
synchronized="false"
|
synchronized="false"
|
||||||
@@ -56208,6 +56418,21 @@
|
|||||||
<parameter name="mimeType" type="java.lang.String">
|
<parameter name="mimeType" type="java.lang.String">
|
||||||
</parameter>
|
</parameter>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="canHandle"
|
||||||
|
return="boolean"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="uri" type="android.net.Uri">
|
||||||
|
</parameter>
|
||||||
|
<parameter name="mimeType" type="java.lang.String">
|
||||||
|
</parameter>
|
||||||
|
</method>
|
||||||
<method name="checkRightsStatus"
|
<method name="checkRightsStatus"
|
||||||
return="int"
|
return="int"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
@@ -56231,11 +56456,39 @@
|
|||||||
deprecated="not deprecated"
|
deprecated="not deprecated"
|
||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
|
<parameter name="uri" type="android.net.Uri">
|
||||||
|
</parameter>
|
||||||
|
</method>
|
||||||
|
<method name="checkRightsStatus"
|
||||||
|
return="int"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
<parameter name="path" type="java.lang.String">
|
<parameter name="path" type="java.lang.String">
|
||||||
</parameter>
|
</parameter>
|
||||||
<parameter name="action" type="int">
|
<parameter name="action" type="int">
|
||||||
</parameter>
|
</parameter>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="checkRightsStatus"
|
||||||
|
return="int"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="uri" type="android.net.Uri">
|
||||||
|
</parameter>
|
||||||
|
<parameter name="action" type="int">
|
||||||
|
</parameter>
|
||||||
|
</method>
|
||||||
<method name="closeConvertSession"
|
<method name="closeConvertSession"
|
||||||
return="android.drm.DrmConvertedStatus"
|
return="android.drm.DrmConvertedStatus"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
@@ -56290,6 +56543,21 @@
|
|||||||
<parameter name="action" type="int">
|
<parameter name="action" type="int">
|
||||||
</parameter>
|
</parameter>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="getConstraints"
|
||||||
|
return="android.content.ContentValues"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="uri" type="android.net.Uri">
|
||||||
|
</parameter>
|
||||||
|
<parameter name="action" type="int">
|
||||||
|
</parameter>
|
||||||
|
</method>
|
||||||
<method name="getDrmObjectType"
|
<method name="getDrmObjectType"
|
||||||
return="int"
|
return="int"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
@@ -56305,6 +56573,21 @@
|
|||||||
<parameter name="mimeType" type="java.lang.String">
|
<parameter name="mimeType" type="java.lang.String">
|
||||||
</parameter>
|
</parameter>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="getDrmObjectType"
|
||||||
|
return="int"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="uri" type="android.net.Uri">
|
||||||
|
</parameter>
|
||||||
|
<parameter name="mimeType" type="java.lang.String">
|
||||||
|
</parameter>
|
||||||
|
</method>
|
||||||
<method name="getOriginalMimeType"
|
<method name="getOriginalMimeType"
|
||||||
return="java.lang.String"
|
return="java.lang.String"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
@@ -56318,8 +56601,21 @@
|
|||||||
<parameter name="path" type="java.lang.String">
|
<parameter name="path" type="java.lang.String">
|
||||||
</parameter>
|
</parameter>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="getOriginalMimeType"
|
||||||
|
return="java.lang.String"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="uri" type="android.net.Uri">
|
||||||
|
</parameter>
|
||||||
|
</method>
|
||||||
<method name="loadPlugIns"
|
<method name="loadPlugIns"
|
||||||
return="void"
|
return="int"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
native="false"
|
native="false"
|
||||||
synchronized="false"
|
synchronized="false"
|
||||||
@@ -56343,7 +56639,7 @@
|
|||||||
</parameter>
|
</parameter>
|
||||||
</method>
|
</method>
|
||||||
<method name="processDrmInfo"
|
<method name="processDrmInfo"
|
||||||
return="android.drm.DrmInfoStatus"
|
return="int"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
native="false"
|
native="false"
|
||||||
synchronized="false"
|
synchronized="false"
|
||||||
@@ -56356,7 +56652,7 @@
|
|||||||
</parameter>
|
</parameter>
|
||||||
</method>
|
</method>
|
||||||
<method name="removeAllRights"
|
<method name="removeAllRights"
|
||||||
return="void"
|
return="int"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
native="false"
|
native="false"
|
||||||
synchronized="false"
|
synchronized="false"
|
||||||
@@ -56367,7 +56663,7 @@
|
|||||||
>
|
>
|
||||||
</method>
|
</method>
|
||||||
<method name="removeRights"
|
<method name="removeRights"
|
||||||
return="void"
|
return="int"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
native="false"
|
native="false"
|
||||||
synchronized="false"
|
synchronized="false"
|
||||||
@@ -56379,8 +56675,21 @@
|
|||||||
<parameter name="path" type="java.lang.String">
|
<parameter name="path" type="java.lang.String">
|
||||||
</parameter>
|
</parameter>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="removeRights"
|
||||||
|
return="int"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="uri" type="android.net.Uri">
|
||||||
|
</parameter>
|
||||||
|
</method>
|
||||||
<method name="saveRights"
|
<method name="saveRights"
|
||||||
return="void"
|
return="int"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
native="false"
|
native="false"
|
||||||
synchronized="false"
|
synchronized="false"
|
||||||
@@ -56398,11 +56707,37 @@
|
|||||||
<exception name="IOException" type="java.io.IOException">
|
<exception name="IOException" type="java.io.IOException">
|
||||||
</exception>
|
</exception>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="setOnErrorListener"
|
||||||
|
return="void"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="true"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="errorListener" type="android.drm.DrmManagerClient.OnErrorListener">
|
||||||
|
</parameter>
|
||||||
|
</method>
|
||||||
|
<method name="setOnEventListener"
|
||||||
|
return="void"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="true"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="eventListener" type="android.drm.DrmManagerClient.OnEventListener">
|
||||||
|
</parameter>
|
||||||
|
</method>
|
||||||
<method name="setOnInfoListener"
|
<method name="setOnInfoListener"
|
||||||
return="void"
|
return="void"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
native="false"
|
native="false"
|
||||||
synchronized="false"
|
synchronized="true"
|
||||||
static="false"
|
static="false"
|
||||||
final="false"
|
final="false"
|
||||||
deprecated="not deprecated"
|
deprecated="not deprecated"
|
||||||
@@ -56412,7 +56747,7 @@
|
|||||||
</parameter>
|
</parameter>
|
||||||
</method>
|
</method>
|
||||||
<method name="unloadPlugIns"
|
<method name="unloadPlugIns"
|
||||||
return="void"
|
return="int"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
native="false"
|
native="false"
|
||||||
synchronized="false"
|
synchronized="false"
|
||||||
@@ -56422,7 +56757,77 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</method>
|
</method>
|
||||||
|
<field name="ERROR_NONE"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="0"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="ERROR_UNKNOWN"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="-2000"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
</class>
|
</class>
|
||||||
|
<interface name="DrmManagerClient.OnErrorListener"
|
||||||
|
abstract="true"
|
||||||
|
static="true"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<method name="onError"
|
||||||
|
return="void"
|
||||||
|
abstract="true"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="client" type="android.drm.DrmManagerClient">
|
||||||
|
</parameter>
|
||||||
|
<parameter name="event" type="android.drm.DrmErrorEvent">
|
||||||
|
</parameter>
|
||||||
|
</method>
|
||||||
|
</interface>
|
||||||
|
<interface name="DrmManagerClient.OnEventListener"
|
||||||
|
abstract="true"
|
||||||
|
static="true"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<method name="onEvent"
|
||||||
|
return="void"
|
||||||
|
abstract="true"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="client" type="android.drm.DrmManagerClient">
|
||||||
|
</parameter>
|
||||||
|
<parameter name="event" type="android.drm.DrmEvent">
|
||||||
|
</parameter>
|
||||||
|
<parameter name="attributes" type="java.util.HashMap<java.lang.String, java.lang.Object>">
|
||||||
|
</parameter>
|
||||||
|
</method>
|
||||||
|
</interface>
|
||||||
<interface name="DrmManagerClient.OnInfoListener"
|
<interface name="DrmManagerClient.OnInfoListener"
|
||||||
abstract="true"
|
abstract="true"
|
||||||
static="true"
|
static="true"
|
||||||
|
|||||||
@@ -75,12 +75,10 @@ DrmConstraints::KeyIterator DrmConstraints::keyIterator() {
|
|||||||
DrmConstraints::KeyIterator::KeyIterator(const DrmConstraints::KeyIterator& keyIterator)
|
DrmConstraints::KeyIterator::KeyIterator(const DrmConstraints::KeyIterator& keyIterator)
|
||||||
: mDrmConstraints(keyIterator.mDrmConstraints),
|
: mDrmConstraints(keyIterator.mDrmConstraints),
|
||||||
mIndex(keyIterator.mIndex) {
|
mIndex(keyIterator.mIndex) {
|
||||||
LOGV("DrmConstraints::KeyIterator::KeyIterator");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DrmConstraints::KeyIterator& DrmConstraints::KeyIterator::operator=(
|
DrmConstraints::KeyIterator& DrmConstraints::KeyIterator::operator=(
|
||||||
const DrmConstraints::KeyIterator& keyIterator) {
|
const DrmConstraints::KeyIterator& keyIterator) {
|
||||||
LOGV("DrmConstraints::KeyIterator::operator=");
|
|
||||||
mDrmConstraints = keyIterator.mDrmConstraints;
|
mDrmConstraints = keyIterator.mDrmConstraints;
|
||||||
mIndex = keyIterator.mIndex;
|
mIndex = keyIterator.mIndex;
|
||||||
return *this;
|
return *this;
|
||||||
@@ -94,12 +92,10 @@ DrmConstraints::Iterator DrmConstraints::iterator() {
|
|||||||
DrmConstraints::Iterator::Iterator(const DrmConstraints::Iterator& iterator) :
|
DrmConstraints::Iterator::Iterator(const DrmConstraints::Iterator& iterator) :
|
||||||
mDrmConstraints(iterator.mDrmConstraints),
|
mDrmConstraints(iterator.mDrmConstraints),
|
||||||
mIndex(iterator.mIndex) {
|
mIndex(iterator.mIndex) {
|
||||||
LOGV("DrmConstraints::Iterator::Iterator");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DrmConstraints::Iterator& DrmConstraints::Iterator::operator=(
|
DrmConstraints::Iterator& DrmConstraints::Iterator::operator=(
|
||||||
const DrmConstraints::Iterator& iterator) {
|
const DrmConstraints::Iterator& iterator) {
|
||||||
LOGV("DrmConstraints::Iterator::operator=");
|
|
||||||
mDrmConstraints = iterator.mDrmConstraints;
|
mDrmConstraints = iterator.mDrmConstraints;
|
||||||
mIndex = iterator.mIndex;
|
mIndex = iterator.mIndex;
|
||||||
return *this;
|
return *this;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ DrmInfoStatus* DrmEngineBase::processDrmInfo(int uniqueId, const DrmInfo* drmInf
|
|||||||
return onProcessDrmInfo(uniqueId, drmInfo);
|
return onProcessDrmInfo(uniqueId, drmInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmEngineBase::saveRights(
|
status_t DrmEngineBase::saveRights(
|
||||||
int uniqueId, const DrmRights& drmRights,
|
int uniqueId, const DrmRights& drmRights,
|
||||||
const String8& rightsPath, const String8& contentPath) {
|
const String8& rightsPath, const String8& contentPath) {
|
||||||
return onSaveRights(uniqueId, drmRights, rightsPath, contentPath);
|
return onSaveRights(uniqueId, drmRights, rightsPath, contentPath);
|
||||||
@@ -74,14 +74,14 @@ int DrmEngineBase::checkRightsStatus(int uniqueId, const String8& path, int acti
|
|||||||
return onCheckRightsStatus(uniqueId, path, action);
|
return onCheckRightsStatus(uniqueId, path, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmEngineBase::consumeRights(
|
status_t DrmEngineBase::consumeRights(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
|
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
|
||||||
onConsumeRights(uniqueId, decryptHandle, action, reserve);
|
return onConsumeRights(uniqueId, decryptHandle, action, reserve);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmEngineBase::setPlaybackStatus(
|
status_t DrmEngineBase::setPlaybackStatus(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
|
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
|
||||||
onSetPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
|
return onSetPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DrmEngineBase::validateAction(
|
bool DrmEngineBase::validateAction(
|
||||||
@@ -90,16 +90,16 @@ bool DrmEngineBase::validateAction(
|
|||||||
return onValidateAction(uniqueId, path, action, description);
|
return onValidateAction(uniqueId, path, action, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmEngineBase::removeRights(int uniqueId, const String8& path) {
|
status_t DrmEngineBase::removeRights(int uniqueId, const String8& path) {
|
||||||
onRemoveRights(uniqueId, path);
|
return onRemoveRights(uniqueId, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmEngineBase::removeAllRights(int uniqueId) {
|
status_t DrmEngineBase::removeAllRights(int uniqueId) {
|
||||||
onRemoveAllRights(uniqueId);
|
return onRemoveAllRights(uniqueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmEngineBase::openConvertSession(int uniqueId, int convertId) {
|
status_t DrmEngineBase::openConvertSession(int uniqueId, int convertId) {
|
||||||
onOpenConvertSession(uniqueId, convertId);
|
return onOpenConvertSession(uniqueId, convertId);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrmConvertedStatus* DrmEngineBase::convertData(
|
DrmConvertedStatus* DrmEngineBase::convertData(
|
||||||
@@ -120,24 +120,24 @@ status_t DrmEngineBase::openDecryptSession(
|
|||||||
return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length);
|
return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmEngineBase::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
|
status_t DrmEngineBase::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
|
||||||
onCloseDecryptSession(uniqueId, decryptHandle);
|
return onCloseDecryptSession(uniqueId, decryptHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmEngineBase::initializeDecryptUnit(
|
status_t DrmEngineBase::initializeDecryptUnit(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) {
|
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) {
|
||||||
onInitializeDecryptUnit(uniqueId, decryptHandle, decryptUnitId, headerInfo);
|
return onInitializeDecryptUnit(uniqueId, decryptHandle, decryptUnitId, headerInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t DrmEngineBase::decrypt(
|
status_t DrmEngineBase::decrypt(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
|
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
|
||||||
const DrmBuffer* encBuffer, DrmBuffer** decBuffer) {
|
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
|
||||||
return onDecrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer);
|
return onDecrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmEngineBase::finalizeDecryptUnit(
|
status_t DrmEngineBase::finalizeDecryptUnit(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
|
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
|
||||||
onFinalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
|
return onFinalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t DrmEngineBase::pread(
|
ssize_t DrmEngineBase::pread(
|
||||||
|
|||||||
@@ -14,10 +14,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LOG_NDEBUG 0
|
|
||||||
#define LOG_TAG "DrmInfoEvent"
|
|
||||||
#include "utils/Log.h"
|
|
||||||
|
|
||||||
#include <utils/String8.h>
|
#include <utils/String8.h>
|
||||||
#include <drm/DrmInfoEvent.h>
|
#include <drm/DrmInfoEvent.h>
|
||||||
|
|
||||||
|
|||||||
@@ -15,14 +15,21 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <drm/DrmRights.h>
|
#include <drm/DrmRights.h>
|
||||||
|
#include <ReadWriteUtils.h>
|
||||||
|
|
||||||
using namespace android;
|
using namespace android;
|
||||||
|
|
||||||
DrmRights::DrmRights(const String8& rightsFilePath, const String8& mimeType,
|
DrmRights::DrmRights(const String8& rightsFilePath, const String8& mimeType,
|
||||||
const String8& accountId, const String8& subscriptionId) {
|
const String8& accountId, const String8& subscriptionId) :
|
||||||
/**
|
mMimeType(mimeType),
|
||||||
* TODO Read DrmRights from rights file
|
mAccountId(accountId),
|
||||||
*/
|
mSubscriptionId(subscriptionId),
|
||||||
|
mRightsFromFile(NULL) {
|
||||||
|
int rightsLength = 0;
|
||||||
|
if (String8("") != rightsFilePath) {
|
||||||
|
rightsLength = ReadWriteUtils::readBytes(rightsFilePath, &mRightsFromFile);
|
||||||
|
}
|
||||||
|
mData = DrmBuffer(mRightsFromFile, rightsLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrmRights::DrmRights(const DrmBuffer& rightsData, const String8& mimeType,
|
DrmRights::DrmRights(const DrmBuffer& rightsData, const String8& mimeType,
|
||||||
@@ -30,7 +37,12 @@ DrmRights::DrmRights(const DrmBuffer& rightsData, const String8& mimeType,
|
|||||||
mData(rightsData),
|
mData(rightsData),
|
||||||
mMimeType(mimeType),
|
mMimeType(mimeType),
|
||||||
mAccountId(accountId),
|
mAccountId(accountId),
|
||||||
mSubscriptionId(subscriptionId) {
|
mSubscriptionId(subscriptionId),
|
||||||
|
mRightsFromFile(NULL) {
|
||||||
|
}
|
||||||
|
|
||||||
|
DrmRights::~DrmRights() {
|
||||||
|
delete[] mRightsFromFile; mRightsFromFile = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DrmBuffer& DrmRights::getData(void) const {
|
const DrmBuffer& DrmRights::getData(void) const {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ bool DrmSupportInfo::operator==(const DrmSupportInfo& drmSupportInfo) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DrmSupportInfo::isSupportedMimeType(const String8& mimeType) const {
|
bool DrmSupportInfo::isSupportedMimeType(const String8& mimeType) const {
|
||||||
for (int i = 0; i < mMimeTypeVector.size(); i++) {
|
for (unsigned int i = 0; i < mMimeTypeVector.size(); i++) {
|
||||||
const String8 item = mMimeTypeVector.itemAt(i);
|
const String8 item = mMimeTypeVector.itemAt(i);
|
||||||
|
|
||||||
if (String8("") != mimeType && item.find(mimeType) != -1) {
|
if (String8("") != mimeType && item.find(mimeType) != -1) {
|
||||||
@@ -53,7 +53,7 @@ bool DrmSupportInfo::isSupportedMimeType(const String8& mimeType) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DrmSupportInfo::isSupportedFileSuffix(const String8& fileType) const {
|
bool DrmSupportInfo::isSupportedFileSuffix(const String8& fileType) const {
|
||||||
for (int i = 0; i < mFileSuffixVector.size(); i++) {
|
for (unsigned int i = 0; i < mFileSuffixVector.size(); i++) {
|
||||||
const String8 item = mFileSuffixVector.itemAt(i);
|
const String8 item = mFileSuffixVector.itemAt(i);
|
||||||
|
|
||||||
if (String8("") != fileType && item.find(fileType) != -1) {
|
if (String8("") != fileType && item.find(fileType) != -1) {
|
||||||
|
|||||||
@@ -14,10 +14,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LOG_NDEBUG 0
|
|
||||||
#define LOG_TAG "IDrmIOService"
|
|
||||||
#include <utils/Log.h>
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <binder/Parcel.h>
|
#include <binder/Parcel.h>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LOG_NDEBUG 0
|
//#define LOG_NDEBUG 0
|
||||||
#define LOG_TAG "IDrmManagerService(Native)"
|
#define LOG_TAG "IDrmManagerService(Native)"
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
|
|
||||||
@@ -36,6 +36,23 @@
|
|||||||
|
|
||||||
using namespace android;
|
using namespace android;
|
||||||
|
|
||||||
|
int BpDrmManagerService::addUniqueId(int uniqueId) {
|
||||||
|
LOGV("add uniqueid");
|
||||||
|
Parcel data, reply;
|
||||||
|
data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
|
||||||
|
data.writeInt32(uniqueId);
|
||||||
|
remote()->transact(ADD_UNIQUEID, data, &reply);
|
||||||
|
return reply.readInt32();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BpDrmManagerService::removeUniqueId(int uniqueId) {
|
||||||
|
LOGV("remove uniqueid");
|
||||||
|
Parcel data, reply;
|
||||||
|
data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
|
||||||
|
data.writeInt32(uniqueId);
|
||||||
|
remote()->transact(REMOVE_UNIQUEID, data, &reply);
|
||||||
|
}
|
||||||
|
|
||||||
status_t BpDrmManagerService::loadPlugIns(int uniqueId) {
|
status_t BpDrmManagerService::loadPlugIns(int uniqueId) {
|
||||||
LOGV("load plugins");
|
LOGV("load plugins");
|
||||||
Parcel data, reply;
|
Parcel data, reply;
|
||||||
@@ -237,7 +254,7 @@ DrmInfo* BpDrmManagerService::acquireDrmInfo(int uniqueId, const DrmInfoRequest*
|
|||||||
return drmInfo;
|
return drmInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BpDrmManagerService::saveRights(
|
status_t BpDrmManagerService::saveRights(
|
||||||
int uniqueId, const DrmRights& drmRights,
|
int uniqueId, const DrmRights& drmRights,
|
||||||
const String8& rightsPath, const String8& contentPath) {
|
const String8& rightsPath, const String8& contentPath) {
|
||||||
LOGV("Save Rights");
|
LOGV("Save Rights");
|
||||||
@@ -264,6 +281,7 @@ void BpDrmManagerService::saveRights(
|
|||||||
data.writeString8((contentPath == String8("")) ? String8("NULL") : contentPath);
|
data.writeString8((contentPath == String8("")) ? String8("NULL") : contentPath);
|
||||||
|
|
||||||
remote()->transact(SAVE_RIGHTS, data, &reply);
|
remote()->transact(SAVE_RIGHTS, data, &reply);
|
||||||
|
return reply.readInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
String8 BpDrmManagerService::getOriginalMimeType(int uniqueId, const String8& path) {
|
String8 BpDrmManagerService::getOriginalMimeType(int uniqueId, const String8& path) {
|
||||||
@@ -307,10 +325,10 @@ int BpDrmManagerService::checkRightsStatus(int uniqueId, const String8& path, in
|
|||||||
return reply.readInt32();
|
return reply.readInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BpDrmManagerService::consumeRights(
|
status_t BpDrmManagerService::consumeRights(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
|
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
|
||||||
LOGV("consumeRights");
|
LOGV("consumeRights");
|
||||||
Parcel data, reply;
|
Parcel data, reply;
|
||||||
|
|
||||||
data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
|
data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
|
||||||
data.writeInt32(uniqueId);
|
data.writeInt32(uniqueId);
|
||||||
@@ -330,9 +348,10 @@ void BpDrmManagerService::consumeRights(
|
|||||||
data.writeInt32(static_cast< int>(reserve));
|
data.writeInt32(static_cast< int>(reserve));
|
||||||
|
|
||||||
remote()->transact(CONSUME_RIGHTS, data, &reply);
|
remote()->transact(CONSUME_RIGHTS, data, &reply);
|
||||||
|
return reply.readInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BpDrmManagerService::setPlaybackStatus(
|
status_t BpDrmManagerService::setPlaybackStatus(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
|
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
|
||||||
LOGV("setPlaybackStatus");
|
LOGV("setPlaybackStatus");
|
||||||
Parcel data, reply;
|
Parcel data, reply;
|
||||||
@@ -355,6 +374,7 @@ void BpDrmManagerService::setPlaybackStatus(
|
|||||||
data.writeInt32(position);
|
data.writeInt32(position);
|
||||||
|
|
||||||
remote()->transact(SET_PLAYBACK_STATUS, data, &reply);
|
remote()->transact(SET_PLAYBACK_STATUS, data, &reply);
|
||||||
|
return reply.readInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BpDrmManagerService::validateAction(
|
bool BpDrmManagerService::validateAction(
|
||||||
@@ -375,7 +395,7 @@ bool BpDrmManagerService::validateAction(
|
|||||||
return static_cast<bool>(reply.readInt32());
|
return static_cast<bool>(reply.readInt32());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BpDrmManagerService::removeRights(int uniqueId, const String8& path) {
|
status_t BpDrmManagerService::removeRights(int uniqueId, const String8& path) {
|
||||||
LOGV("removeRights");
|
LOGV("removeRights");
|
||||||
Parcel data, reply;
|
Parcel data, reply;
|
||||||
|
|
||||||
@@ -384,9 +404,10 @@ void BpDrmManagerService::removeRights(int uniqueId, const String8& path) {
|
|||||||
data.writeString8(path);
|
data.writeString8(path);
|
||||||
|
|
||||||
remote()->transact(REMOVE_RIGHTS, data, &reply);
|
remote()->transact(REMOVE_RIGHTS, data, &reply);
|
||||||
|
return reply.readInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BpDrmManagerService::removeAllRights(int uniqueId) {
|
status_t BpDrmManagerService::removeAllRights(int uniqueId) {
|
||||||
LOGV("removeAllRights");
|
LOGV("removeAllRights");
|
||||||
Parcel data, reply;
|
Parcel data, reply;
|
||||||
|
|
||||||
@@ -394,6 +415,7 @@ void BpDrmManagerService::removeAllRights(int uniqueId) {
|
|||||||
data.writeInt32(uniqueId);
|
data.writeInt32(uniqueId);
|
||||||
|
|
||||||
remote()->transact(REMOVE_ALL_RIGHTS, data, &reply);
|
remote()->transact(REMOVE_ALL_RIGHTS, data, &reply);
|
||||||
|
return reply.readInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
int BpDrmManagerService::openConvertSession(int uniqueId, const String8& mimeType) {
|
int BpDrmManagerService::openConvertSession(int uniqueId, const String8& mimeType) {
|
||||||
@@ -517,15 +539,12 @@ DecryptHandle* BpDrmManagerService::openDecryptSession(
|
|||||||
Parcel data, reply;
|
Parcel data, reply;
|
||||||
|
|
||||||
const String16 interfaceDescriptor = IDrmManagerService::getInterfaceDescriptor();
|
const String16 interfaceDescriptor = IDrmManagerService::getInterfaceDescriptor();
|
||||||
LOGV("BpDrmManagerService::openDecryptSession: InterfaceDescriptor name is %s",
|
|
||||||
interfaceDescriptor.string());
|
|
||||||
data.writeInterfaceToken(interfaceDescriptor);
|
data.writeInterfaceToken(interfaceDescriptor);
|
||||||
data.writeInt32(uniqueId);
|
data.writeInt32(uniqueId);
|
||||||
data.writeFileDescriptor(fd);
|
data.writeFileDescriptor(fd);
|
||||||
data.writeInt32(offset);
|
data.writeInt32(offset);
|
||||||
data.writeInt32(length);
|
data.writeInt32(length);
|
||||||
|
|
||||||
LOGV("try to invoke remote onTransact() with code OPEN_DECRYPT_SESSION");
|
|
||||||
remote()->transact(OPEN_DECRYPT_SESSION, data, &reply);
|
remote()->transact(OPEN_DECRYPT_SESSION, data, &reply);
|
||||||
|
|
||||||
DecryptHandle* handle = NULL;
|
DecryptHandle* handle = NULL;
|
||||||
@@ -546,7 +565,7 @@ DecryptHandle* BpDrmManagerService::openDecryptSession(
|
|||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BpDrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
|
status_t BpDrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
|
||||||
LOGV("closeDecryptSession");
|
LOGV("closeDecryptSession");
|
||||||
Parcel data, reply;
|
Parcel data, reply;
|
||||||
|
|
||||||
@@ -571,9 +590,10 @@ void BpDrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decry
|
|||||||
delete decryptHandle->decryptInfo; decryptHandle->decryptInfo = NULL;
|
delete decryptHandle->decryptInfo; decryptHandle->decryptInfo = NULL;
|
||||||
}
|
}
|
||||||
delete decryptHandle; decryptHandle = NULL;
|
delete decryptHandle; decryptHandle = NULL;
|
||||||
|
return reply.readInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BpDrmManagerService::initializeDecryptUnit(
|
status_t BpDrmManagerService::initializeDecryptUnit(
|
||||||
int uniqueId, DecryptHandle* decryptHandle,
|
int uniqueId, DecryptHandle* decryptHandle,
|
||||||
int decryptUnitId, const DrmBuffer* headerInfo) {
|
int decryptUnitId, const DrmBuffer* headerInfo) {
|
||||||
LOGV("initializeDecryptUnit");
|
LOGV("initializeDecryptUnit");
|
||||||
@@ -598,11 +618,12 @@ void BpDrmManagerService::initializeDecryptUnit(
|
|||||||
data.write(headerInfo->data, headerInfo->length);
|
data.write(headerInfo->data, headerInfo->length);
|
||||||
|
|
||||||
remote()->transact(INITIALIZE_DECRYPT_UNIT, data, &reply);
|
remote()->transact(INITIALIZE_DECRYPT_UNIT, data, &reply);
|
||||||
|
return reply.readInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t BpDrmManagerService::decrypt(
|
status_t BpDrmManagerService::decrypt(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
|
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
|
||||||
const DrmBuffer* encBuffer, DrmBuffer** decBuffer) {
|
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
|
||||||
LOGV("decrypt");
|
LOGV("decrypt");
|
||||||
Parcel data, reply;
|
Parcel data, reply;
|
||||||
|
|
||||||
@@ -626,6 +647,11 @@ status_t BpDrmManagerService::decrypt(
|
|||||||
data.writeInt32(encBuffer->length);
|
data.writeInt32(encBuffer->length);
|
||||||
data.write(encBuffer->data, encBuffer->length);
|
data.write(encBuffer->data, encBuffer->length);
|
||||||
|
|
||||||
|
if (NULL != IV) {
|
||||||
|
data.writeInt32(IV->length);
|
||||||
|
data.write(IV->data, IV->length);
|
||||||
|
}
|
||||||
|
|
||||||
remote()->transact(DECRYPT, data, &reply);
|
remote()->transact(DECRYPT, data, &reply);
|
||||||
|
|
||||||
const status_t status = reply.readInt32();
|
const status_t status = reply.readInt32();
|
||||||
@@ -638,7 +664,7 @@ status_t BpDrmManagerService::decrypt(
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BpDrmManagerService::finalizeDecryptUnit(
|
status_t BpDrmManagerService::finalizeDecryptUnit(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
|
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
|
||||||
LOGV("finalizeDecryptUnit");
|
LOGV("finalizeDecryptUnit");
|
||||||
Parcel data, reply;
|
Parcel data, reply;
|
||||||
@@ -660,6 +686,7 @@ void BpDrmManagerService::finalizeDecryptUnit(
|
|||||||
data.writeInt32(decryptUnitId);
|
data.writeInt32(decryptUnitId);
|
||||||
|
|
||||||
remote()->transact(FINALIZE_DECRYPT_UNIT, data, &reply);
|
remote()->transact(FINALIZE_DECRYPT_UNIT, data, &reply);
|
||||||
|
return reply.readInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t BpDrmManagerService::pread(
|
ssize_t BpDrmManagerService::pread(
|
||||||
@@ -702,6 +729,23 @@ status_t BnDrmManagerService::onTransact(
|
|||||||
LOGV("Entering BnDrmManagerService::onTransact with code %d", code);
|
LOGV("Entering BnDrmManagerService::onTransact with code %d", code);
|
||||||
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
|
case ADD_UNIQUEID:
|
||||||
|
{
|
||||||
|
LOGV("BnDrmManagerService::onTransact :ADD_UNIQUEID");
|
||||||
|
CHECK_INTERFACE(IDrmManagerService, data, reply);
|
||||||
|
int uniqueId = addUniqueId(data.readInt32());
|
||||||
|
reply->writeInt32(uniqueId);
|
||||||
|
return DRM_NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
case REMOVE_UNIQUEID:
|
||||||
|
{
|
||||||
|
LOGV("BnDrmManagerService::onTransact :REMOVE_UNIQUEID");
|
||||||
|
CHECK_INTERFACE(IDrmManagerService, data, reply);
|
||||||
|
removeUniqueId(data.readInt32());
|
||||||
|
return DRM_NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
case LOAD_PLUGINS:
|
case LOAD_PLUGINS:
|
||||||
{
|
{
|
||||||
LOGV("BnDrmManagerService::onTransact :LOAD_PLUGINS");
|
LOGV("BnDrmManagerService::onTransact :LOAD_PLUGINS");
|
||||||
@@ -711,7 +755,6 @@ status_t BnDrmManagerService::onTransact(
|
|||||||
|
|
||||||
reply->writeInt32(status);
|
reply->writeInt32(status);
|
||||||
return DRM_NO_ERROR;
|
return DRM_NO_ERROR;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case LOAD_PLUGINS_FROM_PATH:
|
case LOAD_PLUGINS_FROM_PATH:
|
||||||
@@ -745,7 +788,8 @@ status_t BnDrmManagerService::onTransact(
|
|||||||
LOGV("BnDrmManagerService::onTransact :UNLOAD_PLUGINS");
|
LOGV("BnDrmManagerService::onTransact :UNLOAD_PLUGINS");
|
||||||
CHECK_INTERFACE(IDrmManagerService, data, reply);
|
CHECK_INTERFACE(IDrmManagerService, data, reply);
|
||||||
|
|
||||||
status_t status = unloadPlugIns(data.readInt32());
|
const int uniqueId = data.readInt32();
|
||||||
|
status_t status = unloadPlugIns(uniqueId);
|
||||||
|
|
||||||
reply->writeInt32(status);
|
reply->writeInt32(status);
|
||||||
return DRM_NO_ERROR;
|
return DRM_NO_ERROR;
|
||||||
@@ -923,10 +967,11 @@ status_t BnDrmManagerService::onTransact(
|
|||||||
((accountId == String8("NULL")) ? String8("") : accountId),
|
((accountId == String8("NULL")) ? String8("") : accountId),
|
||||||
((subscriptionId == String8("NULL")) ? String8("") : subscriptionId));
|
((subscriptionId == String8("NULL")) ? String8("") : subscriptionId));
|
||||||
|
|
||||||
saveRights(uniqueId, drmRights,
|
const status_t status = saveRights(uniqueId, drmRights,
|
||||||
((rightsPath == String8("NULL")) ? String8("") : rightsPath),
|
((rightsPath == String8("NULL")) ? String8("") : rightsPath),
|
||||||
((contentPath == String8("NULL")) ? String8("") : contentPath));
|
((contentPath == String8("NULL")) ? String8("") : contentPath));
|
||||||
|
|
||||||
|
reply->writeInt32(status);
|
||||||
return DRM_NO_ERROR;
|
return DRM_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -985,7 +1030,10 @@ status_t BnDrmManagerService::onTransact(
|
|||||||
handle.decryptInfo->decryptBufferLength = bufferLength;
|
handle.decryptInfo->decryptBufferLength = bufferLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
consumeRights(uniqueId, &handle, data.readInt32(), static_cast<bool>(data.readInt32()));
|
const status_t status
|
||||||
|
= consumeRights(uniqueId, &handle, data.readInt32(),
|
||||||
|
static_cast<bool>(data.readInt32()));
|
||||||
|
reply->writeInt32(status);
|
||||||
|
|
||||||
delete handle.decryptInfo; handle.decryptInfo = NULL;
|
delete handle.decryptInfo; handle.decryptInfo = NULL;
|
||||||
return DRM_NO_ERROR;
|
return DRM_NO_ERROR;
|
||||||
@@ -1011,7 +1059,9 @@ status_t BnDrmManagerService::onTransact(
|
|||||||
handle.decryptInfo->decryptBufferLength = bufferLength;
|
handle.decryptInfo->decryptBufferLength = bufferLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPlaybackStatus(uniqueId, &handle, data.readInt32(), data.readInt32());
|
const status_t status
|
||||||
|
= setPlaybackStatus(uniqueId, &handle, data.readInt32(), data.readInt32());
|
||||||
|
reply->writeInt32(status);
|
||||||
|
|
||||||
delete handle.decryptInfo; handle.decryptInfo = NULL;
|
delete handle.decryptInfo; handle.decryptInfo = NULL;
|
||||||
return DRM_NO_ERROR;
|
return DRM_NO_ERROR;
|
||||||
@@ -1037,7 +1087,8 @@ status_t BnDrmManagerService::onTransact(
|
|||||||
LOGV("BnDrmManagerService::onTransact :REMOVE_RIGHTS");
|
LOGV("BnDrmManagerService::onTransact :REMOVE_RIGHTS");
|
||||||
CHECK_INTERFACE(IDrmManagerService, data, reply);
|
CHECK_INTERFACE(IDrmManagerService, data, reply);
|
||||||
|
|
||||||
removeRights(data.readInt32(), data.readString8());
|
const status_t status = removeRights(data.readInt32(), data.readString8());
|
||||||
|
reply->writeInt32(status);
|
||||||
|
|
||||||
return DRM_NO_ERROR;
|
return DRM_NO_ERROR;
|
||||||
}
|
}
|
||||||
@@ -1047,7 +1098,8 @@ status_t BnDrmManagerService::onTransact(
|
|||||||
LOGV("BnDrmManagerService::onTransact :REMOVE_ALL_RIGHTS");
|
LOGV("BnDrmManagerService::onTransact :REMOVE_ALL_RIGHTS");
|
||||||
CHECK_INTERFACE(IDrmManagerService, data, reply);
|
CHECK_INTERFACE(IDrmManagerService, data, reply);
|
||||||
|
|
||||||
removeAllRights(data.readInt32());
|
const status_t status = removeAllRights(data.readInt32());
|
||||||
|
reply->writeInt32(status);
|
||||||
|
|
||||||
return DRM_NO_ERROR;
|
return DRM_NO_ERROR;
|
||||||
}
|
}
|
||||||
@@ -1207,7 +1259,8 @@ status_t BnDrmManagerService::onTransact(
|
|||||||
handle->decryptInfo->decryptBufferLength = bufferLength;
|
handle->decryptInfo->decryptBufferLength = bufferLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
closeDecryptSession(uniqueId, handle);
|
const status_t status = closeDecryptSession(uniqueId, handle);
|
||||||
|
reply->writeInt32(status);
|
||||||
return DRM_NO_ERROR;
|
return DRM_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1237,7 +1290,9 @@ status_t BnDrmManagerService::onTransact(
|
|||||||
DrmBuffer* headerInfo = NULL;
|
DrmBuffer* headerInfo = NULL;
|
||||||
headerInfo = new DrmBuffer((char *)data.readInplace(bufferSize), bufferSize);
|
headerInfo = new DrmBuffer((char *)data.readInplace(bufferSize), bufferSize);
|
||||||
|
|
||||||
initializeDecryptUnit(uniqueId, &handle, decryptUnitId, headerInfo);
|
const status_t status
|
||||||
|
= initializeDecryptUnit(uniqueId, &handle, decryptUnitId, headerInfo);
|
||||||
|
reply->writeInt32(status);
|
||||||
|
|
||||||
delete handle.decryptInfo; handle.decryptInfo = NULL;
|
delete handle.decryptInfo; handle.decryptInfo = NULL;
|
||||||
delete headerInfo; headerInfo = NULL;
|
delete headerInfo; headerInfo = NULL;
|
||||||
@@ -1274,7 +1329,14 @@ status_t BnDrmManagerService::onTransact(
|
|||||||
buffer = new char[decBufferSize];
|
buffer = new char[decBufferSize];
|
||||||
DrmBuffer* decBuffer = new DrmBuffer(buffer, decBufferSize);
|
DrmBuffer* decBuffer = new DrmBuffer(buffer, decBufferSize);
|
||||||
|
|
||||||
const status_t status = decrypt(uniqueId, &handle, decryptUnitId, encBuffer, &decBuffer);
|
DrmBuffer* IV = NULL;
|
||||||
|
if (0 != data.dataAvail()) {
|
||||||
|
const int ivBufferlength = data.readInt32();
|
||||||
|
IV = new DrmBuffer((char *)data.readInplace(ivBufferlength), ivBufferlength);
|
||||||
|
}
|
||||||
|
|
||||||
|
const status_t status
|
||||||
|
= decrypt(uniqueId, &handle, decryptUnitId, encBuffer, &decBuffer, IV);
|
||||||
|
|
||||||
reply->writeInt32(status);
|
reply->writeInt32(status);
|
||||||
|
|
||||||
@@ -1286,6 +1348,7 @@ status_t BnDrmManagerService::onTransact(
|
|||||||
delete encBuffer; encBuffer = NULL;
|
delete encBuffer; encBuffer = NULL;
|
||||||
delete decBuffer; decBuffer = NULL;
|
delete decBuffer; decBuffer = NULL;
|
||||||
delete [] buffer; buffer = NULL;
|
delete [] buffer; buffer = NULL;
|
||||||
|
delete IV; IV = NULL;
|
||||||
return DRM_NO_ERROR;
|
return DRM_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1309,7 +1372,8 @@ status_t BnDrmManagerService::onTransact(
|
|||||||
handle.decryptInfo->decryptBufferLength = bufferLength;
|
handle.decryptInfo->decryptBufferLength = bufferLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
finalizeDecryptUnit(uniqueId, &handle, data.readInt32());
|
const status_t status = finalizeDecryptUnit(uniqueId, &handle, data.readInt32());
|
||||||
|
reply->writeInt32(status);
|
||||||
|
|
||||||
delete handle.decryptInfo; handle.decryptInfo = NULL;
|
delete handle.decryptInfo; handle.decryptInfo = NULL;
|
||||||
return DRM_NO_ERROR;
|
return DRM_NO_ERROR;
|
||||||
|
|||||||
@@ -14,10 +14,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LOG_NDEBUG 0
|
|
||||||
#define LOG_TAG "IDrmServiceListener"
|
|
||||||
#include <utils/Log.h>
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <binder/Parcel.h>
|
#include <binder/Parcel.h>
|
||||||
|
|||||||
@@ -14,6 +14,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//#define LOG_NDEBUG 0
|
||||||
|
#define LOG_TAG "ReadWriteUtils"
|
||||||
|
#include <utils/Log.h>
|
||||||
|
|
||||||
#include <ReadWriteUtils.h>
|
#include <ReadWriteUtils.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@@ -22,7 +26,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <utils/FileMap.h>
|
|
||||||
#include <utils/String8.h>
|
#include <utils/String8.h>
|
||||||
|
|
||||||
using namespace android;
|
using namespace android;
|
||||||
@@ -39,18 +42,39 @@ String8 ReadWriteUtils::readBytes(const String8& filePath) {
|
|||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
|
||||||
if (fstat(fd, &sb) == 0 && sb.st_size > 0) {
|
if (fstat(fd, &sb) == 0 && sb.st_size > 0) {
|
||||||
FileMap* fileMap = new FileMap();
|
int length = sb.st_size;
|
||||||
if (fileMap->create(filePath.string(), fd, 0, sb.st_size, true)) {
|
char* bytes = new char[length];
|
||||||
char* addr = (char*)fileMap->getDataPtr();
|
if (length == read(fd, (void*) bytes, length)) {
|
||||||
string.append(addr, sb.st_size);
|
string.append(bytes, length);
|
||||||
fileMap->release();
|
|
||||||
}
|
}
|
||||||
|
delete bytes;
|
||||||
}
|
}
|
||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ReadWriteUtils::readBytes(const String8& filePath, char** buffer) {
|
||||||
|
FILE* file = NULL;
|
||||||
|
file = fopen(filePath.string(), "r");
|
||||||
|
int length = 0;
|
||||||
|
|
||||||
|
if (NULL != file) {
|
||||||
|
int fd = fileno(file);
|
||||||
|
struct stat sb;
|
||||||
|
|
||||||
|
if (fstat(fd, &sb) == 0 && sb.st_size > 0) {
|
||||||
|
length = sb.st_size;
|
||||||
|
*buffer = new char[length];
|
||||||
|
if (length != read(fd, (void*) *buffer, length)) {
|
||||||
|
length = FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(file);
|
||||||
|
}
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
void ReadWriteUtils::writeToFile(const String8& filePath, const String8& data) {
|
void ReadWriteUtils::writeToFile(const String8& filePath, const String8& data) {
|
||||||
FILE* file = NULL;
|
FILE* file = NULL;
|
||||||
file = fopen(filePath.string(), "w+");
|
file = fopen(filePath.string(), "w+");
|
||||||
@@ -60,12 +84,8 @@ void ReadWriteUtils::writeToFile(const String8& filePath, const String8& data) {
|
|||||||
|
|
||||||
int size = data.size();
|
int size = data.size();
|
||||||
if (FAILURE != ftruncate(fd, size)) {
|
if (FAILURE != ftruncate(fd, size)) {
|
||||||
FileMap* fileMap = NULL;
|
if (size != write(fd, data.string(), size)) {
|
||||||
fileMap = new FileMap();
|
LOGE("Failed to write the data to: %s", filePath.string());
|
||||||
if (fileMap->create(filePath.string(), fd, 0, size, false)) {
|
|
||||||
char* addr = (char*)fileMap->getDataPtr();
|
|
||||||
memcpy(addr, data.string(), size);
|
|
||||||
fileMap->release();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(file);
|
fclose(file);
|
||||||
@@ -79,20 +99,9 @@ void ReadWriteUtils::appendToFile(const String8& filePath, const String8& data)
|
|||||||
if (NULL != file) {
|
if (NULL != file) {
|
||||||
int fd = fileno(file);
|
int fd = fileno(file);
|
||||||
|
|
||||||
int offset = lseek(fd, 0, SEEK_END);
|
int size = data.size();
|
||||||
if (FAILURE != offset) {
|
if (size != write(fd, data.string(), size)) {
|
||||||
int newEntrySize = data.size();
|
LOGE("Failed to write the data to: %s", filePath.string());
|
||||||
int fileSize = offset + newEntrySize;
|
|
||||||
|
|
||||||
if (FAILURE != ftruncate(fd, fileSize)) {
|
|
||||||
FileMap* fileMap = NULL;
|
|
||||||
fileMap = new FileMap();
|
|
||||||
if (fileMap->create(filePath.string(), fd, offset, fileSize, false)) {
|
|
||||||
char* addr = (char*)fileMap->getDataPtr();
|
|
||||||
memcpy(addr, data.string(), data.size());
|
|
||||||
fileMap->release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LOG_NDEBUG 0
|
//#define LOG_NDEBUG 0
|
||||||
#define LOG_TAG "DrmIOService"
|
#define LOG_TAG "DrmIOService"
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LOG_NDEBUG 0
|
//#define LOG_NDEBUG 0
|
||||||
#define LOG_TAG "DrmManager(Native)"
|
#define LOG_TAG "DrmManager(Native)"
|
||||||
#include "utils/Log.h"
|
#include "utils/Log.h"
|
||||||
|
|
||||||
@@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
using namespace android;
|
using namespace android;
|
||||||
|
|
||||||
|
Vector<int> DrmManager::mUniqueIdVector;
|
||||||
const String8 DrmManager::EMPTY_STRING("");
|
const String8 DrmManager::EMPTY_STRING("");
|
||||||
|
|
||||||
DrmManager::DrmManager() :
|
DrmManager::DrmManager() :
|
||||||
@@ -48,6 +49,42 @@ DrmManager::~DrmManager() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DrmManager::addUniqueId(int uniqueId) {
|
||||||
|
if (0 == uniqueId) {
|
||||||
|
int temp = 0;
|
||||||
|
bool foundUniqueId = false;
|
||||||
|
srand(time(NULL));
|
||||||
|
|
||||||
|
while (!foundUniqueId) {
|
||||||
|
const int size = mUniqueIdVector.size();
|
||||||
|
temp = rand() % 100;
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
for (; index < size; ++index) {
|
||||||
|
if (mUniqueIdVector.itemAt(index) == temp) {
|
||||||
|
foundUniqueId = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (index == size) {
|
||||||
|
foundUniqueId = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uniqueId = temp;
|
||||||
|
}
|
||||||
|
mUniqueIdVector.push(uniqueId);
|
||||||
|
return uniqueId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrmManager::removeUniqueId(int uniqueId) {
|
||||||
|
for (unsigned int i = 0; i < mUniqueIdVector.size(); i++) {
|
||||||
|
if (uniqueId == mUniqueIdVector.itemAt(i)) {
|
||||||
|
mUniqueIdVector.removeAt(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
status_t DrmManager::loadPlugIns(int uniqueId) {
|
status_t DrmManager::loadPlugIns(int uniqueId) {
|
||||||
String8 pluginDirPath("/system/lib/drm/plugins/native");
|
String8 pluginDirPath("/system/lib/drm/plugins/native");
|
||||||
return loadPlugIns(uniqueId, pluginDirPath);
|
return loadPlugIns(uniqueId, pluginDirPath);
|
||||||
@@ -82,10 +119,12 @@ status_t DrmManager::unloadPlugIns(int uniqueId) {
|
|||||||
rDrmEngine.terminate(uniqueId);
|
rDrmEngine.terminate(uniqueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
mConvertSessionMap.clear();
|
if (0 >= mUniqueIdVector.size()) {
|
||||||
mDecryptSessionMap.clear();
|
mConvertSessionMap.clear();
|
||||||
mSupportInfoToPlugInIdMap.clear();
|
mDecryptSessionMap.clear();
|
||||||
mPlugInManager.unloadPlugIns();
|
mSupportInfoToPlugInIdMap.clear();
|
||||||
|
mPlugInManager.unloadPlugIns();
|
||||||
|
}
|
||||||
return DRM_NO_ERROR;
|
return DRM_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,13 +198,15 @@ DrmInfo* DrmManager::acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoR
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManager::saveRights(int uniqueId, const DrmRights& drmRights,
|
status_t DrmManager::saveRights(int uniqueId, const DrmRights& drmRights,
|
||||||
const String8& rightsPath, const String8& contentPath) {
|
const String8& rightsPath, const String8& contentPath) {
|
||||||
const String8 plugInId = getSupportedPlugInId(drmRights.getMimeType());
|
const String8 plugInId = getSupportedPlugInId(drmRights.getMimeType());
|
||||||
|
status_t result = DRM_ERROR_UNKNOWN;
|
||||||
if (EMPTY_STRING != plugInId) {
|
if (EMPTY_STRING != plugInId) {
|
||||||
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
|
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
|
||||||
rDrmEngine.saveRights(uniqueId, drmRights, rightsPath, contentPath);
|
result = rDrmEngine.saveRights(uniqueId, drmRights, rightsPath, contentPath);
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
String8 DrmManager::getOriginalMimeType(int uniqueId, const String8& path) {
|
String8 DrmManager::getOriginalMimeType(int uniqueId, const String8& path) {
|
||||||
@@ -195,21 +236,24 @@ int DrmManager::checkRightsStatus(int uniqueId, const String8& path, int action)
|
|||||||
return RightsStatus::RIGHTS_INVALID;
|
return RightsStatus::RIGHTS_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManager::consumeRights(
|
status_t DrmManager::consumeRights(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
|
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
|
||||||
|
status_t result = DRM_ERROR_UNKNOWN;
|
||||||
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
|
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
|
||||||
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
|
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
|
||||||
drmEngine->consumeRights(uniqueId, decryptHandle, action, reserve);
|
result = drmEngine->consumeRights(uniqueId, decryptHandle, action, reserve);
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManager::setPlaybackStatus(
|
status_t DrmManager::setPlaybackStatus(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
|
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
|
||||||
|
status_t result = DRM_ERROR_UNKNOWN;
|
||||||
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
|
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
|
||||||
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
|
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
|
||||||
drmEngine->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
|
result = drmEngine->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DrmManager::validateAction(
|
bool DrmManager::validateAction(
|
||||||
@@ -222,21 +266,27 @@ bool DrmManager::validateAction(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManager::removeRights(int uniqueId, const String8& path) {
|
status_t DrmManager::removeRights(int uniqueId, const String8& path) {
|
||||||
const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, path);
|
const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, path);
|
||||||
|
status_t result = DRM_ERROR_UNKNOWN;
|
||||||
if (EMPTY_STRING != plugInId) {
|
if (EMPTY_STRING != plugInId) {
|
||||||
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
|
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
|
||||||
rDrmEngine.removeRights(uniqueId, path);
|
result = rDrmEngine.removeRights(uniqueId, path);
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManager::removeAllRights(int uniqueId) {
|
status_t DrmManager::removeAllRights(int uniqueId) {
|
||||||
Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
|
Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
|
||||||
|
status_t result = DRM_ERROR_UNKNOWN;
|
||||||
for (unsigned int index = 0; index < plugInIdList.size(); index++) {
|
for (unsigned int index = 0; index < plugInIdList.size(); index++) {
|
||||||
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInIdList.itemAt(index));
|
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInIdList.itemAt(index));
|
||||||
rDrmEngine.removeAllRights(uniqueId);
|
result = rDrmEngine.removeAllRights(uniqueId);
|
||||||
|
if (DRM_NO_ERROR != result) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DrmManager::openConvertSession(int uniqueId, const String8& mimeType) {
|
int DrmManager::openConvertSession(int uniqueId, const String8& mimeType) {
|
||||||
@@ -246,12 +296,12 @@ int DrmManager::openConvertSession(int uniqueId, const String8& mimeType) {
|
|||||||
if (EMPTY_STRING != plugInId) {
|
if (EMPTY_STRING != plugInId) {
|
||||||
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
|
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
|
||||||
|
|
||||||
Mutex::Autolock _l(mConvertLock);
|
if (DRM_NO_ERROR == rDrmEngine.openConvertSession(uniqueId, mConvertId + 1)) {
|
||||||
++mConvertId;
|
Mutex::Autolock _l(mConvertLock);
|
||||||
convertId = mConvertId;
|
++mConvertId;
|
||||||
mConvertSessionMap.add(mConvertId, &rDrmEngine);
|
convertId = mConvertId;
|
||||||
|
mConvertSessionMap.add(convertId, &rDrmEngine);
|
||||||
rDrmEngine.openConvertSession(uniqueId, mConvertId);
|
}
|
||||||
}
|
}
|
||||||
return convertId;
|
return convertId;
|
||||||
}
|
}
|
||||||
@@ -310,7 +360,6 @@ status_t DrmManager::getAllSupportInfo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, int offset, int length) {
|
DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, int offset, int length) {
|
||||||
LOGV("Entering DrmManager::openDecryptSession");
|
|
||||||
status_t result = DRM_ERROR_CANNOT_HANDLE;
|
status_t result = DRM_ERROR_CANNOT_HANDLE;
|
||||||
Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
|
Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
|
||||||
|
|
||||||
@@ -324,18 +373,15 @@ DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, int offset,
|
|||||||
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
|
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
|
||||||
result = rDrmEngine.openDecryptSession(uniqueId, handle, fd, offset, length);
|
result = rDrmEngine.openDecryptSession(uniqueId, handle, fd, offset, length);
|
||||||
|
|
||||||
LOGV("plug-in %s return value = %d", plugInId.string(), result);
|
|
||||||
|
|
||||||
if (DRM_NO_ERROR == result) {
|
if (DRM_NO_ERROR == result) {
|
||||||
++mDecryptSessionId;
|
++mDecryptSessionId;
|
||||||
mDecryptSessionMap.add(mDecryptSessionId, &rDrmEngine);
|
mDecryptSessionMap.add(mDecryptSessionId, &rDrmEngine);
|
||||||
LOGV("plug-in %s is selected", plugInId.string());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DRM_ERROR_CANNOT_HANDLE == result) {
|
if (DRM_NO_ERROR != result) {
|
||||||
delete handle; handle = NULL;
|
delete handle; handle = NULL;
|
||||||
LOGE("DrmManager::openDecryptSession: no capable plug-in found");
|
LOGE("DrmManager::openDecryptSession: no capable plug-in found");
|
||||||
}
|
}
|
||||||
@@ -343,39 +389,47 @@ DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, int offset,
|
|||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManager::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
|
status_t DrmManager::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
|
||||||
|
status_t result = DRM_ERROR_UNKNOWN;
|
||||||
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
|
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
|
||||||
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
|
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
|
||||||
drmEngine->closeDecryptSession(uniqueId, decryptHandle);
|
result = drmEngine->closeDecryptSession(uniqueId, decryptHandle);
|
||||||
|
if (DRM_NO_ERROR == result) {
|
||||||
mDecryptSessionMap.removeItem(decryptHandle->decryptId);
|
mDecryptSessionMap.removeItem(decryptHandle->decryptId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManager::initializeDecryptUnit(
|
status_t DrmManager::initializeDecryptUnit(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) {
|
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) {
|
||||||
|
status_t result = DRM_ERROR_UNKNOWN;
|
||||||
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
|
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
|
||||||
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
|
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
|
||||||
drmEngine->initializeDecryptUnit(uniqueId, decryptHandle, decryptUnitId, headerInfo);
|
result = drmEngine->initializeDecryptUnit(uniqueId, decryptHandle, decryptUnitId, headerInfo);
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t DrmManager::decrypt(int uniqueId, DecryptHandle* decryptHandle,
|
status_t DrmManager::decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
|
||||||
int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer) {
|
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
|
||||||
status_t status = DRM_ERROR_UNKNOWN;
|
status_t result = DRM_ERROR_UNKNOWN;
|
||||||
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
|
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
|
||||||
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
|
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
|
||||||
status = drmEngine->decrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer);
|
result = drmEngine->decrypt(
|
||||||
|
uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
|
||||||
}
|
}
|
||||||
return status;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManager::finalizeDecryptUnit(
|
status_t DrmManager::finalizeDecryptUnit(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
|
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
|
||||||
|
status_t result = DRM_ERROR_UNKNOWN;
|
||||||
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
|
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
|
||||||
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
|
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
|
||||||
drmEngine->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
|
result = drmEngine->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t DrmManager::pread(int uniqueId, DecryptHandle* decryptHandle,
|
ssize_t DrmManager::pread(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LOG_NDEBUG 0
|
//#define LOG_NDEBUG 0
|
||||||
#define LOG_TAG "DrmManagerService(Native)"
|
#define LOG_TAG "DrmManagerService(Native)"
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
|
|
||||||
@@ -29,20 +29,23 @@ using namespace android;
|
|||||||
|
|
||||||
#define SUCCESS 0
|
#define SUCCESS 0
|
||||||
#define DRM_DIRECTORY_PERMISSION 0700
|
#define DRM_DIRECTORY_PERMISSION 0700
|
||||||
|
#define DRM_PLUGINS_ROOT "/data/drm/plugins"
|
||||||
|
#define DRM_PLUGINS_NATIVE "/data/drm/plugins/native"
|
||||||
|
#define DRM_PLUGINS_NATIVE_DATABASES "/data/drm/plugins/native/databases"
|
||||||
|
|
||||||
void DrmManagerService::instantiate() {
|
void DrmManagerService::instantiate() {
|
||||||
LOGV("instantiate");
|
LOGV("instantiate");
|
||||||
|
|
||||||
int res = mkdir("/data/drm/plugins", DRM_DIRECTORY_PERMISSION);
|
int res = mkdir(DRM_PLUGINS_ROOT, DRM_DIRECTORY_PERMISSION);
|
||||||
if (SUCCESS == res || EEXIST == errno) {
|
if (SUCCESS == res || EEXIST == errno) {
|
||||||
res = mkdir("/data/drm/plugins/native", DRM_DIRECTORY_PERMISSION);
|
res = mkdir(DRM_PLUGINS_NATIVE, DRM_DIRECTORY_PERMISSION);
|
||||||
if (SUCCESS == res || EEXIST == errno) {
|
if (SUCCESS == res || EEXIST == errno) {
|
||||||
res = mkdir("/data/drm/plugins/native/databases", DRM_DIRECTORY_PERMISSION);
|
res = mkdir(DRM_PLUGINS_NATIVE_DATABASES, DRM_DIRECTORY_PERMISSION);
|
||||||
if (SUCCESS == res || EEXIST == errno) {
|
if (SUCCESS == res || EEXIST == errno) {
|
||||||
defaultServiceManager()
|
defaultServiceManager()
|
||||||
->addService(String16("drm.drmManager"), new DrmManagerService());
|
->addService(String16("drm.drmManager"), new DrmManagerService());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,6 +60,14 @@ DrmManagerService::~DrmManagerService() {
|
|||||||
delete mDrmManager; mDrmManager = NULL;
|
delete mDrmManager; mDrmManager = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DrmManagerService::addUniqueId(int uniqueId) {
|
||||||
|
return mDrmManager->addUniqueId(uniqueId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrmManagerService::removeUniqueId(int uniqueId) {
|
||||||
|
mDrmManager->removeUniqueId(uniqueId);
|
||||||
|
}
|
||||||
|
|
||||||
status_t DrmManagerService::loadPlugIns(int uniqueId) {
|
status_t DrmManagerService::loadPlugIns(int uniqueId) {
|
||||||
LOGV("Entering load plugins");
|
LOGV("Entering load plugins");
|
||||||
return mDrmManager->loadPlugIns(uniqueId);
|
return mDrmManager->loadPlugIns(uniqueId);
|
||||||
@@ -105,7 +116,7 @@ DrmInfo* DrmManagerService::acquireDrmInfo(int uniqueId, const DrmInfoRequest* d
|
|||||||
return mDrmManager->acquireDrmInfo(uniqueId, drmInfoRequest);
|
return mDrmManager->acquireDrmInfo(uniqueId, drmInfoRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerService::saveRights(
|
status_t DrmManagerService::saveRights(
|
||||||
int uniqueId, const DrmRights& drmRights,
|
int uniqueId, const DrmRights& drmRights,
|
||||||
const String8& rightsPath, const String8& contentPath) {
|
const String8& rightsPath, const String8& contentPath) {
|
||||||
LOGV("Entering saveRights");
|
LOGV("Entering saveRights");
|
||||||
@@ -129,16 +140,16 @@ int DrmManagerService::checkRightsStatus(
|
|||||||
return mDrmManager->checkRightsStatus(uniqueId, path, action);
|
return mDrmManager->checkRightsStatus(uniqueId, path, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerService::consumeRights(
|
status_t DrmManagerService::consumeRights(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
|
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
|
||||||
LOGV("Entering consumeRights");
|
LOGV("Entering consumeRights");
|
||||||
mDrmManager->consumeRights(uniqueId, decryptHandle, action, reserve);
|
return mDrmManager->consumeRights(uniqueId, decryptHandle, action, reserve);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerService::setPlaybackStatus(
|
status_t DrmManagerService::setPlaybackStatus(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
|
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
|
||||||
LOGV("Entering setPlaybackStatus");
|
LOGV("Entering setPlaybackStatus");
|
||||||
mDrmManager->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
|
return mDrmManager->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DrmManagerService::validateAction(
|
bool DrmManagerService::validateAction(
|
||||||
@@ -148,14 +159,14 @@ bool DrmManagerService::validateAction(
|
|||||||
return mDrmManager->validateAction(uniqueId, path, action, description);
|
return mDrmManager->validateAction(uniqueId, path, action, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerService::removeRights(int uniqueId, const String8& path) {
|
status_t DrmManagerService::removeRights(int uniqueId, const String8& path) {
|
||||||
LOGV("Entering removeRights");
|
LOGV("Entering removeRights");
|
||||||
mDrmManager->removeRights(uniqueId, path);
|
return mDrmManager->removeRights(uniqueId, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerService::removeAllRights(int uniqueId) {
|
status_t DrmManagerService::removeAllRights(int uniqueId) {
|
||||||
LOGV("Entering removeAllRights");
|
LOGV("Entering removeAllRights");
|
||||||
mDrmManager->removeAllRights(uniqueId);
|
return mDrmManager->removeAllRights(uniqueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DrmManagerService::openConvertSession(int uniqueId, const String8& mimeType) {
|
int DrmManagerService::openConvertSession(int uniqueId, const String8& mimeType) {
|
||||||
@@ -186,28 +197,28 @@ DecryptHandle* DrmManagerService::openDecryptSession(
|
|||||||
return mDrmManager->openDecryptSession(uniqueId, fd, offset, length);
|
return mDrmManager->openDecryptSession(uniqueId, fd, offset, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
|
status_t DrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
|
||||||
LOGV("Entering closeDecryptSession");
|
LOGV("Entering closeDecryptSession");
|
||||||
mDrmManager->closeDecryptSession(uniqueId, decryptHandle);
|
return mDrmManager->closeDecryptSession(uniqueId, decryptHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerService::initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
status_t DrmManagerService::initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
int decryptUnitId, const DrmBuffer* headerInfo) {
|
int decryptUnitId, const DrmBuffer* headerInfo) {
|
||||||
LOGV("Entering initializeDecryptUnit");
|
LOGV("Entering initializeDecryptUnit");
|
||||||
mDrmManager->initializeDecryptUnit(uniqueId,decryptHandle, decryptUnitId, headerInfo);
|
return mDrmManager->initializeDecryptUnit(uniqueId,decryptHandle, decryptUnitId, headerInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t DrmManagerService::decrypt(
|
status_t DrmManagerService::decrypt(
|
||||||
int uniqueId, DecryptHandle* decryptHandle,
|
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
|
||||||
int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer) {
|
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
|
||||||
LOGV("Entering decrypt");
|
LOGV("Entering decrypt");
|
||||||
return mDrmManager->decrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer);
|
return mDrmManager->decrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerService::finalizeDecryptUnit(
|
status_t DrmManagerService::finalizeDecryptUnit(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
|
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
|
||||||
LOGV("Entering finalizeDecryptUnit");
|
LOGV("Entering finalizeDecryptUnit");
|
||||||
mDrmManager->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
|
return mDrmManager->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t DrmManagerService::pread(int uniqueId, DecryptHandle* decryptHandle,
|
ssize_t DrmManagerService::pread(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
|
|||||||
@@ -45,12 +45,10 @@ StringTokenizer::Iterator StringTokenizer::iterator() {
|
|||||||
StringTokenizer::Iterator::Iterator(const StringTokenizer::Iterator& iterator) :
|
StringTokenizer::Iterator::Iterator(const StringTokenizer::Iterator& iterator) :
|
||||||
mStringTokenizer(iterator.mStringTokenizer),
|
mStringTokenizer(iterator.mStringTokenizer),
|
||||||
mIndex(iterator.mIndex) {
|
mIndex(iterator.mIndex) {
|
||||||
LOGV("StringTokenizer::Iterator::Iterator");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StringTokenizer::Iterator& StringTokenizer::Iterator::operator=(
|
StringTokenizer::Iterator& StringTokenizer::Iterator::operator=(
|
||||||
const StringTokenizer::Iterator& iterator) {
|
const StringTokenizer::Iterator& iterator) {
|
||||||
LOGV("StringTokenizer::Iterator::operator=");
|
|
||||||
mStringTokenizer = iterator.mStringTokenizer;
|
mStringTokenizer = iterator.mStringTokenizer;
|
||||||
mIndex = iterator.mIndex;
|
mIndex = iterator.mIndex;
|
||||||
return *this;
|
return *this;
|
||||||
|
|||||||
89
drm/java/android/drm/DrmErrorEvent.java
Normal file
89
drm/java/android/drm/DrmErrorEvent.java
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.drm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is an entity class which would be passed to caller in
|
||||||
|
* {@link DrmManagerClient.OnErrorListener#onError(DrmManagerClient, DrmErrorEvent)}
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class DrmErrorEvent extends DrmEvent {
|
||||||
|
/**
|
||||||
|
* TYPE_RIGHTS_NOT_INSTALLED, when something went wrong installing the rights.
|
||||||
|
*/
|
||||||
|
public static final int TYPE_RIGHTS_NOT_INSTALLED = 2001;
|
||||||
|
/**
|
||||||
|
* TYPE_RIGHTS_RENEWAL_NOT_ALLOWED, when the server rejects renewal of rights.
|
||||||
|
*/
|
||||||
|
public static final int TYPE_RIGHTS_RENEWAL_NOT_ALLOWED = 2002;
|
||||||
|
/**
|
||||||
|
* TYPE_NOT_SUPPORTED, when answer from server can not be handled by the native agent.
|
||||||
|
*/
|
||||||
|
public static final int TYPE_NOT_SUPPORTED = 2003;
|
||||||
|
/**
|
||||||
|
* TYPE_OUT_OF_MEMORY, when memory allocation fail during renewal.
|
||||||
|
* Can in the future perhaps be used to trigger garbage collector.
|
||||||
|
*/
|
||||||
|
public static final int TYPE_OUT_OF_MEMORY = 2004;
|
||||||
|
/**
|
||||||
|
* TYPE_NO_INTERNET_CONNECTION, when the Internet connection is missing and no attempt
|
||||||
|
* can be made to renew rights.
|
||||||
|
*/
|
||||||
|
public static final int TYPE_NO_INTERNET_CONNECTION = 2005;
|
||||||
|
/**
|
||||||
|
* TYPE_REGISTRATION_FAILED, when failed to register with the service.
|
||||||
|
*/
|
||||||
|
public static final int TYPE_REGISTRATION_FAILED = 2006;
|
||||||
|
/**
|
||||||
|
* TYPE_UNREGISTRATION_FAILED, when failed to unregister with the service.
|
||||||
|
*/
|
||||||
|
public static final int TYPE_UNREGISTRATION_FAILED = 2007;
|
||||||
|
/**
|
||||||
|
* TYPE_RIGHTS_ACQUISITION_FAILED, when failed to acquire the rights information required.
|
||||||
|
*/
|
||||||
|
public static final int TYPE_RIGHTS_ACQUISITION_FAILED = 2008;
|
||||||
|
/**
|
||||||
|
* TYPE_INITIALIZE_FAILED, when failed to load and initialize the available plugins.
|
||||||
|
*/
|
||||||
|
public static final int TYPE_INITIALIZE_FAILED = 2009;
|
||||||
|
/**
|
||||||
|
* TYPE_FINALIZE_FAILED, when failed to unload and finalize the loaded plugins.
|
||||||
|
*/
|
||||||
|
public static final int TYPE_FINALIZE_FAILED = 2010;
|
||||||
|
/**
|
||||||
|
* TYPE_REMOVE_ALL_RIGHTS_FAILED, when failed to remove all the rights objects
|
||||||
|
* associated with all DRM schemes.
|
||||||
|
*/
|
||||||
|
public static final int TYPE_REMOVE_ALL_RIGHTS_FAILED = 2011;
|
||||||
|
/**
|
||||||
|
* TYPE_DRM_INFO_ACQUISITION_FAILED, when failed to get the required information to
|
||||||
|
* communicate with the service.
|
||||||
|
*/
|
||||||
|
public static final int TYPE_DRM_INFO_ACQUISITION_FAILED = 2012;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* constructor to create DrmErrorEvent object with given parameters
|
||||||
|
*
|
||||||
|
* @param uniqueId Unique session identifier
|
||||||
|
* @param type Type of information
|
||||||
|
* @param message Message description
|
||||||
|
*/
|
||||||
|
public DrmErrorEvent(int uniqueId, int type, String message) {
|
||||||
|
super(uniqueId, type, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -22,6 +22,40 @@ package android.drm;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DrmEvent {
|
public class DrmEvent {
|
||||||
|
/**
|
||||||
|
* Constant field signifies that unload and finalize the loaded plugins successfully
|
||||||
|
*/
|
||||||
|
public static final int TYPE_FINALIZED = 1001;
|
||||||
|
/**
|
||||||
|
* Constant field signifies that register with the service successfully
|
||||||
|
*/
|
||||||
|
public static final int TYPE_REGISTERED = 1002;
|
||||||
|
/**
|
||||||
|
* Constant field signifies that load and initialized the available plugins successfully
|
||||||
|
*/
|
||||||
|
public static final int TYPE_INITIALIZED = 1003;
|
||||||
|
/**
|
||||||
|
* Constant field signifies that unregister with the service successfully
|
||||||
|
*/
|
||||||
|
public static final int TYPE_UNREGISTERED = 1004;
|
||||||
|
/**
|
||||||
|
* Constant field signifies that rights information is acquired successfully
|
||||||
|
*/
|
||||||
|
public static final int TYPE_RIGHTS_ACQUIRED = 1005;
|
||||||
|
/**
|
||||||
|
* Constant field signifies that all the rights information associated with
|
||||||
|
* all DRM schemes are removed successfully
|
||||||
|
*/
|
||||||
|
public static final int TYPE_ALL_RIGHTS_REMOVED = 1006;
|
||||||
|
/**
|
||||||
|
* Constant field signifies that the required information to communicate with
|
||||||
|
* the service is acquired sucessfully
|
||||||
|
*/
|
||||||
|
public static final int TYPE_DRM_INFO_ACQUIRED = 1007;
|
||||||
|
|
||||||
|
public static final String DRM_INFO_STATUS_OBJECT = "drm_info_status_object";
|
||||||
|
public static final String DRM_INFO_OBJECT = "drm_info_object";
|
||||||
|
|
||||||
private final int mUniqueId;
|
private final int mUniqueId;
|
||||||
private final int mType;
|
private final int mType;
|
||||||
private String mMessage = "";
|
private String mMessage = "";
|
||||||
|
|||||||
@@ -26,42 +26,25 @@ public class DrmInfoEvent extends DrmEvent {
|
|||||||
* TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT, when registration has been already done
|
* TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT, when registration has been already done
|
||||||
* by another account ID.
|
* by another account ID.
|
||||||
*/
|
*/
|
||||||
public static final int TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT = 0x0000001;
|
public static final int TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT = 1;
|
||||||
/**
|
/**
|
||||||
* TYPE_REMOVE_RIGHTS, when the rights needs to be removed completely.
|
* TYPE_REMOVE_RIGHTS, when the rights needs to be removed completely.
|
||||||
*/
|
*/
|
||||||
public static final int TYPE_REMOVE_RIGHTS = 0x0000002;
|
public static final int TYPE_REMOVE_RIGHTS = 2;
|
||||||
/**
|
/**
|
||||||
* TYPE_RIGHTS_INSTALLED, when the rights are downloaded and installed ok.
|
* TYPE_RIGHTS_INSTALLED, when the rights are downloaded and installed ok.
|
||||||
*/
|
*/
|
||||||
public static final int TYPE_RIGHTS_INSTALLED = 0x0000003;
|
public static final int TYPE_RIGHTS_INSTALLED = 3;
|
||||||
/**
|
|
||||||
* TYPE_RIGHTS_NOT_INSTALLED, when something went wrong installing the rights.
|
|
||||||
*/
|
|
||||||
public static final int TYPE_RIGHTS_NOT_INSTALLED = 0x0000004;
|
|
||||||
/**
|
|
||||||
* TYPE_RIGHTS_RENEWAL_NOT_ALLOWED, when the server rejects renewal of rights.
|
|
||||||
*/
|
|
||||||
public static final int TYPE_RIGHTS_RENEWAL_NOT_ALLOWED = 0x0000005;
|
|
||||||
/**
|
|
||||||
* TYPE_NOT_SUPPORTED, when answer from server can not be handled by the native agent.
|
|
||||||
*/
|
|
||||||
public static final int TYPE_NOT_SUPPORTED = 0x0000006;
|
|
||||||
/**
|
/**
|
||||||
* TYPE_WAIT_FOR_RIGHTS, rights object is on it's way to phone,
|
* TYPE_WAIT_FOR_RIGHTS, rights object is on it's way to phone,
|
||||||
* wait before calling checkRights again.
|
* wait before calling checkRights again.
|
||||||
*/
|
*/
|
||||||
public static final int TYPE_WAIT_FOR_RIGHTS = 0x0000007;
|
public static final int TYPE_WAIT_FOR_RIGHTS = 4;
|
||||||
/**
|
/**
|
||||||
* TYPE_OUT_OF_MEMORY, when memory allocation fail during renewal.
|
* TYPE_ACCOUNT_ALREADY_REGISTERED, when registration has been
|
||||||
* Can in the future perhaps be used to trigger garbage collector.
|
* already done for the given account.
|
||||||
*/
|
*/
|
||||||
public static final int TYPE_OUT_OF_MEMORY = 0x0000008;
|
public static final int TYPE_ACCOUNT_ALREADY_REGISTERED = 5;
|
||||||
/**
|
|
||||||
* TYPE_NO_INTERNET_CONNECTION, when the Internet connection is missing and no attempt
|
|
||||||
* can be made to renew rights.
|
|
||||||
*/
|
|
||||||
public static final int TYPE_NO_INTERNET_CONNECTION = 0x0000009;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor to create DrmInfoEvent object with given parameters
|
* constructor to create DrmInfoEvent object with given parameters
|
||||||
|
|||||||
@@ -18,14 +18,19 @@ package android.drm;
|
|||||||
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.HandlerThread;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
import android.provider.MediaStore;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface of DRM Framework.
|
* Interface of DRM Framework.
|
||||||
@@ -34,7 +39,16 @@ import java.util.ArrayList;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DrmManagerClient {
|
public class DrmManagerClient {
|
||||||
private static final String TAG = "DrmManager";
|
/**
|
||||||
|
* Constant field signifies the success or no error occurred
|
||||||
|
*/
|
||||||
|
public static final int ERROR_NONE = 0;
|
||||||
|
/**
|
||||||
|
* Constant field signifies that error occurred and the reason is not known
|
||||||
|
*/
|
||||||
|
public static final int ERROR_UNKNOWN = -2000;
|
||||||
|
|
||||||
|
private static final String TAG = "DrmManagerClient";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// Load the respective library
|
// Load the respective library
|
||||||
@@ -55,55 +69,189 @@ public class DrmManagerClient {
|
|||||||
public void onInfo(DrmManagerClient client, DrmInfoEvent event);
|
public void onInfo(DrmManagerClient client, DrmInfoEvent event);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int STATE_UNINITIALIZED = 0x00000000;
|
/**
|
||||||
private static final int STATE_INITIALIZED = 0x00000001;
|
* Interface definition of a callback to be invoked to communicate
|
||||||
|
* the result of time consuming APIs asynchronously
|
||||||
|
*/
|
||||||
|
public interface OnEventListener {
|
||||||
|
/**
|
||||||
|
* Called to indicate the result of asynchronous APIs.
|
||||||
|
*
|
||||||
|
* @param client DrmManagerClient instance
|
||||||
|
* @param event instance which wraps type and message
|
||||||
|
* @param attributes resultant values in key and value pair.
|
||||||
|
*/
|
||||||
|
public void onEvent(DrmManagerClient client, DrmEvent event,
|
||||||
|
HashMap<String, Object> attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface definition of a callback to be invoked to communicate
|
||||||
|
* the error occurred
|
||||||
|
*/
|
||||||
|
public interface OnErrorListener {
|
||||||
|
/**
|
||||||
|
* Called to indicate the error occurred.
|
||||||
|
*
|
||||||
|
* @param client DrmManagerClient instance
|
||||||
|
* @param event instance which wraps error type and message
|
||||||
|
*/
|
||||||
|
public void onError(DrmManagerClient client, DrmErrorEvent event);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final int STATE_UNINITIALIZED = 0;
|
||||||
|
private static final int STATE_INITIALIZED = 1;
|
||||||
|
|
||||||
|
private static final int ACTION_INITIALIZE = 1000;
|
||||||
|
private static final int ACTION_FINALIZE = 1001;
|
||||||
|
private static final int ACTION_REMOVE_ALL_RIGHTS = 1002;
|
||||||
|
private static final int ACTION_ACQUIRE_DRM_INFO = 1003;
|
||||||
|
private static final int ACTION_PROCESS_DRM_INFO = 1004;
|
||||||
|
|
||||||
private int mUniqueId;
|
private int mUniqueId;
|
||||||
private int mNativeContext;
|
private int mNativeContext;
|
||||||
|
private Context mContext;
|
||||||
|
private InfoHandler mInfoHandler;
|
||||||
private EventHandler mEventHandler;
|
private EventHandler mEventHandler;
|
||||||
private OnInfoListener mOnInfoListener;
|
private OnInfoListener mOnInfoListener;
|
||||||
|
private OnEventListener mOnEventListener;
|
||||||
|
private OnErrorListener mOnErrorListener;
|
||||||
private int mCurrentState = STATE_UNINITIALIZED;
|
private int mCurrentState = STATE_UNINITIALIZED;
|
||||||
|
|
||||||
/**
|
|
||||||
* {@hide}
|
|
||||||
*/
|
|
||||||
public static void notify(Object thisReference, int uniqueId, int infoType, String message) {
|
|
||||||
DrmManagerClient instance = (DrmManagerClient)((WeakReference)thisReference).get();
|
|
||||||
|
|
||||||
if (null != instance && null != instance.mEventHandler) {
|
|
||||||
Message m = instance.mEventHandler.obtainMessage(
|
|
||||||
EventHandler.INFO_EVENT_TYPE, uniqueId, infoType, message);
|
|
||||||
instance.mEventHandler.sendMessage(m);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class EventHandler extends Handler {
|
private class EventHandler extends Handler {
|
||||||
public static final int INFO_EVENT_TYPE = 1;
|
|
||||||
|
|
||||||
public EventHandler(Looper looper) {
|
public EventHandler(Looper looper) {
|
||||||
super(looper);
|
super(looper);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
|
DrmEvent event = null;
|
||||||
|
DrmErrorEvent error = null;
|
||||||
|
HashMap<String, Object> attributes = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
switch(msg.what) {
|
||||||
|
case ACTION_INITIALIZE: {
|
||||||
|
if (ERROR_NONE == _loadPlugIns(mUniqueId, msg.obj)) {
|
||||||
|
mCurrentState = STATE_INITIALIZED;
|
||||||
|
event = new DrmEvent(mUniqueId, DrmEvent.TYPE_INITIALIZED, null);
|
||||||
|
} else {
|
||||||
|
error = new DrmErrorEvent(mUniqueId,
|
||||||
|
DrmErrorEvent.TYPE_INITIALIZE_FAILED, null);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ACTION_ACQUIRE_DRM_INFO: {
|
||||||
|
final DrmInfoRequest request = (DrmInfoRequest) msg.obj;
|
||||||
|
DrmInfo drmInfo = _acquireDrmInfo(mUniqueId, request);
|
||||||
|
if (null != drmInfo) {
|
||||||
|
attributes.put(DrmEvent.DRM_INFO_OBJECT, drmInfo);
|
||||||
|
event = new DrmEvent(mUniqueId, DrmEvent.TYPE_DRM_INFO_ACQUIRED, null);
|
||||||
|
} else {
|
||||||
|
error = new DrmErrorEvent(mUniqueId,
|
||||||
|
DrmErrorEvent.TYPE_DRM_INFO_ACQUISITION_FAILED, null);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ACTION_PROCESS_DRM_INFO: {
|
||||||
|
final DrmInfo drmInfo = (DrmInfo) msg.obj;
|
||||||
|
DrmInfoStatus status = _processDrmInfo(mUniqueId, drmInfo);
|
||||||
|
if (null != status && DrmInfoStatus.STATUS_OK == status.statusCode) {
|
||||||
|
attributes.put(DrmEvent.DRM_INFO_STATUS_OBJECT, status);
|
||||||
|
event = new DrmEvent(mUniqueId, getEventType(drmInfo.getInfoType()), null);
|
||||||
|
} else {
|
||||||
|
error = new DrmErrorEvent(mUniqueId,
|
||||||
|
getErrorType(drmInfo.getInfoType()), null);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ACTION_REMOVE_ALL_RIGHTS: {
|
||||||
|
if (ERROR_NONE == _removeAllRights(mUniqueId)) {
|
||||||
|
event = new DrmEvent(mUniqueId, DrmEvent.TYPE_ALL_RIGHTS_REMOVED, null);
|
||||||
|
} else {
|
||||||
|
error = new DrmErrorEvent(mUniqueId,
|
||||||
|
DrmErrorEvent.TYPE_REMOVE_ALL_RIGHTS_FAILED, null);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ACTION_FINALIZE: {
|
||||||
|
if (ERROR_NONE == _unloadPlugIns(mUniqueId)) {
|
||||||
|
mCurrentState = STATE_UNINITIALIZED;
|
||||||
|
event = new DrmEvent(mUniqueId, DrmEvent.TYPE_FINALIZED, null);
|
||||||
|
} else {
|
||||||
|
error = new DrmErrorEvent(mUniqueId,
|
||||||
|
DrmErrorEvent.TYPE_FINALIZE_FAILED, null);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
Log.e(TAG, "Unknown message type " + msg.what);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (null != mOnEventListener && null != event) {
|
||||||
|
mOnEventListener.onEvent(DrmManagerClient.this, event, attributes);
|
||||||
|
}
|
||||||
|
if (null != mOnErrorListener && null != error) {
|
||||||
|
mOnErrorListener.onError(DrmManagerClient.this, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@hide}
|
||||||
|
*/
|
||||||
|
public static void notify(
|
||||||
|
Object thisReference, int uniqueId, int infoType, String message) {
|
||||||
|
DrmManagerClient instance = (DrmManagerClient)((WeakReference)thisReference).get();
|
||||||
|
|
||||||
|
if (null != instance && null != instance.mInfoHandler) {
|
||||||
|
Message m = instance.mInfoHandler.obtainMessage(
|
||||||
|
InfoHandler.INFO_EVENT_TYPE, uniqueId, infoType, message);
|
||||||
|
instance.mInfoHandler.sendMessage(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class InfoHandler extends Handler {
|
||||||
|
public static final int INFO_EVENT_TYPE = 1;
|
||||||
|
|
||||||
|
public InfoHandler(Looper looper) {
|
||||||
|
super(looper);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
DrmInfoEvent event = null;
|
||||||
|
DrmErrorEvent error = null;
|
||||||
|
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case EventHandler.INFO_EVENT_TYPE:
|
case InfoHandler.INFO_EVENT_TYPE:
|
||||||
int uniqueId = msg.arg1;
|
int uniqueId = msg.arg1;
|
||||||
int infoType = msg.arg2;
|
int infoType = msg.arg2;
|
||||||
String message = msg.obj.toString();
|
String message = msg.obj.toString();
|
||||||
|
|
||||||
if (infoType == DrmInfoEvent.TYPE_REMOVE_RIGHTS) {
|
switch (infoType) {
|
||||||
|
case DrmInfoEvent.TYPE_REMOVE_RIGHTS: {
|
||||||
try {
|
try {
|
||||||
DrmUtils.removeFile(message);
|
DrmUtils.removeFile(message);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
event = new DrmInfoEvent(uniqueId, infoType, message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DrmInfoEvent.TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT: {
|
||||||
|
event = new DrmInfoEvent(uniqueId, infoType, message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
error = new DrmErrorEvent(uniqueId, infoType, message);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null != mOnInfoListener) {
|
if (null != mOnInfoListener && null != event) {
|
||||||
DrmInfoEvent event = new DrmInfoEvent(uniqueId, infoType, message);
|
|
||||||
mOnInfoListener.onInfo(DrmManagerClient.this, event);
|
mOnInfoListener.onInfo(DrmManagerClient.this, event);
|
||||||
}
|
}
|
||||||
|
if (null != mOnErrorListener && null != error) {
|
||||||
|
mOnErrorListener.onError(DrmManagerClient.this, error);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
Log.e(TAG, "Unknown message type " + msg.what);
|
Log.e(TAG, "Unknown message type " + msg.what);
|
||||||
@@ -118,31 +266,58 @@ public class DrmManagerClient {
|
|||||||
* @param context context of the caller
|
* @param context context of the caller
|
||||||
*/
|
*/
|
||||||
public DrmManagerClient(Context context) {
|
public DrmManagerClient(Context context) {
|
||||||
|
mContext = context;
|
||||||
Looper looper;
|
Looper looper;
|
||||||
|
|
||||||
if (null != (looper = Looper.myLooper())) {
|
if (null != (looper = Looper.myLooper())) {
|
||||||
mEventHandler = new EventHandler(looper);
|
mInfoHandler = new InfoHandler(looper);
|
||||||
} else if (null != (looper = Looper.getMainLooper())) {
|
} else if (null != (looper = Looper.getMainLooper())) {
|
||||||
mEventHandler = new EventHandler(looper);
|
mInfoHandler = new InfoHandler(looper);
|
||||||
} else {
|
} else {
|
||||||
mEventHandler = null;
|
mInfoHandler = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HandlerThread thread = new HandlerThread("DrmManagerClient.EventHandler");
|
||||||
|
thread.start();
|
||||||
|
mEventHandler = new EventHandler(thread.getLooper());
|
||||||
|
|
||||||
// save the unique id
|
// save the unique id
|
||||||
mUniqueId = hashCode();
|
mUniqueId = hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a callback to be invoked when the caller required to receive
|
* Register a callback to be invoked when the caller required to receive
|
||||||
* necessary information
|
* supplementary information.
|
||||||
*
|
*
|
||||||
* @param infoListener
|
* @param infoListener
|
||||||
*/
|
*/
|
||||||
public void setOnInfoListener(OnInfoListener infoListener) {
|
public synchronized void setOnInfoListener(OnInfoListener infoListener) {
|
||||||
synchronized(this) {
|
if (null != infoListener) {
|
||||||
if (null != infoListener) {
|
mOnInfoListener = infoListener;
|
||||||
mOnInfoListener = infoListener;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a callback to be invoked when the caller required to receive
|
||||||
|
* the result of asynchronous APIs.
|
||||||
|
*
|
||||||
|
* @param eventListener
|
||||||
|
*/
|
||||||
|
public synchronized void setOnEventListener(OnEventListener eventListener) {
|
||||||
|
if (null != eventListener) {
|
||||||
|
mOnEventListener = eventListener;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a callback to be invoked when the caller required to receive
|
||||||
|
* error result of asynchronous APIs.
|
||||||
|
*
|
||||||
|
* @param errorListener
|
||||||
|
*/
|
||||||
|
public synchronized void setOnErrorListener(OnErrorListener errorListener) {
|
||||||
|
if (null != errorListener) {
|
||||||
|
mOnErrorListener = errorListener;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,25 +325,43 @@ public class DrmManagerClient {
|
|||||||
* Initializes DrmFramework, which loads all available plug-ins
|
* Initializes DrmFramework, which loads all available plug-ins
|
||||||
* in the default plug-in directory path
|
* in the default plug-in directory path
|
||||||
*
|
*
|
||||||
|
* @return
|
||||||
|
* ERROR_NONE for success
|
||||||
|
* ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
public void loadPlugIns() {
|
public int loadPlugIns() {
|
||||||
if (getState() == STATE_UNINITIALIZED) {
|
int result = ERROR_UNKNOWN;
|
||||||
_loadPlugIns(mUniqueId, new WeakReference<DrmManagerClient>(this));
|
if (STATE_UNINITIALIZED == getState()) {
|
||||||
|
if (null != mEventHandler) {
|
||||||
mCurrentState = STATE_INITIALIZED;
|
Message msg = mEventHandler.obtainMessage(
|
||||||
|
ACTION_INITIALIZE, new WeakReference<DrmManagerClient>(this));
|
||||||
|
result = (mEventHandler.sendMessage(msg)) ? ERROR_NONE : result;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result = ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finalize DrmFramework, which release resources associated with each plug-in
|
* Finalize DrmFramework, which release resources associated with each plug-in
|
||||||
* and unload all plug-ins.
|
* and unload all plug-ins.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* ERROR_NONE for success
|
||||||
|
* ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
public void unloadPlugIns() {
|
public int unloadPlugIns() {
|
||||||
if (getState() == STATE_INITIALIZED) {
|
int result = ERROR_UNKNOWN;
|
||||||
_unloadPlugIns(mUniqueId);
|
if (STATE_INITIALIZED == getState()) {
|
||||||
|
if (null != mEventHandler) {
|
||||||
mCurrentState = STATE_UNINITIALIZED;
|
Message msg = mEventHandler.obtainMessage(ACTION_FINALIZE);
|
||||||
|
result = (mEventHandler.sendMessage(msg)) ? ERROR_NONE : result;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result = ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -177,7 +370,7 @@ public class DrmManagerClient {
|
|||||||
* @return Array of DrmEngine plug-in strings
|
* @return Array of DrmEngine plug-in strings
|
||||||
*/
|
*/
|
||||||
public String[] getAvailableDrmEngines() {
|
public String[] getAvailableDrmEngines() {
|
||||||
if (getState() == STATE_UNINITIALIZED) {
|
if (STATE_UNINITIALIZED == getState()) {
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
throw new IllegalStateException("Not Initialized yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,12 +396,24 @@ public class DrmManagerClient {
|
|||||||
public ContentValues getConstraints(String path, int action) {
|
public ContentValues getConstraints(String path, int action) {
|
||||||
if (null == path || path.equals("") || !DrmStore.Action.isValid(action)) {
|
if (null == path || path.equals("") || !DrmStore.Action.isValid(action)) {
|
||||||
throw new IllegalArgumentException("Given usage or path is invalid/null");
|
throw new IllegalArgumentException("Given usage or path is invalid/null");
|
||||||
} else if (getState() == STATE_UNINITIALIZED) {
|
} else if (STATE_UNINITIALIZED == getState()) {
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
throw new IllegalStateException("Not Initialized yet");
|
||||||
}
|
}
|
||||||
return _getConstraints(mUniqueId, path, action);
|
return _getConstraints(mUniqueId, path, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get constraints information evaluated from DRM content
|
||||||
|
*
|
||||||
|
* @param uri The Content URI of the data
|
||||||
|
* @param action Actions defined in {@link DrmStore.Action}
|
||||||
|
* @return ContentValues instance in which constraints key-value pairs are embedded
|
||||||
|
* or null in case of failure
|
||||||
|
*/
|
||||||
|
public ContentValues getConstraints(Uri uri, int action) {
|
||||||
|
return getConstraints(convertUriToPath(uri), action);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save DRM rights to specified rights path
|
* Save DRM rights to specified rights path
|
||||||
* and make association with content path.
|
* and make association with content path.
|
||||||
@@ -218,20 +423,22 @@ public class DrmManagerClient {
|
|||||||
* @param drmRights DrmRights to be saved
|
* @param drmRights DrmRights to be saved
|
||||||
* @param rightsPath File path where rights to be saved
|
* @param rightsPath File path where rights to be saved
|
||||||
* @param contentPath File path where content was saved
|
* @param contentPath File path where content was saved
|
||||||
|
* @return
|
||||||
|
* ERROR_NONE for success
|
||||||
|
* ERROR_UNKNOWN for failure
|
||||||
* @throws IOException if failed to save rights information in the given path
|
* @throws IOException if failed to save rights information in the given path
|
||||||
*/
|
*/
|
||||||
public void saveRights(
|
public int saveRights(
|
||||||
DrmRights drmRights, String rightsPath, String contentPath) throws IOException {
|
DrmRights drmRights, String rightsPath, String contentPath) throws IOException {
|
||||||
if (null == drmRights || !drmRights.isValid()
|
if (null == drmRights || !drmRights.isValid()) {
|
||||||
|| null == contentPath || contentPath.equals("")) {
|
|
||||||
throw new IllegalArgumentException("Given drmRights or contentPath is not valid");
|
throw new IllegalArgumentException("Given drmRights or contentPath is not valid");
|
||||||
} else if (getState() == STATE_UNINITIALIZED) {
|
} else if (STATE_UNINITIALIZED == getState()) {
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
throw new IllegalStateException("Not Initialized yet");
|
||||||
}
|
}
|
||||||
if (null != rightsPath && !rightsPath.equals("")) {
|
if (null != rightsPath && !rightsPath.equals("")) {
|
||||||
DrmUtils.writeToFile(rightsPath, drmRights.getData());
|
DrmUtils.writeToFile(rightsPath, drmRights.getData());
|
||||||
}
|
}
|
||||||
_saveRights(mUniqueId, drmRights, rightsPath, contentPath);
|
return _saveRights(mUniqueId, drmRights, rightsPath, contentPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -244,7 +451,7 @@ public class DrmManagerClient {
|
|||||||
if (null == engineFilePath || engineFilePath.equals("")) {
|
if (null == engineFilePath || engineFilePath.equals("")) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Given engineFilePath: "+ engineFilePath + "is not valid");
|
"Given engineFilePath: "+ engineFilePath + "is not valid");
|
||||||
} else if (getState() == STATE_UNINITIALIZED) {
|
} else if (STATE_UNINITIALIZED == getState()) {
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
throw new IllegalStateException("Not Initialized yet");
|
||||||
}
|
}
|
||||||
_installDrmEngine(mUniqueId, engineFilePath);
|
_installDrmEngine(mUniqueId, engineFilePath);
|
||||||
@@ -256,47 +463,78 @@ public class DrmManagerClient {
|
|||||||
* @param path Path of the content to be handled
|
* @param path Path of the content to be handled
|
||||||
* @param mimeType Mimetype of the object to be handled
|
* @param mimeType Mimetype of the object to be handled
|
||||||
* @return
|
* @return
|
||||||
* true - if the given mimeType or path can be handled.
|
* true - if the given mimeType or path can be handled
|
||||||
* false - cannot be handled. false will be returned in case
|
* false - cannot be handled. false will be return in case
|
||||||
* the state is uninitialized
|
* the state is uninitialized
|
||||||
*/
|
*/
|
||||||
public boolean canHandle(String path, String mimeType) {
|
public boolean canHandle(String path, String mimeType) {
|
||||||
if ((null == path || path.equals("")) && (null == mimeType || mimeType.equals(""))) {
|
if ((null == path || path.equals("")) && (null == mimeType || mimeType.equals(""))) {
|
||||||
throw new IllegalArgumentException("Path or the mimetype should be non null");
|
throw new IllegalArgumentException("Path or the mimetype should be non null");
|
||||||
} else if (getState() == STATE_UNINITIALIZED) {
|
} else if (STATE_UNINITIALIZED == getState()) {
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
throw new IllegalStateException("Not Initialized yet");
|
||||||
}
|
}
|
||||||
return _canHandle(mUniqueId, path, mimeType);
|
return _canHandle(mUniqueId, path, mimeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the given mimetype or uri can be handled.
|
||||||
|
*
|
||||||
|
* @param uri The content URI of the data
|
||||||
|
* @param mimeType Mimetype of the object to be handled
|
||||||
|
* @return
|
||||||
|
* true - if the given mimeType or path can be handled
|
||||||
|
* false - cannot be handled. false will be return in case
|
||||||
|
* the state is uninitialized
|
||||||
|
*/
|
||||||
|
public boolean canHandle(Uri uri, String mimeType) {
|
||||||
|
if ((null == uri || Uri.EMPTY == uri) && (null == mimeType || mimeType.equals(""))) {
|
||||||
|
throw new IllegalArgumentException("Uri or the mimetype should be non null");
|
||||||
|
}
|
||||||
|
return canHandle(convertUriToPath(uri), mimeType);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes given drm information based on its type
|
* Executes given drm information based on its type
|
||||||
*
|
*
|
||||||
* @param drmInfo Information needs to be processed
|
* @param drmInfo Information needs to be processed
|
||||||
* @return DrmInfoStatus Instance as a result of processing given input
|
* @return
|
||||||
|
* ERROR_NONE for success
|
||||||
|
* ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
public DrmInfoStatus processDrmInfo(DrmInfo drmInfo) {
|
public int processDrmInfo(DrmInfo drmInfo) {
|
||||||
if (null == drmInfo || !drmInfo.isValid()) {
|
if (null == drmInfo || !drmInfo.isValid()) {
|
||||||
throw new IllegalArgumentException("Given drmInfo is invalid/null");
|
throw new IllegalArgumentException("Given drmInfo is invalid/null");
|
||||||
} else if (getState() == STATE_UNINITIALIZED) {
|
} else if (STATE_UNINITIALIZED == getState()) {
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
throw new IllegalStateException("Not Initialized yet");
|
||||||
}
|
}
|
||||||
return _processDrmInfo(mUniqueId, drmInfo);
|
int result = ERROR_UNKNOWN;
|
||||||
|
if (null != mEventHandler) {
|
||||||
|
Message msg = mEventHandler.obtainMessage(ACTION_PROCESS_DRM_INFO, drmInfo);
|
||||||
|
result = (mEventHandler.sendMessage(msg)) ? ERROR_NONE : result;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves necessary information for register, unregister or rights acquisition.
|
* Retrieves necessary information for register, unregister or rights acquisition.
|
||||||
*
|
*
|
||||||
* @param drmInfoRequest Request information to retrieve drmInfo
|
* @param drmInfoRequest Request information to retrieve drmInfo
|
||||||
* @return DrmInfo Instance as a result of processing given input
|
* @return
|
||||||
|
* ERROR_NONE for success
|
||||||
|
* ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
public DrmInfo acquireDrmInfo(DrmInfoRequest drmInfoRequest) {
|
public int acquireDrmInfo(DrmInfoRequest drmInfoRequest) {
|
||||||
if (null == drmInfoRequest || !drmInfoRequest.isValid()) {
|
if (null == drmInfoRequest || !drmInfoRequest.isValid()) {
|
||||||
throw new IllegalArgumentException("Given drmInfoRequest is invalid/null");
|
throw new IllegalArgumentException("Given drmInfoRequest is invalid/null");
|
||||||
} else if (getState() == STATE_UNINITIALIZED) {
|
} else if (STATE_UNINITIALIZED == getState()) {
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
throw new IllegalStateException("Not Initialized yet");
|
||||||
}
|
}
|
||||||
return _acquireDrmInfo(mUniqueId, drmInfoRequest);
|
int result = ERROR_UNKNOWN;
|
||||||
|
if (null != mEventHandler) {
|
||||||
|
Message msg = mEventHandler.obtainMessage(ACTION_ACQUIRE_DRM_INFO, drmInfoRequest);
|
||||||
|
result = (mEventHandler.sendMessage(msg)) ? ERROR_NONE : result;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -312,12 +550,36 @@ public class DrmManagerClient {
|
|||||||
public int getDrmObjectType(String path, String mimeType) {
|
public int getDrmObjectType(String path, String mimeType) {
|
||||||
if ((null == path || path.equals("")) && (null == mimeType || mimeType.equals(""))) {
|
if ((null == path || path.equals("")) && (null == mimeType || mimeType.equals(""))) {
|
||||||
throw new IllegalArgumentException("Path or the mimetype should be non null");
|
throw new IllegalArgumentException("Path or the mimetype should be non null");
|
||||||
} else if (getState() == STATE_UNINITIALIZED) {
|
} else if (STATE_UNINITIALIZED == getState()) {
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
throw new IllegalStateException("Not Initialized yet");
|
||||||
}
|
}
|
||||||
return _getDrmObjectType(mUniqueId, path, mimeType);
|
return _getDrmObjectType(mUniqueId, path, mimeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the type of the protected object (content, rights, etc..)
|
||||||
|
* using specified uri or mimetype. At least one parameter should be non null
|
||||||
|
* to retrieve DRM object type
|
||||||
|
*
|
||||||
|
* @param uri The content URI of the data
|
||||||
|
* @param mimeType Mimetype of the content or null.
|
||||||
|
* @return Type of the DRM content.
|
||||||
|
* @see DrmStore.DrmObjectType
|
||||||
|
*/
|
||||||
|
public int getDrmObjectType(Uri uri, String mimeType) {
|
||||||
|
if ((null == uri || Uri.EMPTY == uri) && (null == mimeType || mimeType.equals(""))) {
|
||||||
|
throw new IllegalArgumentException("Uri or the mimetype should be non null");
|
||||||
|
}
|
||||||
|
String path = "";
|
||||||
|
try {
|
||||||
|
path = convertUriToPath(uri);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Even uri is invalid the mimetype shall be valid, so allow to proceed further.
|
||||||
|
Log.w(TAG, "Given Uri could not be found in media store");
|
||||||
|
}
|
||||||
|
return getDrmObjectType(path, mimeType);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the mime type embedded inside the original content
|
* Retrieves the mime type embedded inside the original content
|
||||||
*
|
*
|
||||||
@@ -327,12 +589,25 @@ public class DrmManagerClient {
|
|||||||
public String getOriginalMimeType(String path) {
|
public String getOriginalMimeType(String path) {
|
||||||
if (null == path || path.equals("")) {
|
if (null == path || path.equals("")) {
|
||||||
throw new IllegalArgumentException("Given path should be non null");
|
throw new IllegalArgumentException("Given path should be non null");
|
||||||
} else if (getState() == STATE_UNINITIALIZED) {
|
} else if (STATE_UNINITIALIZED == getState()) {
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
throw new IllegalStateException("Not Initialized yet");
|
||||||
}
|
}
|
||||||
return _getOriginalMimeType(mUniqueId, path);
|
return _getOriginalMimeType(mUniqueId, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the mime type embedded inside the original content
|
||||||
|
*
|
||||||
|
* @param uri The content URI of the data
|
||||||
|
* @return Mimetype of the original content, such as "video/mpeg"
|
||||||
|
*/
|
||||||
|
public String getOriginalMimeType(Uri uri) {
|
||||||
|
if (null == uri || Uri.EMPTY == uri) {
|
||||||
|
throw new IllegalArgumentException("Given uri is not valid");
|
||||||
|
}
|
||||||
|
return getOriginalMimeType(convertUriToPath(uri));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the given content has valid rights or not
|
* Check whether the given content has valid rights or not
|
||||||
*
|
*
|
||||||
@@ -344,6 +619,20 @@ public class DrmManagerClient {
|
|||||||
return checkRightsStatus(path, DrmStore.Action.DEFAULT);
|
return checkRightsStatus(path, DrmStore.Action.DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the given content has valid rights or not
|
||||||
|
*
|
||||||
|
* @param uri The content URI of the data
|
||||||
|
* @return Status of the rights for the protected content
|
||||||
|
* @see DrmStore.RightsStatus
|
||||||
|
*/
|
||||||
|
public int checkRightsStatus(Uri uri) {
|
||||||
|
if (null == uri || Uri.EMPTY == uri) {
|
||||||
|
throw new IllegalArgumentException("Given uri is not valid");
|
||||||
|
}
|
||||||
|
return checkRightsStatus(convertUriToPath(uri));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the given content has valid rights or not for specified action.
|
* Check whether the given content has valid rights or not for specified action.
|
||||||
*
|
*
|
||||||
@@ -355,35 +644,77 @@ public class DrmManagerClient {
|
|||||||
public int checkRightsStatus(String path, int action) {
|
public int checkRightsStatus(String path, int action) {
|
||||||
if (null == path || path.equals("") || !DrmStore.Action.isValid(action)) {
|
if (null == path || path.equals("") || !DrmStore.Action.isValid(action)) {
|
||||||
throw new IllegalArgumentException("Given path or action is not valid");
|
throw new IllegalArgumentException("Given path or action is not valid");
|
||||||
} else if (getState() == STATE_UNINITIALIZED) {
|
} else if (STATE_UNINITIALIZED == getState()) {
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
throw new IllegalStateException("Not Initialized yet");
|
||||||
}
|
}
|
||||||
return _checkRightsStatus(mUniqueId, path, action);
|
return _checkRightsStatus(mUniqueId, path, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the given content has valid rights or not for specified action.
|
||||||
|
*
|
||||||
|
* @param uri The content URI of the data
|
||||||
|
* @param action Action to perform
|
||||||
|
* @return Status of the rights for the protected content
|
||||||
|
* @see DrmStore.RightsStatus
|
||||||
|
*/
|
||||||
|
public int checkRightsStatus(Uri uri, int action) {
|
||||||
|
if (null == uri || Uri.EMPTY == uri) {
|
||||||
|
throw new IllegalArgumentException("Given uri is not valid");
|
||||||
|
}
|
||||||
|
return checkRightsStatus(convertUriToPath(uri), action);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the rights associated with the given protected content
|
* Removes the rights associated with the given protected content
|
||||||
*
|
*
|
||||||
* @param path Path of the protected content
|
* @param path Path of the protected content
|
||||||
|
* @return
|
||||||
|
* ERROR_NONE for success
|
||||||
|
* ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
public void removeRights(String path) {
|
public int removeRights(String path) {
|
||||||
if (null == path || path.equals("")) {
|
if (null == path || path.equals("")) {
|
||||||
throw new IllegalArgumentException("Given path should be non null");
|
throw new IllegalArgumentException("Given path should be non null");
|
||||||
} else if (getState() == STATE_UNINITIALIZED) {
|
} else if (STATE_UNINITIALIZED == getState()) {
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
throw new IllegalStateException("Not Initialized yet");
|
||||||
}
|
}
|
||||||
_removeRights(mUniqueId, path);
|
return _removeRights(mUniqueId, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the rights associated with the given protected content
|
||||||
|
*
|
||||||
|
* @param uri The content URI of the data
|
||||||
|
* @return
|
||||||
|
* ERROR_NONE for success
|
||||||
|
* ERROR_UNKNOWN for failure
|
||||||
|
*/
|
||||||
|
public int removeRights(Uri uri) {
|
||||||
|
if (null == uri || Uri.EMPTY == uri) {
|
||||||
|
throw new IllegalArgumentException("Given uri is not valid");
|
||||||
|
}
|
||||||
|
return removeRights(convertUriToPath(uri));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all the rights information of every plug-in associated with
|
* Removes all the rights information of every plug-in associated with
|
||||||
* DRM framework. Will be used in master reset
|
* DRM framework. Will be used in master reset
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* ERROR_NONE for success
|
||||||
|
* ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
public void removeAllRights() {
|
public int removeAllRights() {
|
||||||
if (getState() == STATE_UNINITIALIZED) {
|
if (STATE_UNINITIALIZED == getState()) {
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
throw new IllegalStateException("Not Initialized yet");
|
||||||
}
|
}
|
||||||
_removeAllRights(mUniqueId);
|
int result = ERROR_UNKNOWN;
|
||||||
|
if (null != mEventHandler) {
|
||||||
|
Message msg = mEventHandler.obtainMessage(ACTION_REMOVE_ALL_RIGHTS);
|
||||||
|
result = (mEventHandler.sendMessage(msg)) ? ERROR_NONE : result;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -398,7 +729,7 @@ public class DrmManagerClient {
|
|||||||
public int openConvertSession(String mimeType) {
|
public int openConvertSession(String mimeType) {
|
||||||
if (null == mimeType || mimeType.equals("")) {
|
if (null == mimeType || mimeType.equals("")) {
|
||||||
throw new IllegalArgumentException("Path or the mimeType should be non null");
|
throw new IllegalArgumentException("Path or the mimeType should be non null");
|
||||||
} else if (getState() == STATE_UNINITIALIZED) {
|
} else if (STATE_UNINITIALIZED == getState()) {
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
throw new IllegalStateException("Not Initialized yet");
|
||||||
}
|
}
|
||||||
return _openConvertSession(mUniqueId, mimeType);
|
return _openConvertSession(mUniqueId, mimeType);
|
||||||
@@ -419,7 +750,7 @@ public class DrmManagerClient {
|
|||||||
public DrmConvertedStatus convertData(int convertId, byte[] inputData) {
|
public DrmConvertedStatus convertData(int convertId, byte[] inputData) {
|
||||||
if (null == inputData || 0 >= inputData.length) {
|
if (null == inputData || 0 >= inputData.length) {
|
||||||
throw new IllegalArgumentException("Given inputData should be non null");
|
throw new IllegalArgumentException("Given inputData should be non null");
|
||||||
} else if (getState() == STATE_UNINITIALIZED) {
|
} else if (STATE_UNINITIALIZED == getState()) {
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
throw new IllegalStateException("Not Initialized yet");
|
||||||
}
|
}
|
||||||
return _convertData(mUniqueId, convertId, inputData);
|
return _convertData(mUniqueId, convertId, inputData);
|
||||||
@@ -438,7 +769,7 @@ public class DrmManagerClient {
|
|||||||
* the application on which offset these signature data should be appended.
|
* the application on which offset these signature data should be appended.
|
||||||
*/
|
*/
|
||||||
public DrmConvertedStatus closeConvertSession(int convertId) {
|
public DrmConvertedStatus closeConvertSession(int convertId) {
|
||||||
if (getState() == STATE_UNINITIALIZED) {
|
if (STATE_UNINITIALIZED == getState()) {
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
throw new IllegalStateException("Not Initialized yet");
|
||||||
}
|
}
|
||||||
return _closeConvertSession(mUniqueId, convertId);
|
return _closeConvertSession(mUniqueId, convertId);
|
||||||
@@ -448,10 +779,68 @@ public class DrmManagerClient {
|
|||||||
return mCurrentState;
|
return mCurrentState;
|
||||||
}
|
}
|
||||||
|
|
||||||
// private native interfaces
|
private int getEventType(int infoType) {
|
||||||
private native void _loadPlugIns(int uniqueId, Object weak_this);
|
int eventType = -1;
|
||||||
|
|
||||||
private native void _unloadPlugIns(int uniqueId);
|
switch (infoType) {
|
||||||
|
case DrmInfoRequest.TYPE_REGISTRATION_INFO:
|
||||||
|
eventType = DrmEvent.TYPE_REGISTERED;
|
||||||
|
break;
|
||||||
|
case DrmInfoRequest.TYPE_UNREGISTRATION_INFO:
|
||||||
|
eventType = DrmEvent.TYPE_UNREGISTERED;
|
||||||
|
break;
|
||||||
|
case DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_INFO:
|
||||||
|
eventType = DrmEvent.TYPE_RIGHTS_ACQUIRED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return eventType;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getErrorType(int infoType) {
|
||||||
|
int error = -1;
|
||||||
|
|
||||||
|
switch (infoType) {
|
||||||
|
case DrmInfoRequest.TYPE_REGISTRATION_INFO:
|
||||||
|
error = DrmErrorEvent.TYPE_REGISTRATION_FAILED;
|
||||||
|
break;
|
||||||
|
case DrmInfoRequest.TYPE_UNREGISTRATION_INFO:
|
||||||
|
error = DrmErrorEvent.TYPE_UNREGISTRATION_FAILED;
|
||||||
|
break;
|
||||||
|
case DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_INFO:
|
||||||
|
error = DrmErrorEvent.TYPE_RIGHTS_ACQUISITION_FAILED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method expects uri in the following format
|
||||||
|
* content://media/<table_name>/<row_index> (or)
|
||||||
|
* file://sdcard/test.mp4
|
||||||
|
*
|
||||||
|
* Here <table_name> shall be "video" or "audio" or "images"
|
||||||
|
* <row_index> the index of the content in given table
|
||||||
|
*/
|
||||||
|
private String convertUriToPath(Uri uri) {
|
||||||
|
String scheme = uri.getScheme();
|
||||||
|
if (null == scheme || scheme.equals("file")) {
|
||||||
|
return uri.getPath();
|
||||||
|
}
|
||||||
|
String[] projection = new String[] {MediaStore.MediaColumns.DATA};
|
||||||
|
Cursor cursor = mContext.getContentResolver().query(uri, projection, null, null, null);
|
||||||
|
if (null == cursor || 0 == cursor.getCount() || !cursor.moveToFirst()) {
|
||||||
|
throw new IllegalArgumentException("Given Uri could not be found in media store");
|
||||||
|
}
|
||||||
|
int pathIndex = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
|
||||||
|
String path = cursor.getString(pathIndex);
|
||||||
|
cursor.close();
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
// private native interfaces
|
||||||
|
private native int _loadPlugIns(int uniqueId, Object weak_this);
|
||||||
|
|
||||||
|
private native int _unloadPlugIns(int uniqueId);
|
||||||
|
|
||||||
private native void _installDrmEngine(int uniqueId, String engineFilepath);
|
private native void _installDrmEngine(int uniqueId, String engineFilepath);
|
||||||
|
|
||||||
@@ -463,7 +852,7 @@ public class DrmManagerClient {
|
|||||||
|
|
||||||
private native DrmInfo _acquireDrmInfo(int uniqueId, DrmInfoRequest drmInfoRequest);
|
private native DrmInfo _acquireDrmInfo(int uniqueId, DrmInfoRequest drmInfoRequest);
|
||||||
|
|
||||||
private native void _saveRights(
|
private native int _saveRights(
|
||||||
int uniqueId, DrmRights drmRights, String rightsPath, String contentPath);
|
int uniqueId, DrmRights drmRights, String rightsPath, String contentPath);
|
||||||
|
|
||||||
private native int _getDrmObjectType(int uniqueId, String path, String mimeType);
|
private native int _getDrmObjectType(int uniqueId, String path, String mimeType);
|
||||||
@@ -472,13 +861,14 @@ public class DrmManagerClient {
|
|||||||
|
|
||||||
private native int _checkRightsStatus(int uniqueId, String path, int action);
|
private native int _checkRightsStatus(int uniqueId, String path, int action);
|
||||||
|
|
||||||
private native void _removeRights(int uniqueId, String path);
|
private native int _removeRights(int uniqueId, String path);
|
||||||
|
|
||||||
private native void _removeAllRights(int uniqueId);
|
private native int _removeAllRights(int uniqueId);
|
||||||
|
|
||||||
private native int _openConvertSession(int uniqueId, String mimeType);
|
private native int _openConvertSession(int uniqueId, String mimeType);
|
||||||
|
|
||||||
private native DrmConvertedStatus _convertData(int uniqueId, int convertId, byte[] inputData);
|
private native DrmConvertedStatus _convertData(
|
||||||
|
int uniqueId, int convertId, byte[] inputData);
|
||||||
|
|
||||||
private native DrmConvertedStatus _closeConvertSession(int uniqueId, int convertId);
|
private native DrmConvertedStatus _closeConvertSession(int uniqueId, int convertId);
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LOG_NDEBUG 0
|
//#define LOG_NDEBUG 0
|
||||||
#define LOG_TAG "DrmManager-JNI"
|
#define LOG_TAG "DrmManager-JNI"
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ String8 Utility::getStringValue(JNIEnv* env, jobject object, const char* fieldNa
|
|||||||
env->ReleaseStringUTFChars(valueString, bytes);
|
env->ReleaseStringUTFChars(valueString, bytes);
|
||||||
delete [] data; data = NULL;
|
delete [] data; data = NULL;
|
||||||
} else {
|
} else {
|
||||||
LOGD("Failed to retrieve the data from the field %s", fieldName);
|
LOGV("Failed to retrieve the data from the field %s", fieldName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dataString;
|
return dataString;
|
||||||
@@ -223,7 +223,7 @@ static sp<DrmManagerClientImpl> getDrmManagerClientImpl(JNIEnv* env, jobject thi
|
|||||||
return sp<DrmManagerClientImpl>(client);
|
return sp<DrmManagerClientImpl>(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void android_drm_DrmManagerClient_loadPlugIns(
|
static jint android_drm_DrmManagerClient_loadPlugIns(
|
||||||
JNIEnv* env, jobject thiz, jint uniqueId, jobject weak_thiz) {
|
JNIEnv* env, jobject thiz, jint uniqueId, jobject weak_thiz) {
|
||||||
LOGV("load plugins - Enter");
|
LOGV("load plugins - Enter");
|
||||||
|
|
||||||
@@ -235,23 +235,26 @@ static void android_drm_DrmManagerClient_loadPlugIns(
|
|||||||
|
|
||||||
setDrmManagerClientImpl(env, thiz, drmManager);
|
setDrmManagerClientImpl(env, thiz, drmManager);
|
||||||
|
|
||||||
getDrmManagerClientImpl(env, thiz)->loadPlugIns(uniqueId);
|
|
||||||
LOGV("load plugins - Exit");
|
LOGV("load plugins - Exit");
|
||||||
|
return getDrmManagerClientImpl(env, thiz)->loadPlugIns(uniqueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void android_drm_DrmManagerClient_unloadPlugIns(JNIEnv* env, jobject thiz, jint uniqueId) {
|
static jint android_drm_DrmManagerClient_unloadPlugIns(JNIEnv* env, jobject thiz, jint uniqueId) {
|
||||||
LOGV("unload plugins - Enter");
|
LOGV("unload plugins - Enter");
|
||||||
sp<DrmManagerClientImpl> client = getDrmManagerClientImpl(env, thiz);
|
sp<DrmManagerClientImpl> client = getDrmManagerClientImpl(env, thiz);
|
||||||
client->unloadPlugIns(uniqueId);
|
|
||||||
client->setOnInfoListener(uniqueId, NULL);
|
|
||||||
DrmManagerClientImpl::remove(uniqueId);
|
DrmManagerClientImpl::remove(uniqueId);
|
||||||
|
int result = client->unloadPlugIns(uniqueId);
|
||||||
|
if (DRM_NO_ERROR == result) {
|
||||||
|
client->setOnInfoListener(uniqueId, NULL);
|
||||||
|
|
||||||
sp<DrmManagerClientImpl> oldClient = setDrmManagerClientImpl(env, thiz, NULL);
|
sp<DrmManagerClientImpl> oldClient = setDrmManagerClientImpl(env, thiz, NULL);
|
||||||
if (oldClient != NULL) {
|
if (oldClient != NULL) {
|
||||||
oldClient->setOnInfoListener(uniqueId, NULL);
|
oldClient->setOnInfoListener(uniqueId, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGV("unload plugins - Exit");
|
LOGV("unload plugins - Exit");
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static jobject android_drm_DrmManagerClient_getConstraintsFromContent(
|
static jobject android_drm_DrmManagerClient_getConstraintsFromContent(
|
||||||
@@ -356,10 +359,11 @@ static void android_drm_DrmManagerClient_installDrmEngine(
|
|||||||
LOGV("installDrmEngine - Exit");
|
LOGV("installDrmEngine - Exit");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void android_drm_DrmManagerClient_saveRights(
|
static jint android_drm_DrmManagerClient_saveRights(
|
||||||
JNIEnv* env, jobject thiz, jint uniqueId,
|
JNIEnv* env, jobject thiz, jint uniqueId,
|
||||||
jobject drmRights, jstring rightsPath, jstring contentPath) {
|
jobject drmRights, jstring rightsPath, jstring contentPath) {
|
||||||
LOGV("saveRights - Enter");
|
LOGV("saveRights - Enter");
|
||||||
|
int result = DRM_ERROR_UNKNOWN;
|
||||||
int dataLength = 0;
|
int dataLength = 0;
|
||||||
char* mData = Utility::getByteArrayValue(env, drmRights, "mData", &dataLength);
|
char* mData = Utility::getByteArrayValue(env, drmRights, "mData", &dataLength);
|
||||||
|
|
||||||
@@ -368,13 +372,14 @@ static void android_drm_DrmManagerClient_saveRights(
|
|||||||
Utility::getStringValue(env, drmRights, "mMimeType"),
|
Utility::getStringValue(env, drmRights, "mMimeType"),
|
||||||
Utility::getStringValue(env, drmRights, "mAccountId"),
|
Utility::getStringValue(env, drmRights, "mAccountId"),
|
||||||
Utility::getStringValue(env, drmRights, "mSubscriptionId"));
|
Utility::getStringValue(env, drmRights, "mSubscriptionId"));
|
||||||
getDrmManagerClientImpl(env, thiz)
|
result = getDrmManagerClientImpl(env, thiz)
|
||||||
->saveRights(uniqueId, rights, Utility::getStringValue(env, rightsPath),
|
->saveRights(uniqueId, rights, Utility::getStringValue(env, rightsPath),
|
||||||
Utility::getStringValue(env, contentPath));
|
Utility::getStringValue(env, contentPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
delete mData; mData = NULL;
|
delete mData; mData = NULL;
|
||||||
LOGV("saveRights - Exit");
|
LOGV("saveRights - Exit");
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean android_drm_DrmManagerClient_canHandle(
|
static jboolean android_drm_DrmManagerClient_canHandle(
|
||||||
@@ -423,7 +428,7 @@ static jobject android_drm_DrmManagerClient_processDrmInfo(
|
|||||||
|
|
||||||
String8 keyString = Utility::getStringValue(env, key);
|
String8 keyString = Utility::getStringValue(env, key);
|
||||||
String8 valueString = Utility::getStringValue(env, valString);
|
String8 valueString = Utility::getStringValue(env, valString);
|
||||||
LOGD("Key: %s | Value: %s", keyString.string(), valueString.string());
|
LOGV("Key: %s | Value: %s", keyString.string(), valueString.string());
|
||||||
|
|
||||||
drmInfo.put(keyString, valueString);
|
drmInfo.put(keyString, valueString);
|
||||||
}
|
}
|
||||||
@@ -495,7 +500,7 @@ static jobject android_drm_DrmManagerClient_acquireDrmInfo(
|
|||||||
|
|
||||||
String8 keyString = Utility::getStringValue(env, key);
|
String8 keyString = Utility::getStringValue(env, key);
|
||||||
String8 valueString = Utility::getStringValue(env, value);
|
String8 valueString = Utility::getStringValue(env, value);
|
||||||
LOGD("Key: %s | Value: %s", keyString.string(), valueString.string());
|
LOGV("Key: %s | Value: %s", keyString.string(), valueString.string());
|
||||||
|
|
||||||
drmInfoReq.put(keyString, valueString);
|
drmInfoReq.put(keyString, valueString);
|
||||||
}
|
}
|
||||||
@@ -570,18 +575,17 @@ static jint android_drm_DrmManagerClient_checkRightsStatus(
|
|||||||
return rightsStatus;
|
return rightsStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void android_drm_DrmManagerClient_removeRights(
|
static jint android_drm_DrmManagerClient_removeRights(
|
||||||
JNIEnv* env, jobject thiz, jint uniqueId, jstring path) {
|
JNIEnv* env, jobject thiz, jint uniqueId, jstring path) {
|
||||||
LOGV("removeRights Enter");
|
LOGV("removeRights");
|
||||||
getDrmManagerClientImpl(env, thiz)->removeRights(uniqueId, Utility::getStringValue(env, path));
|
return getDrmManagerClientImpl(env, thiz)
|
||||||
LOGV("removeRights Exit");
|
->removeRights(uniqueId, Utility::getStringValue(env, path));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void android_drm_DrmManagerClient_removeAllRights(
|
static jint android_drm_DrmManagerClient_removeAllRights(
|
||||||
JNIEnv* env, jobject thiz, jint uniqueId) {
|
JNIEnv* env, jobject thiz, jint uniqueId) {
|
||||||
LOGV("removeAllRights Enter");
|
LOGV("removeAllRights");
|
||||||
getDrmManagerClientImpl(env, thiz)->removeAllRights(uniqueId);
|
return getDrmManagerClientImpl(env, thiz)->removeAllRights(uniqueId);
|
||||||
LOGV("removeAllRights Exit");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint android_drm_DrmManagerClient_openConvertSession(
|
static jint android_drm_DrmManagerClient_openConvertSession(
|
||||||
@@ -674,10 +678,10 @@ static jobject android_drm_DrmManagerClient_closeConvertSession(
|
|||||||
|
|
||||||
static JNINativeMethod nativeMethods[] = {
|
static JNINativeMethod nativeMethods[] = {
|
||||||
|
|
||||||
{"_loadPlugIns", "(ILjava/lang/Object;)V",
|
{"_loadPlugIns", "(ILjava/lang/Object;)I",
|
||||||
(void*)android_drm_DrmManagerClient_loadPlugIns},
|
(void*)android_drm_DrmManagerClient_loadPlugIns},
|
||||||
|
|
||||||
{"_unloadPlugIns", "(I)V",
|
{"_unloadPlugIns", "(I)I",
|
||||||
(void*)android_drm_DrmManagerClient_unloadPlugIns},
|
(void*)android_drm_DrmManagerClient_unloadPlugIns},
|
||||||
|
|
||||||
{"_getConstraints", "(ILjava/lang/String;I)Landroid/content/ContentValues;",
|
{"_getConstraints", "(ILjava/lang/String;I)Landroid/content/ContentValues;",
|
||||||
@@ -698,7 +702,7 @@ static JNINativeMethod nativeMethods[] = {
|
|||||||
{"_acquireDrmInfo", "(ILandroid/drm/DrmInfoRequest;)Landroid/drm/DrmInfo;",
|
{"_acquireDrmInfo", "(ILandroid/drm/DrmInfoRequest;)Landroid/drm/DrmInfo;",
|
||||||
(void*)android_drm_DrmManagerClient_acquireDrmInfo},
|
(void*)android_drm_DrmManagerClient_acquireDrmInfo},
|
||||||
|
|
||||||
{"_saveRights", "(ILandroid/drm/DrmRights;Ljava/lang/String;Ljava/lang/String;)V",
|
{"_saveRights", "(ILandroid/drm/DrmRights;Ljava/lang/String;Ljava/lang/String;)I",
|
||||||
(void*)android_drm_DrmManagerClient_saveRights},
|
(void*)android_drm_DrmManagerClient_saveRights},
|
||||||
|
|
||||||
{"_getDrmObjectType", "(ILjava/lang/String;Ljava/lang/String;)I",
|
{"_getDrmObjectType", "(ILjava/lang/String;Ljava/lang/String;)I",
|
||||||
@@ -710,10 +714,10 @@ static JNINativeMethod nativeMethods[] = {
|
|||||||
{"_checkRightsStatus", "(ILjava/lang/String;I)I",
|
{"_checkRightsStatus", "(ILjava/lang/String;I)I",
|
||||||
(void*)android_drm_DrmManagerClient_checkRightsStatus},
|
(void*)android_drm_DrmManagerClient_checkRightsStatus},
|
||||||
|
|
||||||
{"_removeRights", "(ILjava/lang/String;)V",
|
{"_removeRights", "(ILjava/lang/String;)I",
|
||||||
(void*)android_drm_DrmManagerClient_removeRights},
|
(void*)android_drm_DrmManagerClient_removeRights},
|
||||||
|
|
||||||
{"_removeAllRights", "(I)V",
|
{"_removeAllRights", "(I)I",
|
||||||
(void*)android_drm_DrmManagerClient_removeAllRights},
|
(void*)android_drm_DrmManagerClient_removeAllRights},
|
||||||
|
|
||||||
{"_openConvertSession", "(ILjava/lang/String;)I",
|
{"_openConvertSession", "(ILjava/lang/String;)I",
|
||||||
|
|||||||
@@ -14,10 +14,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LOG_NDEBUG 0
|
|
||||||
#define LOG_TAG "DrmManagerClient(Native)"
|
|
||||||
#include <utils/Log.h>
|
|
||||||
|
|
||||||
#include <utils/String8.h>
|
#include <utils/String8.h>
|
||||||
#include <binder/IServiceManager.h>
|
#include <binder/IServiceManager.h>
|
||||||
#include <drm/DrmManagerClient.h>
|
#include <drm/DrmManagerClient.h>
|
||||||
@@ -37,8 +33,8 @@ DrmManagerClient::DrmManagerClient() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DrmManagerClient::~DrmManagerClient() {
|
DrmManagerClient::~DrmManagerClient() {
|
||||||
unloadPlugIns();
|
|
||||||
DrmManagerClientImpl::remove(mUniqueId);
|
DrmManagerClientImpl::remove(mUniqueId);
|
||||||
|
unloadPlugIns();
|
||||||
|
|
||||||
delete mDrmManagerClientImpl; mDrmManagerClientImpl = NULL;
|
delete mDrmManagerClientImpl; mDrmManagerClientImpl = NULL;
|
||||||
}
|
}
|
||||||
@@ -72,7 +68,7 @@ DrmInfo* DrmManagerClient::acquireDrmInfo(const DrmInfoRequest* drmInfoRequest)
|
|||||||
return mDrmManagerClientImpl->acquireDrmInfo(mUniqueId, drmInfoRequest);
|
return mDrmManagerClientImpl->acquireDrmInfo(mUniqueId, drmInfoRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerClient::saveRights(
|
status_t DrmManagerClient::saveRights(
|
||||||
const DrmRights& drmRights, const String8& rightsPath, const String8& contentPath) {
|
const DrmRights& drmRights, const String8& rightsPath, const String8& contentPath) {
|
||||||
return mDrmManagerClientImpl->saveRights(mUniqueId, drmRights, rightsPath, contentPath);
|
return mDrmManagerClientImpl->saveRights(mUniqueId, drmRights, rightsPath, contentPath);
|
||||||
}
|
}
|
||||||
@@ -89,13 +85,14 @@ int DrmManagerClient::checkRightsStatus(const String8& path, int action) {
|
|||||||
return mDrmManagerClientImpl->checkRightsStatus(mUniqueId, path, action);
|
return mDrmManagerClientImpl->checkRightsStatus(mUniqueId, path, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerClient::consumeRights(DecryptHandle* decryptHandle, int action, bool reserve) {
|
status_t DrmManagerClient::consumeRights(DecryptHandle* decryptHandle, int action, bool reserve) {
|
||||||
mDrmManagerClientImpl->consumeRights(mUniqueId, decryptHandle, action, reserve);
|
return mDrmManagerClientImpl->consumeRights(mUniqueId, decryptHandle, action, reserve);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerClient::setPlaybackStatus(
|
status_t DrmManagerClient::setPlaybackStatus(
|
||||||
DecryptHandle* decryptHandle, int playbackStatus, int position) {
|
DecryptHandle* decryptHandle, int playbackStatus, int position) {
|
||||||
mDrmManagerClientImpl->setPlaybackStatus(mUniqueId, decryptHandle, playbackStatus, position);
|
return mDrmManagerClientImpl
|
||||||
|
->setPlaybackStatus(mUniqueId, decryptHandle, playbackStatus, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DrmManagerClient::validateAction(
|
bool DrmManagerClient::validateAction(
|
||||||
@@ -103,12 +100,12 @@ bool DrmManagerClient::validateAction(
|
|||||||
return mDrmManagerClientImpl->validateAction(mUniqueId, path, action, description);
|
return mDrmManagerClientImpl->validateAction(mUniqueId, path, action, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerClient::removeRights(const String8& path) {
|
status_t DrmManagerClient::removeRights(const String8& path) {
|
||||||
mDrmManagerClientImpl->removeRights(mUniqueId, path);
|
return mDrmManagerClientImpl->removeRights(mUniqueId, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerClient::removeAllRights() {
|
status_t DrmManagerClient::removeAllRights() {
|
||||||
mDrmManagerClientImpl->removeAllRights(mUniqueId);
|
return mDrmManagerClientImpl->removeAllRights(mUniqueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DrmManagerClient::openConvertSession(const String8& mimeType) {
|
int DrmManagerClient::openConvertSession(const String8& mimeType) {
|
||||||
@@ -131,25 +128,25 @@ DecryptHandle* DrmManagerClient::openDecryptSession(int fd, int offset, int leng
|
|||||||
return mDrmManagerClientImpl->openDecryptSession(mUniqueId, fd, offset, length);
|
return mDrmManagerClientImpl->openDecryptSession(mUniqueId, fd, offset, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerClient::closeDecryptSession(DecryptHandle* decryptHandle) {
|
status_t DrmManagerClient::closeDecryptSession(DecryptHandle* decryptHandle) {
|
||||||
mDrmManagerClientImpl->closeDecryptSession(mUniqueId, decryptHandle);
|
return mDrmManagerClientImpl->closeDecryptSession(mUniqueId, decryptHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerClient::initializeDecryptUnit(
|
status_t DrmManagerClient::initializeDecryptUnit(
|
||||||
DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) {
|
DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) {
|
||||||
mDrmManagerClientImpl->initializeDecryptUnit(
|
return mDrmManagerClientImpl->initializeDecryptUnit(
|
||||||
mUniqueId, decryptHandle, decryptUnitId, headerInfo);
|
mUniqueId, decryptHandle, decryptUnitId, headerInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t DrmManagerClient::decrypt(
|
status_t DrmManagerClient::decrypt(
|
||||||
DecryptHandle* decryptHandle, int decryptUnitId,
|
DecryptHandle* decryptHandle, int decryptUnitId,
|
||||||
const DrmBuffer* encBuffer, DrmBuffer** decBuffer) {
|
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
|
||||||
return mDrmManagerClientImpl->decrypt(
|
return mDrmManagerClientImpl->decrypt(
|
||||||
mUniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer);
|
mUniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerClient::finalizeDecryptUnit(DecryptHandle* decryptHandle, int decryptUnitId) {
|
status_t DrmManagerClient::finalizeDecryptUnit(DecryptHandle* decryptHandle, int decryptUnitId) {
|
||||||
mDrmManagerClientImpl->finalizeDecryptUnit(mUniqueId, decryptHandle, decryptUnitId);
|
return mDrmManagerClientImpl->finalizeDecryptUnit(mUniqueId, decryptHandle, decryptUnitId);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t DrmManagerClient::pread(
|
ssize_t DrmManagerClient::pread(
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LOG_NDEBUG 0
|
//#define LOG_NDEBUG 0
|
||||||
#define LOG_TAG "DrmManagerClientImpl(Native)"
|
#define LOG_TAG "DrmManagerClientImpl(Native)"
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
|
|
||||||
@@ -29,44 +29,21 @@ using namespace android;
|
|||||||
#define INVALID_VALUE -1
|
#define INVALID_VALUE -1
|
||||||
|
|
||||||
Mutex DrmManagerClientImpl::mMutex;
|
Mutex DrmManagerClientImpl::mMutex;
|
||||||
Vector<int> DrmManagerClientImpl::mUniqueIdVector;
|
|
||||||
sp<IDrmManagerService> DrmManagerClientImpl::mDrmManagerService;
|
sp<IDrmManagerService> DrmManagerClientImpl::mDrmManagerService;
|
||||||
const String8 DrmManagerClientImpl::EMPTY_STRING("");
|
const String8 DrmManagerClientImpl::EMPTY_STRING("");
|
||||||
|
|
||||||
DrmManagerClientImpl* DrmManagerClientImpl::create(int* pUniqueId) {
|
DrmManagerClientImpl* DrmManagerClientImpl::create(int* pUniqueId) {
|
||||||
if (0 == *pUniqueId) {
|
if (0 == *pUniqueId) {
|
||||||
int uniqueId = 0;
|
int uniqueId = getDrmManagerService()->addUniqueId(*pUniqueId);
|
||||||
bool foundUniqueId = false;
|
|
||||||
srand(time(NULL));
|
|
||||||
|
|
||||||
while (!foundUniqueId) {
|
|
||||||
const int size = mUniqueIdVector.size();
|
|
||||||
uniqueId = rand() % 100;
|
|
||||||
|
|
||||||
int index = 0;
|
|
||||||
for (; index < size; ++index) {
|
|
||||||
if (mUniqueIdVector.itemAt(index) == uniqueId) {
|
|
||||||
foundUniqueId = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (index == size) {
|
|
||||||
foundUniqueId = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*pUniqueId = uniqueId;
|
*pUniqueId = uniqueId;
|
||||||
|
} else {
|
||||||
|
getDrmManagerService()->addUniqueId(*pUniqueId);
|
||||||
}
|
}
|
||||||
mUniqueIdVector.push(*pUniqueId);
|
|
||||||
return new DrmManagerClientImpl();
|
return new DrmManagerClientImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerClientImpl::remove(int uniqueId) {
|
void DrmManagerClientImpl::remove(int uniqueId) {
|
||||||
for (int i = 0; i < mUniqueIdVector.size(); i++) {
|
getDrmManagerService()->removeUniqueId(uniqueId);
|
||||||
if (uniqueId == mUniqueIdVector.itemAt(i)) {
|
|
||||||
mUniqueIdVector.removeAt(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DrmManagerClientImpl::DrmManagerClientImpl() {
|
DrmManagerClientImpl::DrmManagerClientImpl() {
|
||||||
@@ -164,11 +141,13 @@ DrmInfo* DrmManagerClientImpl::acquireDrmInfo(int uniqueId, const DrmInfoRequest
|
|||||||
return drmInfo;
|
return drmInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerClientImpl::saveRights(int uniqueId, const DrmRights& drmRights,
|
status_t DrmManagerClientImpl::saveRights(int uniqueId, const DrmRights& drmRights,
|
||||||
const String8& rightsPath, const String8& contentPath) {
|
const String8& rightsPath, const String8& contentPath) {
|
||||||
|
status_t status = DRM_ERROR_UNKNOWN;
|
||||||
if (EMPTY_STRING != contentPath) {
|
if (EMPTY_STRING != contentPath) {
|
||||||
getDrmManagerService()->saveRights(uniqueId, drmRights, rightsPath, contentPath);
|
status = getDrmManagerService()->saveRights(uniqueId, drmRights, rightsPath, contentPath);
|
||||||
}
|
}
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
String8 DrmManagerClientImpl::getOriginalMimeType(int uniqueId, const String8& path) {
|
String8 DrmManagerClientImpl::getOriginalMimeType(int uniqueId, const String8& path) {
|
||||||
@@ -197,19 +176,23 @@ int DrmManagerClientImpl::checkRightsStatus(
|
|||||||
return rightsStatus;
|
return rightsStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerClientImpl::consumeRights(
|
status_t DrmManagerClientImpl::consumeRights(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
|
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
|
||||||
|
status_t status = DRM_ERROR_UNKNOWN;
|
||||||
if (NULL != decryptHandle) {
|
if (NULL != decryptHandle) {
|
||||||
getDrmManagerService()->consumeRights(uniqueId, decryptHandle, action, reserve);
|
status = getDrmManagerService()->consumeRights(uniqueId, decryptHandle, action, reserve);
|
||||||
}
|
}
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerClientImpl::setPlaybackStatus(
|
status_t DrmManagerClientImpl::setPlaybackStatus(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
|
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
|
||||||
|
status_t status = DRM_ERROR_UNKNOWN;
|
||||||
if (NULL != decryptHandle) {
|
if (NULL != decryptHandle) {
|
||||||
getDrmManagerService()->setPlaybackStatus(
|
status = getDrmManagerService()->setPlaybackStatus(
|
||||||
uniqueId, decryptHandle, playbackStatus, position);
|
uniqueId, decryptHandle, playbackStatus, position);
|
||||||
}
|
}
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DrmManagerClientImpl::validateAction(
|
bool DrmManagerClientImpl::validateAction(
|
||||||
@@ -221,14 +204,16 @@ bool DrmManagerClientImpl::validateAction(
|
|||||||
return retCode;
|
return retCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerClientImpl::removeRights(int uniqueId, const String8& path) {
|
status_t DrmManagerClientImpl::removeRights(int uniqueId, const String8& path) {
|
||||||
|
status_t status = DRM_ERROR_UNKNOWN;
|
||||||
if (EMPTY_STRING != path) {
|
if (EMPTY_STRING != path) {
|
||||||
getDrmManagerService()->removeRights(uniqueId, path);
|
status = getDrmManagerService()->removeRights(uniqueId, path);
|
||||||
}
|
}
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerClientImpl::removeAllRights(int uniqueId) {
|
status_t DrmManagerClientImpl::removeAllRights(int uniqueId) {
|
||||||
getDrmManagerService()->removeAllRights(uniqueId);
|
return getDrmManagerService()->removeAllRights(uniqueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DrmManagerClientImpl::openConvertSession(int uniqueId, const String8& mimeType) {
|
int DrmManagerClientImpl::openConvertSession(int uniqueId, const String8& mimeType) {
|
||||||
@@ -263,40 +248,46 @@ status_t DrmManagerClientImpl::getAllSupportInfo(
|
|||||||
|
|
||||||
DecryptHandle* DrmManagerClientImpl::openDecryptSession(
|
DecryptHandle* DrmManagerClientImpl::openDecryptSession(
|
||||||
int uniqueId, int fd, int offset, int length) {
|
int uniqueId, int fd, int offset, int length) {
|
||||||
LOGV("Entering DrmManagerClientImpl::openDecryptSession");
|
|
||||||
return getDrmManagerService()->openDecryptSession(uniqueId, fd, offset, length);
|
return getDrmManagerService()->openDecryptSession(uniqueId, fd, offset, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerClientImpl::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
|
status_t DrmManagerClientImpl::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
|
||||||
if (NULL != decryptHandle) {
|
|
||||||
getDrmManagerService()->closeDecryptSession( uniqueId, decryptHandle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrmManagerClientImpl::initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
|
||||||
int decryptUnitId, const DrmBuffer* headerInfo) {
|
|
||||||
if ((NULL != decryptHandle) && (NULL != headerInfo)) {
|
|
||||||
getDrmManagerService()->initializeDecryptUnit(
|
|
||||||
uniqueId, decryptHandle, decryptUnitId, headerInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
status_t DrmManagerClientImpl::decrypt(int uniqueId, DecryptHandle* decryptHandle,
|
|
||||||
int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer) {
|
|
||||||
status_t status = DRM_ERROR_UNKNOWN;
|
status_t status = DRM_ERROR_UNKNOWN;
|
||||||
if ((NULL != decryptHandle) && (NULL != encBuffer)
|
if (NULL != decryptHandle) {
|
||||||
&& (NULL != decBuffer) && (NULL != *decBuffer)) {
|
status = getDrmManagerService()->closeDecryptSession( uniqueId, decryptHandle);
|
||||||
status = getDrmManagerService()->decrypt(
|
|
||||||
uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer);
|
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerClientImpl::finalizeDecryptUnit(
|
status_t DrmManagerClientImpl::initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
|
int decryptUnitId, const DrmBuffer* headerInfo) {
|
||||||
if (NULL != decryptHandle) {
|
status_t status = DRM_ERROR_UNKNOWN;
|
||||||
getDrmManagerService()->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
|
if ((NULL != decryptHandle) && (NULL != headerInfo)) {
|
||||||
|
status = getDrmManagerService()->initializeDecryptUnit(
|
||||||
|
uniqueId, decryptHandle, decryptUnitId, headerInfo);
|
||||||
}
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t DrmManagerClientImpl::decrypt(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
|
int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
|
||||||
|
status_t status = DRM_ERROR_UNKNOWN;
|
||||||
|
if ((NULL != decryptHandle) && (NULL != encBuffer)
|
||||||
|
&& (NULL != decBuffer) && (NULL != *decBuffer)) {
|
||||||
|
status = getDrmManagerService()->decrypt(
|
||||||
|
uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t DrmManagerClientImpl::finalizeDecryptUnit(
|
||||||
|
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
|
||||||
|
status_t status = DRM_ERROR_UNKNOWN;
|
||||||
|
if (NULL != decryptHandle) {
|
||||||
|
status
|
||||||
|
= getDrmManagerService()->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t DrmManagerClientImpl::pread(int uniqueId, DecryptHandle* decryptHandle,
|
ssize_t DrmManagerClientImpl::pread(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
|
|||||||
@@ -53,6 +53,9 @@ public:
|
|||||||
virtual ~DrmManager();
|
virtual ~DrmManager();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
int addUniqueId(int uniqueId);
|
||||||
|
|
||||||
|
void removeUniqueId(int uniqueId);
|
||||||
|
|
||||||
status_t loadPlugIns(int uniqueId);
|
status_t loadPlugIns(int uniqueId);
|
||||||
|
|
||||||
@@ -73,7 +76,7 @@ public:
|
|||||||
|
|
||||||
DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest);
|
DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest);
|
||||||
|
|
||||||
void saveRights(int uniqueId, const DrmRights& drmRights,
|
status_t saveRights(int uniqueId, const DrmRights& drmRights,
|
||||||
const String8& rightsPath, const String8& contentPath);
|
const String8& rightsPath, const String8& contentPath);
|
||||||
|
|
||||||
String8 getOriginalMimeType(int uniqueId, const String8& path);
|
String8 getOriginalMimeType(int uniqueId, const String8& path);
|
||||||
@@ -82,17 +85,17 @@ public:
|
|||||||
|
|
||||||
int checkRightsStatus(int uniqueId, const String8& path, int action);
|
int checkRightsStatus(int uniqueId, const String8& path, int action);
|
||||||
|
|
||||||
void consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
|
status_t consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
|
||||||
|
|
||||||
void setPlaybackStatus(
|
status_t setPlaybackStatus(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
|
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
|
||||||
|
|
||||||
bool validateAction(
|
bool validateAction(
|
||||||
int uniqueId, const String8& path, int action, const ActionDescription& description);
|
int uniqueId, const String8& path, int action, const ActionDescription& description);
|
||||||
|
|
||||||
void removeRights(int uniqueId, const String8& path);
|
status_t removeRights(int uniqueId, const String8& path);
|
||||||
|
|
||||||
void removeAllRights(int uniqueId);
|
status_t removeAllRights(int uniqueId);
|
||||||
|
|
||||||
int openConvertSession(int uniqueId, const String8& mimeType);
|
int openConvertSession(int uniqueId, const String8& mimeType);
|
||||||
|
|
||||||
@@ -104,15 +107,15 @@ public:
|
|||||||
|
|
||||||
DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length);
|
DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length);
|
||||||
|
|
||||||
void closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
|
status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
|
||||||
|
|
||||||
void initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
int decryptUnitId, const DrmBuffer* headerInfo);
|
int decryptUnitId, const DrmBuffer* headerInfo);
|
||||||
|
|
||||||
status_t decrypt(int uniqueId, DecryptHandle* decryptHandle,
|
status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
|
||||||
int decryptUnitId, const DrmBuffer* encBuffer,DrmBuffer** decBuffer);
|
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV);
|
||||||
|
|
||||||
void finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
|
status_t finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
|
||||||
|
|
||||||
ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
|
ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
void* buffer, ssize_t numBytes, off_t offset);
|
void* buffer, ssize_t numBytes, off_t offset);
|
||||||
@@ -133,6 +136,7 @@ private:
|
|||||||
void initializePlugIns(int uniqueId);
|
void initializePlugIns(int uniqueId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static Vector<int> mUniqueIdVector;
|
||||||
static const String8 EMPTY_STRING;
|
static const String8 EMPTY_STRING;
|
||||||
|
|
||||||
int mDecryptSessionId;
|
int mDecryptSessionId;
|
||||||
|
|||||||
@@ -132,8 +132,10 @@ public:
|
|||||||
* @param[in] drmRights DrmRights to be saved
|
* @param[in] drmRights DrmRights to be saved
|
||||||
* @param[in] rightsPath File path where rights to be saved
|
* @param[in] rightsPath File path where rights to be saved
|
||||||
* @param[in] contentPath File path where content was saved
|
* @param[in] contentPath File path where content was saved
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
void saveRights(int uniqueId, const DrmRights& drmRights,
|
status_t saveRights(int uniqueId, const DrmRights& drmRights,
|
||||||
const String8& rightsPath, const String8& contentPath);
|
const String8& rightsPath, const String8& contentPath);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -179,8 +181,10 @@ public:
|
|||||||
* @param[in] decryptHandle Handle for the decryption session
|
* @param[in] decryptHandle Handle for the decryption session
|
||||||
* @param[in] action Action to perform. (Action::DEFAULT, Action::PLAY, etc)
|
* @param[in] action Action to perform. (Action::DEFAULT, Action::PLAY, etc)
|
||||||
* @param[in] reserve True if the rights should be reserved.
|
* @param[in] reserve True if the rights should be reserved.
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
void consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
|
status_t consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Informs the DRM engine about the playback actions performed on the DRM files.
|
* Informs the DRM engine about the playback actions performed on the DRM files.
|
||||||
@@ -190,8 +194,10 @@ public:
|
|||||||
* @param[in] playbackStatus Playback action (Playback::START, Playback::STOP, Playback::PAUSE)
|
* @param[in] playbackStatus Playback action (Playback::START, Playback::STOP, Playback::PAUSE)
|
||||||
* @param[in] position Position in the file (in milliseconds) where the start occurs.
|
* @param[in] position Position in the file (in milliseconds) where the start occurs.
|
||||||
* Only valid together with Playback::START.
|
* Only valid together with Playback::START.
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
void setPlaybackStatus(
|
status_t setPlaybackStatus(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
|
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -211,16 +217,20 @@ public:
|
|||||||
*
|
*
|
||||||
* @param[in] uniqueId Unique identifier for a session
|
* @param[in] uniqueId Unique identifier for a session
|
||||||
* @param[in] path Path of the protected content
|
* @param[in] path Path of the protected content
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
void removeRights(int uniqueId, const String8& path);
|
status_t removeRights(int uniqueId, const String8& path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all the rights information of each plug-in associated with
|
* Removes all the rights information of each plug-in associated with
|
||||||
* DRM framework. Will be used in master reset
|
* DRM framework. Will be used in master reset
|
||||||
*
|
*
|
||||||
* @param[in] uniqueId Unique identifier for a session
|
* @param[in] uniqueId Unique identifier for a session
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
void removeAllRights(int uniqueId);
|
status_t removeAllRights(int uniqueId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This API is for Forward Lock based DRM scheme.
|
* This API is for Forward Lock based DRM scheme.
|
||||||
@@ -295,8 +305,10 @@ public:
|
|||||||
*
|
*
|
||||||
* @param[in] uniqueId Unique identifier for a session
|
* @param[in] uniqueId Unique identifier for a session
|
||||||
* @param[in] decryptHandle Handle for the decryption session
|
* @param[in] decryptHandle Handle for the decryption session
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
void closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
|
status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize decryption for the given unit of the protected content
|
* Initialize decryption for the given unit of the protected content
|
||||||
@@ -305,8 +317,10 @@ public:
|
|||||||
* @param[in] decryptHandle Handle for the decryption session
|
* @param[in] decryptHandle Handle for the decryption session
|
||||||
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
|
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
|
||||||
* @param[in] headerInfo Information for initializing decryption of this decrypUnit
|
* @param[in] headerInfo Information for initializing decryption of this decrypUnit
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
void initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
int decryptUnitId, const DrmBuffer* headerInfo);
|
int decryptUnitId, const DrmBuffer* headerInfo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -319,14 +333,15 @@ public:
|
|||||||
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
|
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
|
||||||
* @param[in] encBuffer Encrypted data block
|
* @param[in] encBuffer Encrypted data block
|
||||||
* @param[out] decBuffer Decrypted data block
|
* @param[out] decBuffer Decrypted data block
|
||||||
|
* @param[in] IV Optional buffer
|
||||||
* @return status_t
|
* @return status_t
|
||||||
* Returns the error code for this API
|
* Returns the error code for this API
|
||||||
* DRM_NO_ERROR for success, and one of DRM_ERROR_UNKNOWN, DRM_ERROR_LICENSE_EXPIRED
|
* DRM_NO_ERROR for success, and one of DRM_ERROR_UNKNOWN, DRM_ERROR_LICENSE_EXPIRED
|
||||||
* DRM_ERROR_SESSION_NOT_OPENED, DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED,
|
* DRM_ERROR_SESSION_NOT_OPENED, DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED,
|
||||||
* DRM_ERROR_DECRYPT for failure.
|
* DRM_ERROR_DECRYPT for failure.
|
||||||
*/
|
*/
|
||||||
status_t decrypt(int uniqueId, DecryptHandle* decryptHandle,
|
status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
|
||||||
int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer);
|
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finalize decryption for the given unit of the protected content
|
* Finalize decryption for the given unit of the protected content
|
||||||
@@ -334,8 +349,10 @@ public:
|
|||||||
* @param[in] uniqueId Unique identifier for a session
|
* @param[in] uniqueId Unique identifier for a session
|
||||||
* @param[in] decryptHandle Handle for the decryption session
|
* @param[in] decryptHandle Handle for the decryption session
|
||||||
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
|
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
void finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
|
status_t finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the specified number of bytes from an open DRM file.
|
* Reads the specified number of bytes from an open DRM file.
|
||||||
@@ -388,7 +405,6 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static Mutex mMutex;
|
static Mutex mMutex;
|
||||||
static Vector<int> mUniqueIdVector;
|
|
||||||
static sp<IDrmManagerService> mDrmManagerService;
|
static sp<IDrmManagerService> mDrmManagerService;
|
||||||
static const sp<IDrmManagerService>& getDrmManagerService();
|
static const sp<IDrmManagerService>& getDrmManagerService();
|
||||||
static const String8 EMPTY_STRING;
|
static const String8 EMPTY_STRING;
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ private:
|
|||||||
virtual ~DrmManagerService();
|
virtual ~DrmManagerService();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
int addUniqueId(int uniqueId);
|
||||||
|
|
||||||
|
void removeUniqueId(int uniqueId);
|
||||||
|
|
||||||
status_t loadPlugIns(int uniqueId);
|
status_t loadPlugIns(int uniqueId);
|
||||||
|
|
||||||
status_t loadPlugIns(int uniqueId, const String8& plugInDirPath);
|
status_t loadPlugIns(int uniqueId, const String8& plugInDirPath);
|
||||||
@@ -65,7 +69,7 @@ public:
|
|||||||
|
|
||||||
DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest);
|
DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest);
|
||||||
|
|
||||||
void saveRights(int uniqueId, const DrmRights& drmRights,
|
status_t saveRights(int uniqueId, const DrmRights& drmRights,
|
||||||
const String8& rightsPath, const String8& contentPath);
|
const String8& rightsPath, const String8& contentPath);
|
||||||
|
|
||||||
String8 getOriginalMimeType(int uniqueId, const String8& path);
|
String8 getOriginalMimeType(int uniqueId, const String8& path);
|
||||||
@@ -74,17 +78,17 @@ public:
|
|||||||
|
|
||||||
int checkRightsStatus(int uniqueId, const String8& path,int action);
|
int checkRightsStatus(int uniqueId, const String8& path,int action);
|
||||||
|
|
||||||
void consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
|
status_t consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
|
||||||
|
|
||||||
void setPlaybackStatus(
|
status_t setPlaybackStatus(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
|
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
|
||||||
|
|
||||||
bool validateAction(int uniqueId, const String8& path,
|
bool validateAction(int uniqueId, const String8& path,
|
||||||
int action, const ActionDescription& description);
|
int action, const ActionDescription& description);
|
||||||
|
|
||||||
void removeRights(int uniqueId, const String8& path);
|
status_t removeRights(int uniqueId, const String8& path);
|
||||||
|
|
||||||
void removeAllRights(int uniqueId);
|
status_t removeAllRights(int uniqueId);
|
||||||
|
|
||||||
int openConvertSession(int uniqueId, const String8& mimeType);
|
int openConvertSession(int uniqueId, const String8& mimeType);
|
||||||
|
|
||||||
@@ -96,15 +100,15 @@ public:
|
|||||||
|
|
||||||
DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length);
|
DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length);
|
||||||
|
|
||||||
void closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
|
status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
|
||||||
|
|
||||||
void initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
int decryptUnitId, const DrmBuffer* headerInfo);
|
int decryptUnitId, const DrmBuffer* headerInfo);
|
||||||
|
|
||||||
status_t decrypt(int uniqueId, DecryptHandle* decryptHandle,
|
status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
|
||||||
int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer);
|
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV);
|
||||||
|
|
||||||
void finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
|
status_t finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
|
||||||
|
|
||||||
ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
|
ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
void* buffer, ssize_t numBytes, off_t offset);
|
void* buffer, ssize_t numBytes, off_t offset);
|
||||||
|
|||||||
@@ -44,7 +44,9 @@ class IDrmManagerService : public IInterface
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum {
|
enum {
|
||||||
LOAD_PLUGINS = IBinder::FIRST_CALL_TRANSACTION,
|
ADD_UNIQUEID = IBinder::FIRST_CALL_TRANSACTION,
|
||||||
|
REMOVE_UNIQUEID,
|
||||||
|
LOAD_PLUGINS,
|
||||||
LOAD_PLUGINS_FROM_PATH,
|
LOAD_PLUGINS_FROM_PATH,
|
||||||
SET_DRM_SERVICE_LISTENER,
|
SET_DRM_SERVICE_LISTENER,
|
||||||
UNLOAD_PLUGINS,
|
UNLOAD_PLUGINS,
|
||||||
@@ -78,6 +80,10 @@ public:
|
|||||||
DECLARE_META_INTERFACE(DrmManagerService);
|
DECLARE_META_INTERFACE(DrmManagerService);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual int addUniqueId(int uniqueId) = 0;
|
||||||
|
|
||||||
|
virtual void removeUniqueId(int uniqueId) = 0;
|
||||||
|
|
||||||
virtual status_t loadPlugIns(int uniqueId) = 0;
|
virtual status_t loadPlugIns(int uniqueId) = 0;
|
||||||
|
|
||||||
virtual status_t loadPlugIns(int uniqueId, const String8& plugInDirPath) = 0;
|
virtual status_t loadPlugIns(int uniqueId, const String8& plugInDirPath) = 0;
|
||||||
@@ -98,7 +104,7 @@ public:
|
|||||||
|
|
||||||
virtual DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest) = 0;
|
virtual DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest) = 0;
|
||||||
|
|
||||||
virtual void saveRights(int uniqueId, const DrmRights& drmRights,
|
virtual status_t saveRights(int uniqueId, const DrmRights& drmRights,
|
||||||
const String8& rightsPath, const String8& contentPath) = 0;
|
const String8& rightsPath, const String8& contentPath) = 0;
|
||||||
|
|
||||||
virtual String8 getOriginalMimeType(int uniqueId, const String8& path) = 0;
|
virtual String8 getOriginalMimeType(int uniqueId, const String8& path) = 0;
|
||||||
@@ -108,19 +114,19 @@ public:
|
|||||||
|
|
||||||
virtual int checkRightsStatus(int uniqueId, const String8& path, int action) = 0;
|
virtual int checkRightsStatus(int uniqueId, const String8& path, int action) = 0;
|
||||||
|
|
||||||
virtual void consumeRights(
|
virtual status_t consumeRights(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) = 0;
|
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) = 0;
|
||||||
|
|
||||||
virtual void setPlaybackStatus(
|
virtual status_t setPlaybackStatus(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) = 0;
|
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) = 0;
|
||||||
|
|
||||||
virtual bool validateAction(
|
virtual bool validateAction(
|
||||||
int uniqueId, const String8& path,
|
int uniqueId, const String8& path,
|
||||||
int action, const ActionDescription& description) = 0;
|
int action, const ActionDescription& description) = 0;
|
||||||
|
|
||||||
virtual void removeRights(int uniqueId, const String8& path) = 0;
|
virtual status_t removeRights(int uniqueId, const String8& path) = 0;
|
||||||
|
|
||||||
virtual void removeAllRights(int uniqueId) = 0;
|
virtual status_t removeAllRights(int uniqueId) = 0;
|
||||||
|
|
||||||
virtual int openConvertSession(int uniqueId, const String8& mimeType) = 0;
|
virtual int openConvertSession(int uniqueId, const String8& mimeType) = 0;
|
||||||
|
|
||||||
@@ -134,15 +140,15 @@ public:
|
|||||||
|
|
||||||
virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length) = 0;
|
virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length) = 0;
|
||||||
|
|
||||||
virtual void closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
|
virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
|
||||||
|
|
||||||
virtual void initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
int decryptUnitId, const DrmBuffer* headerInfo) = 0;
|
int decryptUnitId, const DrmBuffer* headerInfo) = 0;
|
||||||
|
|
||||||
virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle,
|
virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
|
||||||
int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer) = 0;
|
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) = 0;
|
||||||
|
|
||||||
virtual void finalizeDecryptUnit(
|
virtual status_t finalizeDecryptUnit(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) = 0;
|
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) = 0;
|
||||||
|
|
||||||
virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
|
virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
@@ -158,6 +164,10 @@ public:
|
|||||||
BpDrmManagerService(const sp<IBinder>& impl)
|
BpDrmManagerService(const sp<IBinder>& impl)
|
||||||
: BpInterface<IDrmManagerService>(impl) {}
|
: BpInterface<IDrmManagerService>(impl) {}
|
||||||
|
|
||||||
|
virtual int addUniqueId(int uniqueId);
|
||||||
|
|
||||||
|
virtual void removeUniqueId(int uniqueId);
|
||||||
|
|
||||||
virtual status_t loadPlugIns(int uniqueId);
|
virtual status_t loadPlugIns(int uniqueId);
|
||||||
|
|
||||||
virtual status_t loadPlugIns(int uniqueId, const String8& plugInDirPath);
|
virtual status_t loadPlugIns(int uniqueId, const String8& plugInDirPath);
|
||||||
@@ -177,7 +187,7 @@ public:
|
|||||||
|
|
||||||
virtual DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest);
|
virtual DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest);
|
||||||
|
|
||||||
virtual void saveRights(int uniqueId, const DrmRights& drmRights,
|
virtual status_t saveRights(int uniqueId, const DrmRights& drmRights,
|
||||||
const String8& rightsPath, const String8& contentPath);
|
const String8& rightsPath, const String8& contentPath);
|
||||||
|
|
||||||
virtual String8 getOriginalMimeType(int uniqueId, const String8& path);
|
virtual String8 getOriginalMimeType(int uniqueId, const String8& path);
|
||||||
@@ -186,18 +196,18 @@ public:
|
|||||||
|
|
||||||
virtual int checkRightsStatus(int uniqueId, const String8& path, int action);
|
virtual int checkRightsStatus(int uniqueId, const String8& path, int action);
|
||||||
|
|
||||||
virtual void consumeRights(
|
virtual status_t consumeRights(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
|
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
|
||||||
|
|
||||||
virtual void setPlaybackStatus(
|
virtual status_t setPlaybackStatus(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
|
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
|
||||||
|
|
||||||
virtual bool validateAction(
|
virtual bool validateAction(
|
||||||
int uniqueId, const String8& path, int action, const ActionDescription& description);
|
int uniqueId, const String8& path, int action, const ActionDescription& description);
|
||||||
|
|
||||||
virtual void removeRights(int uniqueId, const String8& path);
|
virtual status_t removeRights(int uniqueId, const String8& path);
|
||||||
|
|
||||||
virtual void removeAllRights(int uniqueId);
|
virtual status_t removeAllRights(int uniqueId);
|
||||||
|
|
||||||
virtual int openConvertSession(int uniqueId, const String8& mimeType);
|
virtual int openConvertSession(int uniqueId, const String8& mimeType);
|
||||||
|
|
||||||
@@ -211,15 +221,15 @@ public:
|
|||||||
|
|
||||||
virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length);
|
virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length);
|
||||||
|
|
||||||
virtual void closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
|
virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
|
||||||
|
|
||||||
virtual void initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
int decryptUnitId, const DrmBuffer* headerInfo);
|
int decryptUnitId, const DrmBuffer* headerInfo);
|
||||||
|
|
||||||
virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle,
|
virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
|
||||||
int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer);
|
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV);
|
||||||
|
|
||||||
virtual void finalizeDecryptUnit(
|
virtual status_t finalizeDecryptUnit(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
|
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
|
||||||
|
|
||||||
virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
|
virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
|
|||||||
@@ -46,6 +46,14 @@ public:
|
|||||||
* @return Data read from the file
|
* @return Data read from the file
|
||||||
*/
|
*/
|
||||||
static String8 readBytes(const String8& filePath);
|
static String8 readBytes(const String8& filePath);
|
||||||
|
/**
|
||||||
|
* Reads the data into the given buffer from the file path provided
|
||||||
|
*
|
||||||
|
* @param[in] filePath Path of the file
|
||||||
|
* @param[out] buffer Data read from the file
|
||||||
|
* @return Length of the data read from the file
|
||||||
|
*/
|
||||||
|
static int readBytes(const String8& filePath, char** buffer);
|
||||||
/**
|
/**
|
||||||
* Writes the data into the file path provided
|
* Writes the data into the file path provided
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public:
|
|||||||
|
|
||||||
DrmInfoStatus* processDrmInfo(int uniqueId, const DrmInfo* drmInfo);
|
DrmInfoStatus* processDrmInfo(int uniqueId, const DrmInfo* drmInfo);
|
||||||
|
|
||||||
void saveRights(int uniqueId, const DrmRights& drmRights,
|
status_t saveRights(int uniqueId, const DrmRights& drmRights,
|
||||||
const String8& rightsPath, const String8& contentPath);
|
const String8& rightsPath, const String8& contentPath);
|
||||||
|
|
||||||
DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest);
|
DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest);
|
||||||
@@ -57,19 +57,19 @@ public:
|
|||||||
|
|
||||||
int checkRightsStatus(int uniqueId, const String8& path, int action);
|
int checkRightsStatus(int uniqueId, const String8& path, int action);
|
||||||
|
|
||||||
void consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
|
status_t consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
|
||||||
|
|
||||||
void setPlaybackStatus(
|
status_t setPlaybackStatus(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
|
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
|
||||||
|
|
||||||
bool validateAction(
|
bool validateAction(
|
||||||
int uniqueId, const String8& path, int action, const ActionDescription& description);
|
int uniqueId, const String8& path, int action, const ActionDescription& description);
|
||||||
|
|
||||||
void removeRights(int uniqueId, const String8& path);
|
status_t removeRights(int uniqueId, const String8& path);
|
||||||
|
|
||||||
void removeAllRights(int uniqueId);
|
status_t removeAllRights(int uniqueId);
|
||||||
|
|
||||||
void openConvertSession(int uniqueId, int convertId);
|
status_t openConvertSession(int uniqueId, int convertId);
|
||||||
|
|
||||||
DrmConvertedStatus* convertData(int uniqueId, int convertId, const DrmBuffer* inputData);
|
DrmConvertedStatus* convertData(int uniqueId, int convertId, const DrmBuffer* inputData);
|
||||||
|
|
||||||
@@ -80,15 +80,15 @@ public:
|
|||||||
status_t openDecryptSession(
|
status_t openDecryptSession(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length);
|
int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length);
|
||||||
|
|
||||||
void closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
|
status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
|
||||||
|
|
||||||
void initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
int decryptUnitId, const DrmBuffer* headerInfo);
|
int decryptUnitId, const DrmBuffer* headerInfo);
|
||||||
|
|
||||||
status_t decrypt(int uniqueId, DecryptHandle* decryptHandle,
|
status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
|
||||||
int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer);
|
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV);
|
||||||
|
|
||||||
void finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
|
status_t finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
|
||||||
|
|
||||||
ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
|
ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
void* buffer, ssize_t numBytes, off_t offset);
|
void* buffer, ssize_t numBytes, off_t offset);
|
||||||
@@ -172,8 +172,10 @@ protected:
|
|||||||
* @param[in] drmRights DrmRights to be saved
|
* @param[in] drmRights DrmRights to be saved
|
||||||
* @param[in] rightsPath File path where rights to be saved
|
* @param[in] rightsPath File path where rights to be saved
|
||||||
* @param[in] contentPath File path where content was saved
|
* @param[in] contentPath File path where content was saved
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
virtual void onSaveRights(int uniqueId, const DrmRights& drmRights,
|
virtual status_t onSaveRights(int uniqueId, const DrmRights& drmRights,
|
||||||
const String8& rightspath, const String8& contentPath) = 0;
|
const String8& rightspath, const String8& contentPath) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -231,8 +233,10 @@ protected:
|
|||||||
* @param[in] decryptHandle Handle for the decryption session
|
* @param[in] decryptHandle Handle for the decryption session
|
||||||
* @param[in] action Action to perform. (Action::DEFAULT, Action::PLAY, etc)
|
* @param[in] action Action to perform. (Action::DEFAULT, Action::PLAY, etc)
|
||||||
* @param[in] reserve True if the rights should be reserved.
|
* @param[in] reserve True if the rights should be reserved.
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
virtual void onConsumeRights(int uniqueId, DecryptHandle* decryptHandle,
|
virtual status_t onConsumeRights(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
int action, bool reserve) = 0;
|
int action, bool reserve) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -243,8 +247,10 @@ protected:
|
|||||||
* @param[in] playbackStatus Playback action (Playback::START, Playback::STOP, Playback::PAUSE)
|
* @param[in] playbackStatus Playback action (Playback::START, Playback::STOP, Playback::PAUSE)
|
||||||
* @param[in] position Position in the file (in milliseconds) where the start occurs.
|
* @param[in] position Position in the file (in milliseconds) where the start occurs.
|
||||||
* Only valid together with Playback::START.
|
* Only valid together with Playback::START.
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
virtual void onSetPlaybackStatus(
|
virtual status_t onSetPlaybackStatus(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) = 0;
|
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -264,16 +270,20 @@ protected:
|
|||||||
*
|
*
|
||||||
* @param[in] uniqueId Unique identifier for a session
|
* @param[in] uniqueId Unique identifier for a session
|
||||||
* @param[in] path Path of the protected content
|
* @param[in] path Path of the protected content
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
virtual void onRemoveRights(int uniqueId, const String8& path) = 0;
|
virtual status_t onRemoveRights(int uniqueId, const String8& path) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all the rights information of each plug-in associated with
|
* Removes all the rights information of each plug-in associated with
|
||||||
* DRM framework. Will be used in master reset
|
* DRM framework. Will be used in master reset
|
||||||
*
|
*
|
||||||
* @param[in] uniqueId Unique identifier for a session
|
* @param[in] uniqueId Unique identifier for a session
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
virtual void onRemoveAllRights(int uniqueId) = 0;
|
virtual status_t onRemoveAllRights(int uniqueId) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This API is for Forward Lock based DRM scheme.
|
* This API is for Forward Lock based DRM scheme.
|
||||||
@@ -283,8 +293,10 @@ protected:
|
|||||||
*
|
*
|
||||||
* @param[in] uniqueId Unique identifier for a session
|
* @param[in] uniqueId Unique identifier for a session
|
||||||
* @param[in] convertId Handle for the convert session
|
* @param[in] convertId Handle for the convert session
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
virtual void onOpenConvertSession(int uniqueId, int convertId) = 0;
|
virtual status_t onOpenConvertSession(int uniqueId, int convertId) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accepts and converts the input data which is part of DRM file.
|
* Accepts and converts the input data which is part of DRM file.
|
||||||
@@ -347,8 +359,10 @@ protected:
|
|||||||
*
|
*
|
||||||
* @param[in] uniqueId Unique identifier for a session
|
* @param[in] uniqueId Unique identifier for a session
|
||||||
* @param[in] decryptHandle Handle for the decryption session
|
* @param[in] decryptHandle Handle for the decryption session
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
virtual void onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
|
virtual status_t onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize decryption for the given unit of the protected content
|
* Initialize decryption for the given unit of the protected content
|
||||||
@@ -357,8 +371,10 @@ protected:
|
|||||||
* @param[in] decryptId Handle for the decryption session
|
* @param[in] decryptId Handle for the decryption session
|
||||||
* @param[in] decryptUnitId ID Specifies decryption unit, such as track ID
|
* @param[in] decryptUnitId ID Specifies decryption unit, such as track ID
|
||||||
* @param[in] headerInfo Information for initializing decryption of this decrypUnit
|
* @param[in] headerInfo Information for initializing decryption of this decrypUnit
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
virtual void onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
virtual status_t onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
int decryptUnitId, const DrmBuffer* headerInfo) = 0;
|
int decryptUnitId, const DrmBuffer* headerInfo) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -371,14 +387,15 @@ protected:
|
|||||||
* @param[in] decryptUnitId ID Specifies decryption unit, such as track ID
|
* @param[in] decryptUnitId ID Specifies decryption unit, such as track ID
|
||||||
* @param[in] encBuffer Encrypted data block
|
* @param[in] encBuffer Encrypted data block
|
||||||
* @param[out] decBuffer Decrypted data block
|
* @param[out] decBuffer Decrypted data block
|
||||||
|
* @param[in] IV Optional buffer
|
||||||
* @return status_t
|
* @return status_t
|
||||||
* Returns the error code for this API
|
* Returns the error code for this API
|
||||||
* DRM_NO_ERROR for success, and one of DRM_ERROR_UNKNOWN, DRM_ERROR_LICENSE_EXPIRED
|
* DRM_NO_ERROR for success, and one of DRM_ERROR_UNKNOWN, DRM_ERROR_LICENSE_EXPIRED
|
||||||
* DRM_ERROR_SESSION_NOT_OPENED, DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED,
|
* DRM_ERROR_SESSION_NOT_OPENED, DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED,
|
||||||
* DRM_ERROR_DECRYPT for failure.
|
* DRM_ERROR_DECRYPT for failure.
|
||||||
*/
|
*/
|
||||||
virtual status_t onDecrypt(int uniqueId, DecryptHandle* decryptHandle,
|
virtual status_t onDecrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
|
||||||
int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer) = 0;
|
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finalize decryption for the given unit of the protected content
|
* Finalize decryption for the given unit of the protected content
|
||||||
@@ -386,8 +403,10 @@ protected:
|
|||||||
* @param[in] uniqueId Unique identifier for a session
|
* @param[in] uniqueId Unique identifier for a session
|
||||||
* @param[in] decryptHandle Handle for the decryption session
|
* @param[in] decryptHandle Handle for the decryption session
|
||||||
* @param[in] decryptUnitId ID Specifies decryption unit, such as track ID
|
* @param[in] decryptUnitId ID Specifies decryption unit, such as track ID
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
virtual void onFinalizeDecryptUnit(
|
virtual status_t onFinalizeDecryptUnit(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) = 0;
|
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -143,8 +143,10 @@ public:
|
|||||||
* @param[in] drmRights DrmRights to be saved
|
* @param[in] drmRights DrmRights to be saved
|
||||||
* @param[in] rightsPath File path where rights to be saved
|
* @param[in] rightsPath File path where rights to be saved
|
||||||
* @param[in] contentPath File path where content was saved
|
* @param[in] contentPath File path where content was saved
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
virtual void saveRights(int uniqueId, const DrmRights& drmRights,
|
virtual status_t saveRights(int uniqueId, const DrmRights& drmRights,
|
||||||
const String8& rightsPath, const String8& contentPath) = 0;
|
const String8& rightsPath, const String8& contentPath) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -191,8 +193,10 @@ public:
|
|||||||
* @param[in] decryptHandle Handle for the decryption session
|
* @param[in] decryptHandle Handle for the decryption session
|
||||||
* @param[in] action Action to perform. (Action::DEFAULT, Action::PLAY, etc)
|
* @param[in] action Action to perform. (Action::DEFAULT, Action::PLAY, etc)
|
||||||
* @param[in] reserve True if the rights should be reserved.
|
* @param[in] reserve True if the rights should be reserved.
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
virtual void consumeRights(
|
virtual status_t consumeRights(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) = 0;
|
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -203,8 +207,10 @@ public:
|
|||||||
* @param[in] playbackStatus Playback action (Playback::START, Playback::STOP, Playback::PAUSE)
|
* @param[in] playbackStatus Playback action (Playback::START, Playback::STOP, Playback::PAUSE)
|
||||||
* @param[in] position Position in the file (in milliseconds) where the start occurs.
|
* @param[in] position Position in the file (in milliseconds) where the start occurs.
|
||||||
* Only valid together with Playback::START.
|
* Only valid together with Playback::START.
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
virtual void setPlaybackStatus(int uniqueId, DecryptHandle* decryptHandle,
|
virtual status_t setPlaybackStatus(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
int playbackStatus, int position) = 0;
|
int playbackStatus, int position) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -224,16 +230,20 @@ public:
|
|||||||
*
|
*
|
||||||
* @param[in] uniqueId Unique identifier for a session
|
* @param[in] uniqueId Unique identifier for a session
|
||||||
* @param[in] path Path of the protected content
|
* @param[in] path Path of the protected content
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
virtual void removeRights(int uniqueId, const String8& path) = 0;
|
virtual status_t removeRights(int uniqueId, const String8& path) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all the rights information of each plug-in associated with
|
* Removes all the rights information of each plug-in associated with
|
||||||
* DRM framework. Will be used in master reset
|
* DRM framework. Will be used in master reset
|
||||||
*
|
*
|
||||||
* @param[in] uniqueId Unique identifier for a session
|
* @param[in] uniqueId Unique identifier for a session
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
virtual void removeAllRights(int uniqueId) = 0;
|
virtual status_t removeAllRights(int uniqueId) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This API is for Forward Lock based DRM scheme.
|
* This API is for Forward Lock based DRM scheme.
|
||||||
@@ -243,8 +253,10 @@ public:
|
|||||||
*
|
*
|
||||||
* @param[in] uniqueId Unique identifier for a session
|
* @param[in] uniqueId Unique identifier for a session
|
||||||
* @param[in] convertId Handle for the convert session
|
* @param[in] convertId Handle for the convert session
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
virtual void openConvertSession(int uniqueId, int convertId) = 0;
|
virtual status_t openConvertSession(int uniqueId, int convertId) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accepts and converts the input data which is part of DRM file.
|
* Accepts and converts the input data which is part of DRM file.
|
||||||
@@ -307,8 +319,10 @@ public:
|
|||||||
*
|
*
|
||||||
* @param[in] uniqueId Unique identifier for a session
|
* @param[in] uniqueId Unique identifier for a session
|
||||||
* @param[in] decryptHandle Handle for the decryption session
|
* @param[in] decryptHandle Handle for the decryption session
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
virtual void closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
|
virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize decryption for the given unit of the protected content
|
* Initialize decryption for the given unit of the protected content
|
||||||
@@ -317,8 +331,10 @@ public:
|
|||||||
* @param[in] decryptHandle Handle for the decryption session
|
* @param[in] decryptHandle Handle for the decryption session
|
||||||
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
|
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
|
||||||
* @param[in] headerInfo Information for initializing decryption of this decrypUnit
|
* @param[in] headerInfo Information for initializing decryption of this decrypUnit
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
virtual void initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
int decryptUnitId, const DrmBuffer* headerInfo) = 0;
|
int decryptUnitId, const DrmBuffer* headerInfo) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -331,14 +347,15 @@ public:
|
|||||||
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
|
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
|
||||||
* @param[in] encBuffer Encrypted data block
|
* @param[in] encBuffer Encrypted data block
|
||||||
* @param[out] decBuffer Decrypted data block
|
* @param[out] decBuffer Decrypted data block
|
||||||
|
* @param[in] IV Optional buffer
|
||||||
* @return status_t
|
* @return status_t
|
||||||
* Returns the error code for this API
|
* Returns the error code for this API
|
||||||
* DRM_NO_ERROR for success, and one of DRM_ERROR_UNKNOWN, DRM_ERROR_LICENSE_EXPIRED
|
* DRM_NO_ERROR for success, and one of DRM_ERROR_UNKNOWN, DRM_ERROR_LICENSE_EXPIRED
|
||||||
* DRM_ERROR_SESSION_NOT_OPENED, DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED,
|
* DRM_ERROR_SESSION_NOT_OPENED, DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED,
|
||||||
* DRM_ERROR_DECRYPT for failure.
|
* DRM_ERROR_DECRYPT for failure.
|
||||||
*/
|
*/
|
||||||
virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle,
|
virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
|
||||||
int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer) = 0;
|
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finalize decryption for the given unit of the protected content
|
* Finalize decryption for the given unit of the protected content
|
||||||
@@ -346,8 +363,10 @@ public:
|
|||||||
* @param[in] uniqueId Unique identifier for a session
|
* @param[in] uniqueId Unique identifier for a session
|
||||||
* @param[in] decryptHandle Handle for the decryption session
|
* @param[in] decryptHandle Handle for the decryption session
|
||||||
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
|
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
virtual void finalizeDecryptUnit(
|
virtual status_t finalizeDecryptUnit(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) = 0;
|
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ protected:
|
|||||||
|
|
||||||
DrmInfoStatus* onProcessDrmInfo(int uniqueId, const DrmInfo* drmInfo);
|
DrmInfoStatus* onProcessDrmInfo(int uniqueId, const DrmInfo* drmInfo);
|
||||||
|
|
||||||
void onSaveRights(int uniqueId, const DrmRights& drmRights,
|
status_t onSaveRights(int uniqueId, const DrmRights& drmRights,
|
||||||
const String8& rightsPath, const String8& contentPath);
|
const String8& rightsPath, const String8& contentPath);
|
||||||
|
|
||||||
DrmInfo* onAcquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest);
|
DrmInfo* onAcquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest);
|
||||||
@@ -51,19 +51,19 @@ protected:
|
|||||||
|
|
||||||
int onCheckRightsStatus(int uniqueId, const String8& path, int action);
|
int onCheckRightsStatus(int uniqueId, const String8& path, int action);
|
||||||
|
|
||||||
void onConsumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
|
status_t onConsumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
|
||||||
|
|
||||||
void onSetPlaybackStatus(
|
status_t onSetPlaybackStatus(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
|
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
|
||||||
|
|
||||||
bool onValidateAction(
|
bool onValidateAction(
|
||||||
int uniqueId, const String8& path, int action, const ActionDescription& description);
|
int uniqueId, const String8& path, int action, const ActionDescription& description);
|
||||||
|
|
||||||
void onRemoveRights(int uniqueId, const String8& path);
|
status_t onRemoveRights(int uniqueId, const String8& path);
|
||||||
|
|
||||||
void onRemoveAllRights(int uniqueId);
|
status_t onRemoveAllRights(int uniqueId);
|
||||||
|
|
||||||
void onOpenConvertSession(int uniqueId, int convertId);
|
status_t onOpenConvertSession(int uniqueId, int convertId);
|
||||||
|
|
||||||
DrmConvertedStatus* onConvertData(int uniqueId, int convertId, const DrmBuffer* inputData);
|
DrmConvertedStatus* onConvertData(int uniqueId, int convertId, const DrmBuffer* inputData);
|
||||||
|
|
||||||
@@ -74,15 +74,15 @@ protected:
|
|||||||
status_t onOpenDecryptSession(
|
status_t onOpenDecryptSession(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length);
|
int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length);
|
||||||
|
|
||||||
void onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
|
status_t onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
|
||||||
|
|
||||||
void onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
status_t onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
int decryptUnitId, const DrmBuffer* headerInfo);
|
int decryptUnitId, const DrmBuffer* headerInfo);
|
||||||
|
|
||||||
status_t onDecrypt(int uniqueId, DecryptHandle* decryptHandle,
|
status_t onDecrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
|
||||||
int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer);
|
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV);
|
||||||
|
|
||||||
void onFinalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
|
status_t onFinalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
|
||||||
|
|
||||||
ssize_t onPread(int uniqueId, DecryptHandle* decryptHandle,
|
ssize_t onPread(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
void* buffer, ssize_t numBytes, off_t offset);
|
void* buffer, ssize_t numBytes, off_t offset);
|
||||||
|
|||||||
@@ -129,9 +129,10 @@ DrmSupportInfo* DrmPassthruPlugIn::onGetSupportInfo(int uniqueId) {
|
|||||||
return drmSupportInfo;
|
return drmSupportInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmPassthruPlugIn::onSaveRights(int uniqueId, const DrmRights& drmRights,
|
status_t DrmPassthruPlugIn::onSaveRights(int uniqueId, const DrmRights& drmRights,
|
||||||
const String8& rightsPath, const String8& contentPath) {
|
const String8& rightsPath, const String8& contentPath) {
|
||||||
LOGD("DrmPassthruPlugIn::onSaveRights : %d", uniqueId);
|
LOGD("DrmPassthruPlugIn::onSaveRights : %d", uniqueId);
|
||||||
|
return DRM_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrmInfo* DrmPassthruPlugIn::onAcquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest) {
|
DrmInfo* DrmPassthruPlugIn::onAcquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest) {
|
||||||
@@ -174,14 +175,16 @@ int DrmPassthruPlugIn::onCheckRightsStatus(int uniqueId, const String8& path, in
|
|||||||
return rightsStatus;
|
return rightsStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmPassthruPlugIn::onConsumeRights(int uniqueId, DecryptHandle* decryptHandle,
|
status_t DrmPassthruPlugIn::onConsumeRights(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
int action, bool reserve) {
|
int action, bool reserve) {
|
||||||
LOGD("DrmPassthruPlugIn::onConsumeRights() : %d", uniqueId);
|
LOGD("DrmPassthruPlugIn::onConsumeRights() : %d", uniqueId);
|
||||||
|
return DRM_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmPassthruPlugIn::onSetPlaybackStatus(int uniqueId, DecryptHandle* decryptHandle,
|
status_t DrmPassthruPlugIn::onSetPlaybackStatus(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
int playbackStatus, int position) {
|
int playbackStatus, int position) {
|
||||||
LOGD("DrmPassthruPlugIn::onSetPlaybackStatus() : %d", uniqueId);
|
LOGD("DrmPassthruPlugIn::onSetPlaybackStatus() : %d", uniqueId);
|
||||||
|
return DRM_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DrmPassthruPlugIn::onValidateAction(int uniqueId, const String8& path,
|
bool DrmPassthruPlugIn::onValidateAction(int uniqueId, const String8& path,
|
||||||
@@ -190,16 +193,19 @@ bool DrmPassthruPlugIn::onValidateAction(int uniqueId, const String8& path,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmPassthruPlugIn::onRemoveRights(int uniqueId, const String8& path) {
|
status_t DrmPassthruPlugIn::onRemoveRights(int uniqueId, const String8& path) {
|
||||||
LOGD("DrmPassthruPlugIn::onRemoveRights() : %d", uniqueId);
|
LOGD("DrmPassthruPlugIn::onRemoveRights() : %d", uniqueId);
|
||||||
|
return DRM_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmPassthruPlugIn::onRemoveAllRights(int uniqueId) {
|
status_t DrmPassthruPlugIn::onRemoveAllRights(int uniqueId) {
|
||||||
LOGD("DrmPassthruPlugIn::onRemoveAllRights() : %d", uniqueId);
|
LOGD("DrmPassthruPlugIn::onRemoveAllRights() : %d", uniqueId);
|
||||||
|
return DRM_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmPassthruPlugIn::onOpenConvertSession(int uniqueId, int convertId) {
|
status_t DrmPassthruPlugIn::onOpenConvertSession(int uniqueId, int convertId) {
|
||||||
LOGD("DrmPassthruPlugIn::onOpenConvertSession() : %d", uniqueId);
|
LOGD("DrmPassthruPlugIn::onOpenConvertSession() : %d", uniqueId);
|
||||||
|
return DRM_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrmConvertedStatus* DrmPassthruPlugIn::onConvertData(
|
DrmConvertedStatus* DrmPassthruPlugIn::onConvertData(
|
||||||
@@ -237,7 +243,7 @@ status_t DrmPassthruPlugIn::onOpenDecryptSession(
|
|||||||
return DRM_ERROR_CANNOT_HANDLE;
|
return DRM_ERROR_CANNOT_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmPassthruPlugIn::onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
|
status_t DrmPassthruPlugIn::onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
|
||||||
LOGD("DrmPassthruPlugIn::onCloseDecryptSession() : %d", uniqueId);
|
LOGD("DrmPassthruPlugIn::onCloseDecryptSession() : %d", uniqueId);
|
||||||
if (NULL != decryptHandle) {
|
if (NULL != decryptHandle) {
|
||||||
if (NULL != decryptHandle->decryptInfo) {
|
if (NULL != decryptHandle->decryptInfo) {
|
||||||
@@ -245,15 +251,17 @@ void DrmPassthruPlugIn::onCloseDecryptSession(int uniqueId, DecryptHandle* decry
|
|||||||
}
|
}
|
||||||
delete decryptHandle; decryptHandle = NULL;
|
delete decryptHandle; decryptHandle = NULL;
|
||||||
}
|
}
|
||||||
|
return DRM_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmPassthruPlugIn::onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
status_t DrmPassthruPlugIn::onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
int decryptUnitId, const DrmBuffer* headerInfo) {
|
int decryptUnitId, const DrmBuffer* headerInfo) {
|
||||||
LOGD("DrmPassthruPlugIn::onInitializeDecryptUnit() : %d", uniqueId);
|
LOGD("DrmPassthruPlugIn::onInitializeDecryptUnit() : %d", uniqueId);
|
||||||
|
return DRM_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t DrmPassthruPlugIn::onDecrypt(int uniqueId, DecryptHandle* decryptHandle,
|
status_t DrmPassthruPlugIn::onDecrypt(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer) {
|
int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
|
||||||
LOGD("DrmPassthruPlugIn::onDecrypt() : %d", uniqueId);
|
LOGD("DrmPassthruPlugIn::onDecrypt() : %d", uniqueId);
|
||||||
/**
|
/**
|
||||||
* As a workaround implementation passthru would copy the given
|
* As a workaround implementation passthru would copy the given
|
||||||
@@ -267,9 +275,10 @@ status_t DrmPassthruPlugIn::onDecrypt(int uniqueId, DecryptHandle* decryptHandle
|
|||||||
return DRM_NO_ERROR;
|
return DRM_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmPassthruPlugIn::onFinalizeDecryptUnit(
|
status_t DrmPassthruPlugIn::onFinalizeDecryptUnit(
|
||||||
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
|
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
|
||||||
LOGD("DrmPassthruPlugIn::onFinalizeDecryptUnit() : %d", uniqueId);
|
LOGD("DrmPassthruPlugIn::onFinalizeDecryptUnit() : %d", uniqueId);
|
||||||
|
return DRM_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t DrmPassthruPlugIn::onPread(int uniqueId, DecryptHandle* decryptHandle,
|
ssize_t DrmPassthruPlugIn::onPread(int uniqueId, DecryptHandle* decryptHandle,
|
||||||
|
|||||||
@@ -27,28 +27,40 @@ class String8;
|
|||||||
*/
|
*/
|
||||||
class DrmInfoEvent {
|
class DrmInfoEvent {
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* The following constant values should be in sync with DrmInfoEvent.java
|
||||||
|
*/
|
||||||
//! TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT, when registration has been
|
//! TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT, when registration has been
|
||||||
//! already done by another account ID.
|
//! already done by another account ID.
|
||||||
static const int TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT = 0x0000001;
|
static const int TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT = 1;
|
||||||
//! TYPE_REMOVE_RIGHTS, when the rights needs to be removed completely.
|
//! TYPE_REMOVE_RIGHTS, when the rights needs to be removed completely.
|
||||||
static const int TYPE_REMOVE_RIGHTS = 0x0000002;
|
static const int TYPE_REMOVE_RIGHTS = 2;
|
||||||
//! TYPE_RIGHTS_INSTALLED, when the rights are downloaded and installed ok.
|
//! TYPE_RIGHTS_INSTALLED, when the rights are downloaded and installed ok.
|
||||||
static const int TYPE_RIGHTS_INSTALLED = 0x0000003;
|
static const int TYPE_RIGHTS_INSTALLED = 3;
|
||||||
//! TYPE_RIGHTS_NOT_INSTALLED, when something went wrong installing the rights
|
|
||||||
static const int TYPE_RIGHTS_NOT_INSTALLED = 0x0000004;
|
|
||||||
//! TYPE_RIGHTS_RENEWAL_NOT_ALLOWED, when the server rejects renewal of rights
|
|
||||||
static const int TYPE_RIGHTS_RENEWAL_NOT_ALLOWED = 0x0000005;
|
|
||||||
//! TYPE_NOT_SUPPORTED, when answer from server can not be handled by the native agent
|
|
||||||
static const int TYPE_NOT_SUPPORTED = 0x0000006;
|
|
||||||
//! TYPE_WAIT_FOR_RIGHTS, rights object is on it's way to phone,
|
//! TYPE_WAIT_FOR_RIGHTS, rights object is on it's way to phone,
|
||||||
//! wait before calling checkRights again
|
//! wait before calling checkRights again
|
||||||
static const int TYPE_WAIT_FOR_RIGHTS = 0x0000007;
|
static const int TYPE_WAIT_FOR_RIGHTS = 4;
|
||||||
|
//! TYPE_ACCOUNT_ALREADY_REGISTERED, when registration has been
|
||||||
|
//! already done for the given account.
|
||||||
|
static const int TYPE_ACCOUNT_ALREADY_REGISTERED = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The following constant values should be in sync with DrmErrorEvent.java
|
||||||
|
*/
|
||||||
|
//! TYPE_RIGHTS_NOT_INSTALLED, when something went wrong installing the rights
|
||||||
|
static const int TYPE_RIGHTS_NOT_INSTALLED = 2001;
|
||||||
|
//! TYPE_RIGHTS_RENEWAL_NOT_ALLOWED, when the server rejects renewal of rights
|
||||||
|
static const int TYPE_RIGHTS_RENEWAL_NOT_ALLOWED = 2002;
|
||||||
|
//! TYPE_NOT_SUPPORTED, when answer from server can not be handled by the native agent
|
||||||
|
static const int TYPE_NOT_SUPPORTED = 2003;
|
||||||
//! TYPE_OUT_OF_MEMORY, when memory allocation fail during renewal.
|
//! TYPE_OUT_OF_MEMORY, when memory allocation fail during renewal.
|
||||||
//! Can in the future perhaps be used to trigger garbage collector
|
//! Can in the future perhaps be used to trigger garbage collector
|
||||||
static const int TYPE_OUT_OF_MEMORY = 0x0000008;
|
static const int TYPE_OUT_OF_MEMORY = 2004;
|
||||||
//! TYPE_NO_INTERNET_CONNECTION, when the Internet connection is missing and no attempt
|
//! TYPE_NO_INTERNET_CONNECTION, when the Internet connection is missing and no attempt
|
||||||
//! can be made to renew rights
|
//! can be made to renew rights
|
||||||
static const int TYPE_NO_INTERNET_CONNECTION = 0x0000009;
|
static const int TYPE_NO_INTERNET_CONNECTION = 2005;
|
||||||
|
//! TYPE_REGISTRATION_FAILED, when registration with server failed.
|
||||||
|
static const int TYPE_REGISTRATION_FAILED = 2006;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -70,8 +70,10 @@ public:
|
|||||||
* Close the decrypt session for the given handle
|
* Close the decrypt session for the given handle
|
||||||
*
|
*
|
||||||
* @param[in] decryptHandle Handle for the decryption session
|
* @param[in] decryptHandle Handle for the decryption session
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
void closeDecryptSession(DecryptHandle* decryptHandle);
|
status_t closeDecryptSession(DecryptHandle* decryptHandle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Consumes the rights for a content.
|
* Consumes the rights for a content.
|
||||||
@@ -81,8 +83,11 @@ public:
|
|||||||
* @param[in] decryptHandle Handle for the decryption session
|
* @param[in] decryptHandle Handle for the decryption session
|
||||||
* @param[in] action Action to perform. (Action::DEFAULT, Action::PLAY, etc)
|
* @param[in] action Action to perform. (Action::DEFAULT, Action::PLAY, etc)
|
||||||
* @param[in] reserve True if the rights should be reserved.
|
* @param[in] reserve True if the rights should be reserved.
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure.
|
||||||
|
* In case license has been expired, DRM_ERROR_LICENSE_EXPIRED will be returned.
|
||||||
*/
|
*/
|
||||||
void consumeRights(DecryptHandle* decryptHandle, int action, bool reserve);
|
status_t consumeRights(DecryptHandle* decryptHandle, int action, bool reserve);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Informs the DRM engine about the playback actions performed on the DRM files.
|
* Informs the DRM engine about the playback actions performed on the DRM files.
|
||||||
@@ -90,9 +95,11 @@ public:
|
|||||||
* @param[in] decryptHandle Handle for the decryption session
|
* @param[in] decryptHandle Handle for the decryption session
|
||||||
* @param[in] playbackStatus Playback action (Playback::START, Playback::STOP, Playback::PAUSE)
|
* @param[in] playbackStatus Playback action (Playback::START, Playback::STOP, Playback::PAUSE)
|
||||||
* @param[in] position Position in the file (in milliseconds) where the start occurs.
|
* @param[in] position Position in the file (in milliseconds) where the start occurs.
|
||||||
* Only valid together with Playback::START.
|
* Only valid together with Playback::START.
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
void setPlaybackStatus(DecryptHandle* decryptHandle, int playbackStatus, int position);
|
status_t setPlaybackStatus(DecryptHandle* decryptHandle, int playbackStatus, int position);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize decryption for the given unit of the protected content
|
* Initialize decryption for the given unit of the protected content
|
||||||
@@ -100,8 +107,10 @@ public:
|
|||||||
* @param[in] decryptHandle Handle for the decryption session
|
* @param[in] decryptHandle Handle for the decryption session
|
||||||
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
|
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
|
||||||
* @param[in] headerInfo Information for initializing decryption of this decrypUnit
|
* @param[in] headerInfo Information for initializing decryption of this decrypUnit
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
void initializeDecryptUnit(
|
status_t initializeDecryptUnit(
|
||||||
DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo);
|
DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -113,6 +122,7 @@ public:
|
|||||||
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
|
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
|
||||||
* @param[in] encBuffer Encrypted data block
|
* @param[in] encBuffer Encrypted data block
|
||||||
* @param[out] decBuffer Decrypted data block
|
* @param[out] decBuffer Decrypted data block
|
||||||
|
* @param[in] IV Optional buffer
|
||||||
* @return status_t
|
* @return status_t
|
||||||
* Returns the error code for this API
|
* Returns the error code for this API
|
||||||
* DRM_NO_ERROR for success, and one of DRM_ERROR_UNKNOWN, DRM_ERROR_LICENSE_EXPIRED
|
* DRM_NO_ERROR for success, and one of DRM_ERROR_UNKNOWN, DRM_ERROR_LICENSE_EXPIRED
|
||||||
@@ -121,15 +131,17 @@ public:
|
|||||||
*/
|
*/
|
||||||
status_t decrypt(
|
status_t decrypt(
|
||||||
DecryptHandle* decryptHandle, int decryptUnitId,
|
DecryptHandle* decryptHandle, int decryptUnitId,
|
||||||
const DrmBuffer* encBuffer, DrmBuffer** decBuffer);
|
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV = NULL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finalize decryption for the given unit of the protected content
|
* Finalize decryption for the given unit of the protected content
|
||||||
*
|
*
|
||||||
* @param[in] decryptHandle Handle for the decryption session
|
* @param[in] decryptHandle Handle for the decryption session
|
||||||
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
|
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
void finalizeDecryptUnit(DecryptHandle* decryptHandle, int decryptUnitId);
|
status_t finalizeDecryptUnit(DecryptHandle* decryptHandle, int decryptUnitId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the specified number of bytes from an open DRM file.
|
* Reads the specified number of bytes from an open DRM file.
|
||||||
@@ -217,8 +229,10 @@ public:
|
|||||||
* @param[in] drmRights DrmRights to be saved
|
* @param[in] drmRights DrmRights to be saved
|
||||||
* @param[in] rightsPath File path where rights to be saved
|
* @param[in] rightsPath File path where rights to be saved
|
||||||
* @param[in] contentPath File path where content was saved
|
* @param[in] contentPath File path where content was saved
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
void saveRights(
|
status_t saveRights(
|
||||||
const DrmRights& drmRights, const String8& rightsPath, const String8& contentPath);
|
const DrmRights& drmRights, const String8& rightsPath, const String8& contentPath);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -256,15 +270,19 @@ public:
|
|||||||
* Removes the rights associated with the given protected content
|
* Removes the rights associated with the given protected content
|
||||||
*
|
*
|
||||||
* @param[in] path Path of the protected content
|
* @param[in] path Path of the protected content
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
void removeRights(const String8& path);
|
status_t removeRights(const String8& path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all the rights information of each plug-in associated with
|
* Removes all the rights information of each plug-in associated with
|
||||||
* DRM framework. Will be used in master reset
|
* DRM framework. Will be used in master reset
|
||||||
*
|
*
|
||||||
|
* @return status_t
|
||||||
|
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
void removeAllRights();
|
status_t removeAllRights();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This API is for Forward Lock DRM.
|
* This API is for Forward Lock DRM.
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Destructor for DrmRights
|
* Destructor for DrmRights
|
||||||
*/
|
*/
|
||||||
virtual ~DrmRights() {}
|
virtual ~DrmRights();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@@ -97,6 +97,7 @@ private:
|
|||||||
String8 mMimeType;
|
String8 mMimeType;
|
||||||
String8 mAccountId;
|
String8 mAccountId;
|
||||||
String8 mSubscriptionId;
|
String8 mSubscriptionId;
|
||||||
|
char* mRightsFromFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -254,13 +254,13 @@ public:
|
|||||||
* (file format is not encrypted but ES is encrypted)
|
* (file format is not encrypted but ES is encrypted)
|
||||||
* e.g., Marlin DRM (MP4 file format), WM-DRM (asf file format)
|
* e.g., Marlin DRM (MP4 file format), WM-DRM (asf file format)
|
||||||
*
|
*
|
||||||
* DecryptAPI::TYPE_ELEMENTARY_STREAM_BASED
|
* DecryptApiType::ELEMENTARY_STREAM_BASED
|
||||||
* Decryption API set for ES based DRM
|
* Decryption API set for ES based DRM
|
||||||
* initializeDecryptUnit(), decrypt(), and finalizeDecryptUnit()
|
* initializeDecryptUnit(), decrypt(), and finalizeDecryptUnit()
|
||||||
* 2. Decrypt APIs for container based DRM (file format itself is encrypted)
|
* 2. Decrypt APIs for container based DRM (file format itself is encrypted)
|
||||||
* e.g., OMA DRM (dcf file format)
|
* e.g., OMA DRM (dcf file format)
|
||||||
*
|
*
|
||||||
* DecryptAPI::TYPE_CONTAINER_BASED
|
* DecryptApiType::CONTAINER_BASED
|
||||||
* POSIX based Decryption API set for container based DRM
|
* POSIX based Decryption API set for container based DRM
|
||||||
* pread()
|
* pread()
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user