3535#include " FwdLockConv.h"
3636#include " FwdLockFile.h"
3737#include " FwdLockGlue.h"
38- #include " FwdLockEngineConst.h"
3938#include " MimeTypeUtil.h"
4039
4140#undef LOG_TAG
@@ -160,19 +159,58 @@ android::status_t FwdLockEngine::onTerminate(int uniqueId) {
160159 return DRM_NO_ERROR;
161160}
162161
162+ const String8 FwdLockEngine::FileSuffixes[] = {
163+ String8 (" .fl" ),
164+ String8 (" .dm" ),
165+ };
166+
167+ const String8 FwdLockEngine::MimeTypes[] = {
168+ String8 (" application/x-android-drm-fl" ),
169+ String8 (" application/vnd.oma.drm.message" ),
170+ };
171+
172+ const String8 FwdLockEngine::Description (" OMA V1 Forward Lock" );
173+
174+ void FwdLockEngine::AddSupportedMimeTypes (DrmSupportInfo *info) {
175+ for (size_t i = 0 , n = sizeof (MimeTypes)/sizeof (MimeTypes[0 ]); i < n; ++i) {
176+ info->addMimeType (MimeTypes[i]);
177+ }
178+ }
179+
180+ void FwdLockEngine::AddSupportedFileSuffixes (DrmSupportInfo *info) {
181+ for (size_t i = 0 , n = sizeof (FileSuffixes)/sizeof (FileSuffixes[0 ]); i < n; ++i) {
182+ info->addFileSuffix (FileSuffixes[i]);
183+ }
184+ }
185+
186+ bool FwdLockEngine::IsMimeTypeSupported (const String8& mime) {
187+ for (size_t i = 0 , n = sizeof (MimeTypes)/sizeof (MimeTypes[0 ]); i < n; ++i) {
188+ if (mime == MimeTypes[i]) {
189+ return true ;
190+ }
191+ }
192+ return false ;
193+ }
194+
195+ bool FwdLockEngine::IsFileSuffixSupported (const String8& suffix) {
196+ for (size_t i = 0 , n = sizeof (FileSuffixes)/sizeof (FileSuffixes[0 ]); i < n; ++i) {
197+ if (suffix == FileSuffixes[i]) {
198+ return true ;
199+ }
200+ }
201+ return false ;
202+ }
203+
163204DrmSupportInfo* FwdLockEngine::onGetSupportInfo (int uniqueId) {
164205 DrmSupportInfo* pSupportInfo = new DrmSupportInfo ();
165206
166207 LOG_VERBOSE (" FwdLockEngine::onGetSupportInfo" );
167208
168209 // fill all Forward Lock mimetypes and extensions
169210 if (NULL != pSupportInfo) {
170- pSupportInfo->addMimeType (String8 (FWDLOCK_MIMETYPE_FL));
171- pSupportInfo->addFileSuffix (String8 (FWDLOCK_DOTEXTENSION_FL));
172- pSupportInfo->addMimeType (String8 (FWDLOCK_MIMETYPE_DM));
173- pSupportInfo->addFileSuffix (String8 (FWDLOCK_DOTEXTENSION_DM));
174-
175- pSupportInfo->setDescription (String8 (FWDLOCK_DESCRIPTION));
211+ AddSupportedMimeTypes (pSupportInfo);
212+ AddSupportedFileSuffixes (pSupportInfo);
213+ pSupportInfo->setDescription (Description);
176214 }
177215
178216 return pSupportInfo;
@@ -182,14 +220,8 @@ bool FwdLockEngine::onCanHandle(int uniqueId, const String8& path) {
182220 bool result = false ;
183221
184222 String8 extString = path.getPathExtension ();
185-
186223 extString.toLower ();
187-
188- if ((extString == String8 (FWDLOCK_DOTEXTENSION_FL)) ||
189- (extString == String8 (FWDLOCK_DOTEXTENSION_DM))) {
190- result = true ;
191- }
192- return result;
224+ return IsFileSuffixSupported (extString);
193225}
194226
195227DrmInfoStatus* FwdLockEngine::onProcessDrmInfo (int uniqueId, const DrmInfo* drmInfo) {
@@ -308,8 +340,7 @@ int FwdLockEngine::onGetDrmObjectType(int uniqueId,
308340 * (regardless of the relation between them to make it compatible with other DRM Engines)
309341 */
310342 if (((0 == path.length ()) || onCanHandle (uniqueId, path)) &&
311- ((0 == mimeType.length ()) || ((mimeStr == String8 (FWDLOCK_MIMETYPE_FL)) ||
312- (mimeStr == String8 (FWDLOCK_MIMETYPE_DM)))) && (mimeType != path) ) {
343+ ((0 == mimeType.length ()) || IsMimeTypeSupported (mimeType)) && (mimeType != path) ) {
313344 return DrmObjectType::CONTENT;
314345 }
315346
0 commit comments