Skip to content

Commit a220a29

Browse files
Gloria WangAndroid Code Review
authored andcommitted
Merge "Initial OMA DRM forward lock contribution"
2 parents bdb7aee + a3e96bf commit a220a29

File tree

27 files changed

+5370
-0
lines changed

27 files changed

+5370
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
# Copyright (C) 2010 The Android Open Source Project
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
include $(call all-subdir-makefiles)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#
2+
# Copyright (C) 2010 The Android Open Source Project
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
LOCAL_PATH:= $(call my-dir)
17+
18+
include $(CLEAR_VARS)
19+
20+
LOCAL_SRC_FILES := \
21+
src/MimeTypeUtil.cpp
22+
23+
LOCAL_MODULE := libdrmutility
24+
25+
LOCAL_SHARED_LIBRARIES := \
26+
libutils \
27+
libdl \
28+
libdvm \
29+
libandroid_runtime \
30+
libnativehelper \
31+
liblog
32+
33+
34+
base := frameworks/base
35+
36+
LOCAL_C_INCLUDES += \
37+
$(JNI_H_INCLUDE) \
38+
$(base)/include \
39+
$(base)/include/drm \
40+
$(base)/include/drm/plugins \
41+
$(LOCAL_PATH)/include
42+
43+
44+
ifneq ($(TARGET_BUILD_VARIANT),user)
45+
LOCAL_C_INCLUDES += \
46+
$(LOCAL_PATH)/tools
47+
48+
endif
49+
50+
LOCAL_MODULE_TAGS := optional
51+
52+
include $(BUILD_STATIC_LIBRARY)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright (C) 2010 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef __MIMETYPEUTIL_H__
18+
#define __MIMETYPEUTIL_H__
19+
20+
#include <utils/String8.h>
21+
22+
namespace android {
23+
24+
class MimeTypeUtil {
25+
26+
public:
27+
28+
MimeTypeUtil() {}
29+
30+
virtual ~MimeTypeUtil() {}
31+
32+
/**
33+
* May convert the mimetype if there is a well known
34+
* replacement mimetype otherwise the original mimetype
35+
* is returned.
36+
*
37+
* @param mimeType - mimetype in lower case to convert.
38+
*
39+
* @return mimetype or null.
40+
*/
41+
static String8 convertMimeType(String8& mimeType);
42+
43+
};
44+
};
45+
46+
#endif /* __MIMETYPEUTIL_H__ */
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
/*
2+
* Copyright (C) 2010 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef __SESSIONMAP_H__
18+
#define __SESSIONMAP_H__
19+
20+
#include <utils/KeyedVector.h>
21+
22+
namespace android {
23+
24+
/**
25+
* A wrapper template class for handling DRM Engine sessions.
26+
*/
27+
template <typename NODE>
28+
class SessionMap {
29+
30+
public:
31+
KeyedVector<int, NODE> map;
32+
33+
SessionMap() {}
34+
35+
virtual ~SessionMap() {
36+
destroyMap();
37+
}
38+
39+
/**
40+
* Adds a new value in the session map table. It expects memory to be allocated already
41+
* for the session object
42+
*
43+
* @param key - key or Session ID
44+
* @param value - session object to add
45+
*
46+
* @return boolean result of adding value. returns false if key is already exist.
47+
*/
48+
bool addValue(int key, NODE value) {
49+
bool result = false;
50+
51+
if (!isCreated(key)) {
52+
map.add(key, value);
53+
result = true;
54+
}
55+
56+
return result;
57+
}
58+
59+
60+
/**
61+
* returns the session object by the key
62+
*
63+
* @param key - key or Session ID
64+
*
65+
* @return session object as per the key
66+
*/
67+
NODE getValue(int key) {
68+
NODE value = NULL;
69+
70+
if (isCreated(key)) {
71+
value = (NODE) map.valueFor(key);
72+
}
73+
74+
return value;
75+
}
76+
77+
/**
78+
* returns the number of objects in the session map table
79+
*
80+
* @return count of number of session objects.
81+
*/
82+
int getSize() {
83+
return map.size();
84+
}
85+
86+
/**
87+
* returns the session object by the index in the session map table
88+
*
89+
* @param index - index of the value required
90+
*
91+
* @return session object as per the index
92+
*/
93+
NODE getValueAt(unsigned int index) {
94+
NODE value = NULL;
95+
96+
if (map.size() > index) {
97+
value = map.valueAt(index);
98+
}
99+
100+
return value;
101+
}
102+
103+
/**
104+
* deletes the object from session map. It also frees up memory for the session object.
105+
*
106+
* @param key - key of the value to be deleted
107+
*
108+
*/
109+
void removeValue(int key) {
110+
deleteValue(getValue(key));
111+
map.removeItem(key);
112+
}
113+
114+
/**
115+
* decides if session is already created.
116+
*
117+
* @param key - key of the value for the session
118+
*
119+
* @return boolean result of whether session is created
120+
*/
121+
bool isCreated(int key) {
122+
return (0 <= map.indexOfKey(key));
123+
}
124+
125+
/**
126+
* empty the entire session table. It releases all the memory for session objects.
127+
*/
128+
void destroyMap() {
129+
int size = map.size();
130+
int i = 0;
131+
132+
for (i = 0; i < size; i++) {
133+
deleteValue(map.valueAt(i));
134+
}
135+
136+
map.clear();
137+
}
138+
139+
/**
140+
* free up the memory for the session object.
141+
* Make sure if any reference to the session object anywhere, otherwise it will be a
142+
* dangle pointer after this call.
143+
*
144+
* @param value - session object to free
145+
*
146+
*/
147+
void deleteValue(NODE value) {
148+
delete value;
149+
}
150+
151+
};
152+
153+
};
154+
155+
#endif /* __SESSIONMAP_H__ */

0 commit comments

Comments
 (0)