Remove support for loading extractors from apk

Bug: 123250010
Test: boot, play video
Change-Id: I19c66d76f98a593ac9082054a2faccedcd73a55d
gugelfrei
Marco Nelissen 6 years ago
parent 850847df03
commit eb8c7bf64a

@ -144,18 +144,10 @@ cc_library_static {
},
}
filegroup {
name: "mediaupdateservice_aidl",
srcs: [
"aidl/android/media/IMediaUpdateService.aidl",
],
}
cc_library {
name: "libmedia",
srcs: [
":mediaupdateservice_aidl",
"IDataSource.cpp",
"BufferingSettings.cpp",
"mediaplayer.cpp",

@ -1,25 +0,0 @@
/*
* Copyright 2018 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.media;
/**
* Service to reload media component plugins when update package is installed/uninstalled.
* @hide
*/
interface IMediaUpdateService {
void loadPlugins(@utf8InCpp String apkPath);
}

@ -89,7 +89,7 @@ sp<IMediaExtractor> MediaExtractorFactory::CreateFromService(
ALOGV("MediaExtractorFactory::CreateFromService %s", mime);
UpdateExtractors(nullptr);
UpdateExtractors();
// initialize source decryption if needed
source->DrmInitialization(nullptr /* mime */);
@ -122,13 +122,6 @@ sp<IMediaExtractor> MediaExtractorFactory::CreateFromService(
return CreateIMediaExtractorFromMediaExtractor(ex, source, plugin);
}
//static
void MediaExtractorFactory::LoadPlugins(const ::std::string& apkPath) {
// TODO: Verify apk path with package manager in extractor process.
ALOGV("Load plugins from: %s", apkPath.c_str());
UpdateExtractors(apkPath.empty() ? nullptr : apkPath.c_str());
}
struct ExtractorPlugin : public RefBase {
ExtractorDef def;
void *libHandle;
@ -257,54 +250,6 @@ void MediaExtractorFactory::RegisterExtractor(const sp<ExtractorPlugin> &plugin,
pluginList.push_back(plugin);
}
//static
void MediaExtractorFactory::RegisterExtractorsInApk(
const char *apkPath, std::list<sp<ExtractorPlugin>> &pluginList) {
ALOGV("search for plugins at %s", apkPath);
ZipArchiveHandle zipHandle;
int32_t ret = OpenArchive(apkPath, &zipHandle);
if (ret == 0) {
char abi[PROPERTY_VALUE_MAX];
property_get("ro.product.cpu.abi", abi, "arm64-v8a");
String8 prefix8 = String8::format("lib/%s/", abi);
ZipString prefix(prefix8.c_str());
ZipString suffix("extractor.so");
void* cookie;
ret = StartIteration(zipHandle, &cookie, &prefix, &suffix);
if (ret == 0) {
ZipEntry entry;
ZipString name;
while (Next(cookie, &entry, &name) == 0) {
String8 libPath = String8(apkPath) + "!/" +
String8(reinterpret_cast<const char*>(name.name), name.name_length);
// TODO: Open with a linker namespace so that it can be linked with sub-libraries
// within the apk instead of system libraries already loaded.
void *libHandle = dlopen(libPath.string(), RTLD_NOW | RTLD_LOCAL);
if (libHandle) {
GetExtractorDef getDef =
(GetExtractorDef) dlsym(libHandle, "GETEXTRACTORDEF");
if (getDef) {
ALOGV("registering sniffer for %s", libPath.string());
RegisterExtractor(
new ExtractorPlugin(getDef(), libHandle, libPath), pluginList);
} else {
ALOGW("%s does not contain sniffer", libPath.string());
dlclose(libHandle);
}
} else {
ALOGW("couldn't dlopen(%s) %s", libPath.string(), strerror(errno));
}
}
EndIteration(cookie);
} else {
ALOGW("couldn't find plugins from %s, %d", apkPath, ret);
}
CloseArchive(zipHandle);
} else {
ALOGW("couldn't open(%s) %d", apkPath, ret);
}
}
//static
void MediaExtractorFactory::RegisterExtractorsInSystem(
const char *libDirPath, std::list<sp<ExtractorPlugin>> &pluginList) {
@ -412,11 +357,9 @@ static bool compareFunc(const sp<ExtractorPlugin>& first, const sp<ExtractorPlug
static std::unordered_set<std::string> gSupportedExtensions;
// static
void MediaExtractorFactory::UpdateExtractors(const char *newUpdateApkPath) {
void MediaExtractorFactory::UpdateExtractors() {
Mutex::Autolock autoLock(gPluginMutex);
if (newUpdateApkPath != nullptr) {
gPluginsRegistered = false;
}
if (gPluginsRegistered) {
return;
}
@ -437,10 +380,6 @@ void MediaExtractorFactory::UpdateExtractors(const char *newUpdateApkPath) {
#endif
"/extractors", *newList);
if (newUpdateApkPath != nullptr) {
RegisterExtractorsInApk(newUpdateApkPath, *newList);
}
newList->sort(compareFunc);
gPlugins = newList;

@ -34,7 +34,6 @@ public:
const sp<DataSource> &source, const char *mime = NULL);
static sp<IMediaExtractor> CreateFromService(
const sp<DataSource> &source, const char *mime = NULL);
static void LoadPlugins(const ::std::string& apkPath);
static status_t dump(int fd, const Vector<String16>& args);
static std::unordered_set<std::string> getSupportedTypes();
static void SetLinkedLibraries(const std::string& linkedLibraries);
@ -46,8 +45,6 @@ private:
static bool gIgnoreVersion;
static std::string gLinkedLibraries;
static void RegisterExtractorsInApk(
const char *apkPath, std::list<sp<ExtractorPlugin>> &pluginList);
static void RegisterExtractorsInSystem(
const char *libDirPath, std::list<sp<ExtractorPlugin>> &pluginList);
static void RegisterExtractorsInApex(
@ -59,7 +56,7 @@ private:
float *confidence, void **meta, FreeMetaFunc *freeMeta,
sp<ExtractorPlugin> &plugin, uint32_t *creatorVersion);
static void UpdateExtractors(const char *newUpdateApkPath);
static void UpdateExtractors();
};
} // namespace android

@ -4,8 +4,7 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS := -Wall -Werror
LOCAL_SRC_FILES := \
MediaExtractorService.cpp \
MediaExtractorUpdateService.cpp \
MediaExtractorService.cpp
LOCAL_SHARED_LIBRARIES := libmedia libstagefright libbinder libutils liblog
LOCAL_MODULE:= libmediaextractorservice

@ -1,35 +0,0 @@
/*
* Copyright 2018 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.
*/
#define LOG_TAG "MediaExtractorUpdateService"
#define LOG_NDEBUG 0
#include <utils/Log.h>
#include <media/stagefright/MediaExtractorFactory.h>
#include "MediaExtractorUpdateService.h"
namespace android {
namespace media {
binder::Status MediaExtractorUpdateService::loadPlugins(const ::std::string& apkPath) {
ALOGV("loadPlugins %s", apkPath.c_str());
MediaExtractorFactory::LoadPlugins(apkPath);
return binder::Status::ok();
}
} // namespace media
} // namespace android

@ -1,40 +0,0 @@
/*
* Copyright 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_MEDIA_EXTRACTOR_UPDATE_SERVICE_H
#define ANDROID_MEDIA_EXTRACTOR_UPDATE_SERVICE_H
#include <binder/BinderService.h>
#include <android/media/BnMediaUpdateService.h>
namespace android {
namespace media {
class MediaExtractorUpdateService
: public BinderService<MediaExtractorUpdateService>, public BnMediaUpdateService
{
friend class BinderService<MediaExtractorUpdateService>;
public:
MediaExtractorUpdateService() : BnMediaUpdateService() { }
virtual ~MediaExtractorUpdateService() { }
static const char* getServiceName() { return "media.extractor.update"; }
binder::Status loadPlugins(const ::std::string& apkPath);
};
} // namespace media
} // namespace android
#endif // ANDROID_MEDIA_EXTRACTOR_UPDATE_SERVICE_H

@ -31,7 +31,6 @@
// from LOCAL_C_INCLUDES
#include "IcuUtils.h"
#include "MediaExtractorService.h"
#include "MediaExtractorUpdateService.h"
#include "MediaUtils.h"
#include "minijail.h"
@ -72,11 +71,6 @@ int main(int argc __unused, char** argv)
sp<IServiceManager> sm = defaultServiceManager();
MediaExtractorService::instantiate();
std::string value = base::GetProperty("ro.build.type", "unknown");
if (value == "userdebug" || value == "eng") {
media::MediaExtractorUpdateService::instantiate();
}
ProcessState::self()->startThreadPool();
IPCThreadState::self()->joinThreadPool();
}

Loading…
Cancel
Save