Skip to content

Commit

Permalink
[droidmedia] Rewrite miniaudiopolicy to spawn a fake service. JB#56158
Browse files Browse the repository at this point in the history
The old miniaudiopolicy spawned a full instance auf audiopolicy spawn
a fake instance that does nothing instead.

Signed-off-by: Björn Bidar <[email protected]>
  • Loading branch information
Thaodan committed Jul 14, 2022
1 parent 38c5544 commit da23715
Show file tree
Hide file tree
Showing 10 changed files with 2,363 additions and 16 deletions.
20 changes: 14 additions & 6 deletions Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,14 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := minimedia.cpp
LOCAL_C_INCLUDES := frameworks/av/services/camera/libcameraservice \
frameworks/av/media/libmediaplayerservice \
system/media/camera/include
system/media/camera/include \
$(call include-path-for, audio-utils) \
frameworks/av/media/libaaudio/include \
frameworks/av/media/libaaudio/src \
frameworks/av/media/libaaudio/src/binding \
frameworks/av/media/libmedia \
frameworks/av/services/audioflinger

LOCAL_SHARED_LIBRARIES := libcameraservice \
libmediaplayerservice \
libcamera_client \
Expand All @@ -135,7 +142,6 @@ LOCAL_SHARED_LIBRARIES := libcameraservice \
libcutils \
libui

ifeq ($(MINIMEDIA_AUDIOPOLICYSERVICE_ENABLE),1)
ifeq ($(ANDROID_MAJOR),$(filter $(ANDROID_MAJOR),5))
LOCAL_C_INCLUDES += frameworks/av/services/audiopolicy
else
Expand All @@ -146,7 +152,12 @@ LOCAL_C_INCLUDES += frameworks/av/services/audiopolicy \
frameworks/av/services/audiopolicy/managerdefault \
frameworks/av/services/audiopolicy/service
endif
LOCAL_SHARED_LIBRARIES += libaudiopolicyservice

# libmedia was split into libmedia and libaudioclient starting with A7
ifeq ($(shell test $(ANDROID_MAJOR) -ge 7 && echo true),true)
LOCAL_SHARED_LIBRARIES += libaudioclient
else
LOCAL_SHARED_LIBRARIES += libmedia
endif

ifeq ($(ANDROID_MAJOR),$(filter $(ANDROID_MAJOR),8 9))
Expand Down Expand Up @@ -194,9 +205,6 @@ LOCAL_CPPFLAGS=-DANDROID_MAJOR=$(ANDROID_MAJOR) -DANDROID_MINOR=$(ANDROID_MINOR)
ifeq ($(MINIMEDIA_SENSORSERVER_DISABLE),1)
LOCAL_CPPFLAGS += -DSENSORSERVER_DISABLE
endif
ifeq ($(MINIMEDIA_AUDIOPOLICYSERVICE_ENABLE),1)
LOCAL_CPPFLAGS += -DAUDIOPOLICYSERVICE_ENABLE
endif
LOCAL_MODULE := minimediaservice
ifeq ($(strip $(DROIDMEDIA_32)), true)
LOCAL_32_BIT_ONLY := true
Expand Down
8 changes: 2 additions & 6 deletions minimedia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
#include <CameraService.h>
#ifdef AUDIOPOLICYSERVICE_ENABLE
#include <AudioPolicyService.h>
#endif
#include <binder/MemoryHeapBase.h>
#include <MediaPlayerService.h>
#if ANDROID_MAJOR >= 6
Expand All @@ -39,6 +36,7 @@
#include "allocator.h"
#endif
#include "services/services.h"
#include "services/audiopolicy/audiopolicy.h"

#include <cutils/properties.h>

Expand All @@ -64,9 +62,7 @@ main(int, char**)
FakeActivityManager::instantiate();
#endif
MediaPlayerService::instantiate();
#ifdef AUDIOPOLICYSERVICE_ENABLE
AudioPolicyService::instantiate();
#endif
FakeAudioPolicyService::instantiate();

// PermissionController and AppOps are needed on Android 4, but aren't allowed to be run here.
#if ANDROID_MAJOR >= 5
Expand Down
17 changes: 13 additions & 4 deletions rpm/droidmedia.spec
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,27 @@ DROIDLIB=lib
fi

mkdir -p $RPM_BUILD_ROOT/%{_libexecdir}/droid-hybris/system/$DROIDLIB/
mkdir -p $RPM_BUILD_ROOT/%{_libexecdir}/droid-hybris/system/etc/init
mkdir -p $RPM_BUILD_ROOT/%{_libexecdir}/droid-hybris/system/bin/

cp out/target/product/*/system/$DROIDLIB/libdroidmedia.so \
$RPM_BUILD_ROOT/%{_libexecdir}/droid-hybris/system/$DROIDLIB/
$RPM_BUILD_ROOT/%{_libexecdir}/droid-hybris/system/$DROIDLIB/

cp out/target/product/*/system/$DROIDLIB/libminisf.so \
$RPM_BUILD_ROOT/%{_libexecdir}/droid-hybris/system/$DROIDLIB/
$RPM_BUILD_ROOT/%{_libexecdir}/droid-hybris/system/$DROIDLIB/

cp out/target/product/*/system/bin/minimediaservice \
$RPM_BUILD_ROOT/%{_libexecdir}/droid-hybris/system/bin/
$RPM_BUILD_ROOT/%{_libexecdir}/droid-hybris/system/bin/

cp out/target/product/*/system/bin/minisfservice \
$RPM_BUILD_ROOT/%{_libexecdir}/droid-hybris/system/bin/
$RPM_BUILD_ROOT/%{_libexecdir}/droid-hybris/system/bin/

cp external/droidmedia/init/*.rc \
$RPM_BUILD_ROOT/%{_libexecdir}/droid-hybris/system/etc/init/

cp out/target/product/*/system/bin/miniaudiopolicyservice \
$RPM_BUILD_ROOT/%{_libexecdir}/droid-hybris/system/bin/


LIBDMSOLOC=$RPM_BUILD_ROOT/file.list
echo %{_libexecdir}/droid-hybris/system/$DROIDLIB/libdroidmedia.so >> %{LIBDMSOLOC}
Expand All @@ -93,3 +101,4 @@ echo %{_libexecdir}/droid-hybris/system/$DROIDLIB/libminisf.so >> %{LIBDMSOLOC}
%defattr(-,root,root,-)
%{_libexecdir}/droid-hybris/system/bin/minimediaservice
%{_libexecdir}/droid-hybris/system/bin/minisfservice
%{_libexecdir}/droid-hybris/system/etc/init/*
41 changes: 41 additions & 0 deletions services/audiopolicy/audiopolicy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (C) 2022 Jolla Ltd.
*
* 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.
*
*/


#if ANDROID_MAJOR == 6 && ANDROID_MINOR == 0
#include "audiopolicy_6_0_0.h"
#endif

#if ANDROID_MAJOR == 7 && ANDROID_MINOR == 0
#include "audiopolicy_7_0_0.h"
#endif

#if ANDROID_MAJOR == 8 && ANDROID_MINOR == 1
#include "audiopolicy_8_1_0.h"
#endif

#if ANDROID_MAJOR == 9
#include "audiopolicy_9_0_0.h"
#endif

#if ANDROID_MAJOR == 10
#include "audiopolicy_10_0_0.h"
#endif

#if ANDROID_MAJOR == 11
#include "audiopolicy_11_0_0.h"
#endif
Loading

0 comments on commit da23715

Please sign in to comment.