Loading services/core/java/com/android/server/media/quality/MediaQualityService.java +40 −43 Original line number Diff line number Diff line Loading @@ -127,17 +127,17 @@ public class MediaQualityService extends SystemService { super(context); mContext = context; mHalAmbientBacklightCallback = new HalAmbientBacklightCallback(); mPictureProfileAdjListener = new PictureProfileAdjustmentListenerImpl(mContext); mSoundProfileAdjListener = new SoundProfileAdjustmentListenerImpl(mContext); mPackageManager = mContext.getPackageManager(); mPictureProfileTempIdMap = new BiMap<>(); mSoundProfileTempIdMap = new BiMap<>(); mMediaQualityDbHelper = new MediaQualityDbHelper(mContext); mMqDatabaseUtils = new MqDatabaseUtils(mContext); mMediaQualityDbHelper.setWriteAheadLoggingEnabled(true); mMediaQualityDbHelper.setIdleConnectionTimeout(30); mHalNotifier = new HalNotifier(); mMqManagerNotifier = new MqManagerNotifier(); mMqDatabaseUtils = new MqDatabaseUtils(); mHalNotifier = new HalNotifier(); mPictureProfileAdjListener = new PictureProfileAdjustmentListenerImpl(); mSoundProfileAdjListener = new SoundProfileAdjustmentListenerImpl(); // The package info in the context isn't initialized in the way it is for normal apps, // so the standard, name-based context.getSharedPreferences doesn't work. Instead, we Loading Loading @@ -166,16 +166,18 @@ public class MediaQualityService extends SystemService { if (mMediaQuality != null) { try { mMediaQuality.setAmbientBacklightCallback(mHalAmbientBacklightCallback); mPpChangedListener = mMediaQuality.getPictureProfileListener(); mSpChangedListener = mMediaQuality.getSoundProfileListener(); mMediaQuality.setPictureProfileAdjustmentListener(mPictureProfileAdjListener); mMediaQuality.setSoundProfileAdjustmentListener(mSoundProfileAdjListener); } catch (RemoteException e) { Slog.e(TAG, "Failed to set ambient backlight detector callback", e); } } mPpChangedListener = IPictureProfileChangedListener.Stub.asInterface(binder); mSpChangedListener = ISoundProfileChangedListener.Stub.asInterface(binder); publishBinderService(Context.MEDIA_QUALITY_SERVICE, new BinderService()); } Loading Loading @@ -225,7 +227,6 @@ public class MediaQualityService extends SystemService { PictureProfile.ERROR_NO_PERMISSION, Binder.getCallingUid(), Binder.getCallingPid()); } synchronized (mPictureProfileLock) { ContentValues values = MediaQualityUtils.getContentValues(dbId, pp.getProfileType(), Loading @@ -233,7 +234,6 @@ public class MediaQualityService extends SystemService { pp.getPackageName(), pp.getInputId(), pp.getParameters()); updateDatabaseOnPictureProfileAndNotifyManagerAndHal(values, pp.getParameters()); } } Loading Loading @@ -792,7 +792,6 @@ public class MediaQualityService extends SystemService { } } //TODO: do I need a lock here? @Override public List<ParameterCapability> getParameterCapabilities( List<String> names, UserHandle user) { Loading @@ -809,7 +808,10 @@ public class MediaQualityService extends SystemService { private List<ParameterCapability> getListParameterCapability(ParamCapability[] caps) { List<ParameterCapability> pcList = new ArrayList<>(); if (caps != null) { for (ParamCapability pcHal : caps) { if (pcHal != null) { String name = MediaQualityUtils.getParameterName(pcHal.name); boolean isSupported = pcHal.isSupported; int type = pcHal.defaultValue == null ? 0 : pcHal.defaultValue.getTag() + 1; Loading @@ -817,6 +819,9 @@ public class MediaQualityService extends SystemService { pcList.add(new ParameterCapability(name, isSupported, type, bundle)); } } } return pcList; } Loading Loading @@ -1112,8 +1117,6 @@ public class MediaQualityService extends SystemService { private final class MqDatabaseUtils { MediaQualityDbHelper mMediaQualityDbHelper; private PictureProfile getPictureProfile(Long dbId) { String selection = BaseParameters.PARAMETER_ID + " = ?"; String[] selectionArguments = {Long.toString(dbId)}; Loading Loading @@ -1205,8 +1208,7 @@ public class MediaQualityService extends SystemService { /*groupBy=*/ null, /*having=*/ null, /*orderBy=*/ null); } private MqDatabaseUtils(Context context) { mMediaQualityDbHelper = new MediaQualityDbHelper(context); private MqDatabaseUtils() { } } Loading Loading @@ -1404,6 +1406,7 @@ public class MediaQualityService extends SystemService { private void notifyHalOnPictureProfileChange(Long dbId, PersistableBundle params) { // TODO: only notify HAL when the profile is active / being used if (mPpChangedListener != null) { try { mPpChangedListener.onPictureProfileChanged(convertToHalPictureProfile(dbId, params)); Loading @@ -1411,6 +1414,7 @@ public class MediaQualityService extends SystemService { Slog.e(TAG, "Failed to notify HAL on picture profile change.", e); } } } private android.hardware.tv.mediaquality.PictureProfile convertToHalPictureProfile(Long id, PersistableBundle params) { Loading @@ -1429,12 +1433,15 @@ public class MediaQualityService extends SystemService { private void notifyHalOnSoundProfileChange(Long dbId, PersistableBundle params) { // TODO: only notify HAL when the profile is active / being used if (mSpChangedListener != null) { try { mSpChangedListener.onSoundProfileChanged(convertToHalSoundProfile(dbId, params)); mSpChangedListener .onSoundProfileChanged(convertToHalSoundProfile(dbId, params)); } catch (RemoteException e) { Slog.e(TAG, "Failed to notify HAL on sound profile change.", e); } } } private android.hardware.tv.mediaquality.SoundProfile convertToHalSoundProfile(Long id, PersistableBundle params) { Loading Loading @@ -1488,9 +1495,6 @@ public class MediaQualityService extends SystemService { private final class PictureProfileAdjustmentListenerImpl extends IPictureProfileAdjustmentListener.Stub { MqDatabaseUtils mMqDatabaseUtils; MqManagerNotifier mMqManagerNotifier; HalNotifier mHalNotifier; @Override public void onPictureProfileAdjusted( Loading Loading @@ -1542,18 +1546,13 @@ public class MediaQualityService extends SystemService { return null; } private PictureProfileAdjustmentListenerImpl(Context context) { mMqDatabaseUtils = new MqDatabaseUtils(context); mMqManagerNotifier = new MqManagerNotifier(); mHalNotifier = new HalNotifier(); private PictureProfileAdjustmentListenerImpl() { } } private final class SoundProfileAdjustmentListenerImpl extends ISoundProfileAdjustmentListener.Stub { MqDatabaseUtils mMqDatabaseUtils; MqManagerNotifier mMqManagerNotifier; HalNotifier mHalNotifier; @Override public void onSoundProfileAdjusted( Loading Loading @@ -1598,10 +1597,8 @@ public class MediaQualityService extends SystemService { return null; } private SoundProfileAdjustmentListenerImpl(Context context) { mMqDatabaseUtils = new MqDatabaseUtils(context); mMqManagerNotifier = new MqManagerNotifier(); mHalNotifier = new HalNotifier(); private SoundProfileAdjustmentListenerImpl() { } } Loading Loading
services/core/java/com/android/server/media/quality/MediaQualityService.java +40 −43 Original line number Diff line number Diff line Loading @@ -127,17 +127,17 @@ public class MediaQualityService extends SystemService { super(context); mContext = context; mHalAmbientBacklightCallback = new HalAmbientBacklightCallback(); mPictureProfileAdjListener = new PictureProfileAdjustmentListenerImpl(mContext); mSoundProfileAdjListener = new SoundProfileAdjustmentListenerImpl(mContext); mPackageManager = mContext.getPackageManager(); mPictureProfileTempIdMap = new BiMap<>(); mSoundProfileTempIdMap = new BiMap<>(); mMediaQualityDbHelper = new MediaQualityDbHelper(mContext); mMqDatabaseUtils = new MqDatabaseUtils(mContext); mMediaQualityDbHelper.setWriteAheadLoggingEnabled(true); mMediaQualityDbHelper.setIdleConnectionTimeout(30); mHalNotifier = new HalNotifier(); mMqManagerNotifier = new MqManagerNotifier(); mMqDatabaseUtils = new MqDatabaseUtils(); mHalNotifier = new HalNotifier(); mPictureProfileAdjListener = new PictureProfileAdjustmentListenerImpl(); mSoundProfileAdjListener = new SoundProfileAdjustmentListenerImpl(); // The package info in the context isn't initialized in the way it is for normal apps, // so the standard, name-based context.getSharedPreferences doesn't work. Instead, we Loading Loading @@ -166,16 +166,18 @@ public class MediaQualityService extends SystemService { if (mMediaQuality != null) { try { mMediaQuality.setAmbientBacklightCallback(mHalAmbientBacklightCallback); mPpChangedListener = mMediaQuality.getPictureProfileListener(); mSpChangedListener = mMediaQuality.getSoundProfileListener(); mMediaQuality.setPictureProfileAdjustmentListener(mPictureProfileAdjListener); mMediaQuality.setSoundProfileAdjustmentListener(mSoundProfileAdjListener); } catch (RemoteException e) { Slog.e(TAG, "Failed to set ambient backlight detector callback", e); } } mPpChangedListener = IPictureProfileChangedListener.Stub.asInterface(binder); mSpChangedListener = ISoundProfileChangedListener.Stub.asInterface(binder); publishBinderService(Context.MEDIA_QUALITY_SERVICE, new BinderService()); } Loading Loading @@ -225,7 +227,6 @@ public class MediaQualityService extends SystemService { PictureProfile.ERROR_NO_PERMISSION, Binder.getCallingUid(), Binder.getCallingPid()); } synchronized (mPictureProfileLock) { ContentValues values = MediaQualityUtils.getContentValues(dbId, pp.getProfileType(), Loading @@ -233,7 +234,6 @@ public class MediaQualityService extends SystemService { pp.getPackageName(), pp.getInputId(), pp.getParameters()); updateDatabaseOnPictureProfileAndNotifyManagerAndHal(values, pp.getParameters()); } } Loading Loading @@ -792,7 +792,6 @@ public class MediaQualityService extends SystemService { } } //TODO: do I need a lock here? @Override public List<ParameterCapability> getParameterCapabilities( List<String> names, UserHandle user) { Loading @@ -809,7 +808,10 @@ public class MediaQualityService extends SystemService { private List<ParameterCapability> getListParameterCapability(ParamCapability[] caps) { List<ParameterCapability> pcList = new ArrayList<>(); if (caps != null) { for (ParamCapability pcHal : caps) { if (pcHal != null) { String name = MediaQualityUtils.getParameterName(pcHal.name); boolean isSupported = pcHal.isSupported; int type = pcHal.defaultValue == null ? 0 : pcHal.defaultValue.getTag() + 1; Loading @@ -817,6 +819,9 @@ public class MediaQualityService extends SystemService { pcList.add(new ParameterCapability(name, isSupported, type, bundle)); } } } return pcList; } Loading Loading @@ -1112,8 +1117,6 @@ public class MediaQualityService extends SystemService { private final class MqDatabaseUtils { MediaQualityDbHelper mMediaQualityDbHelper; private PictureProfile getPictureProfile(Long dbId) { String selection = BaseParameters.PARAMETER_ID + " = ?"; String[] selectionArguments = {Long.toString(dbId)}; Loading Loading @@ -1205,8 +1208,7 @@ public class MediaQualityService extends SystemService { /*groupBy=*/ null, /*having=*/ null, /*orderBy=*/ null); } private MqDatabaseUtils(Context context) { mMediaQualityDbHelper = new MediaQualityDbHelper(context); private MqDatabaseUtils() { } } Loading Loading @@ -1404,6 +1406,7 @@ public class MediaQualityService extends SystemService { private void notifyHalOnPictureProfileChange(Long dbId, PersistableBundle params) { // TODO: only notify HAL when the profile is active / being used if (mPpChangedListener != null) { try { mPpChangedListener.onPictureProfileChanged(convertToHalPictureProfile(dbId, params)); Loading @@ -1411,6 +1414,7 @@ public class MediaQualityService extends SystemService { Slog.e(TAG, "Failed to notify HAL on picture profile change.", e); } } } private android.hardware.tv.mediaquality.PictureProfile convertToHalPictureProfile(Long id, PersistableBundle params) { Loading @@ -1429,12 +1433,15 @@ public class MediaQualityService extends SystemService { private void notifyHalOnSoundProfileChange(Long dbId, PersistableBundle params) { // TODO: only notify HAL when the profile is active / being used if (mSpChangedListener != null) { try { mSpChangedListener.onSoundProfileChanged(convertToHalSoundProfile(dbId, params)); mSpChangedListener .onSoundProfileChanged(convertToHalSoundProfile(dbId, params)); } catch (RemoteException e) { Slog.e(TAG, "Failed to notify HAL on sound profile change.", e); } } } private android.hardware.tv.mediaquality.SoundProfile convertToHalSoundProfile(Long id, PersistableBundle params) { Loading Loading @@ -1488,9 +1495,6 @@ public class MediaQualityService extends SystemService { private final class PictureProfileAdjustmentListenerImpl extends IPictureProfileAdjustmentListener.Stub { MqDatabaseUtils mMqDatabaseUtils; MqManagerNotifier mMqManagerNotifier; HalNotifier mHalNotifier; @Override public void onPictureProfileAdjusted( Loading Loading @@ -1542,18 +1546,13 @@ public class MediaQualityService extends SystemService { return null; } private PictureProfileAdjustmentListenerImpl(Context context) { mMqDatabaseUtils = new MqDatabaseUtils(context); mMqManagerNotifier = new MqManagerNotifier(); mHalNotifier = new HalNotifier(); private PictureProfileAdjustmentListenerImpl() { } } private final class SoundProfileAdjustmentListenerImpl extends ISoundProfileAdjustmentListener.Stub { MqDatabaseUtils mMqDatabaseUtils; MqManagerNotifier mMqManagerNotifier; HalNotifier mHalNotifier; @Override public void onSoundProfileAdjusted( Loading Loading @@ -1598,10 +1597,8 @@ public class MediaQualityService extends SystemService { return null; } private SoundProfileAdjustmentListenerImpl(Context context) { mMqDatabaseUtils = new MqDatabaseUtils(context); mMqManagerNotifier = new MqManagerNotifier(); mHalNotifier = new HalNotifier(); private SoundProfileAdjustmentListenerImpl() { } } Loading