Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eb8c7bf6 authored by Marco Nelissen's avatar Marco Nelissen
Browse files

Remove support for loading extractors from apk

Bug: 123250010
Test: boot, play video
Change-Id: I19c66d76f98a593ac9082054a2faccedcd73a55d
parent 850847df
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -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",
+0 −25
Original line number Diff line number Diff line
/*
 * 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);
}
+3 −64
Original line number Diff line number Diff line
@@ -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;

+1 −4
Original line number Diff line number Diff line
@@ -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
+1 −2
Original line number Diff line number Diff line
@@ -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
Loading