Merge "Hide Dock speaker plays from sound pages" into udc-dev

This commit is contained in:
TreeHugger Robot
2023-03-15 11:52:38 +00:00
committed by Android (Google) Code Review
2 changed files with 58 additions and 1 deletions

View File

@@ -19,6 +19,8 @@ package com.android.settings.notification;
import static com.android.settings.notification.SettingPref.TYPE_GLOBAL;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.provider.Settings.Global;
@@ -41,7 +43,7 @@ public class DockAudioMediaPreferenceController extends SettingPrefController {
DEFAULT_DOCK_AUDIO_MEDIA, DOCK_AUDIO_MEDIA_DISABLED, DOCK_AUDIO_MEDIA_ENABLED) {
@Override
public boolean isApplicable(Context context) {
return context.getResources().getBoolean(
return isLeDesk() && context.getResources().getBoolean(
com.android.settings.R.bool.has_dock_settings);
}
@@ -60,4 +62,18 @@ public class DockAudioMediaPreferenceController extends SettingPrefController {
}
};
}
/**
* Checks the state of docking type
* @return true if it is low-end dock types
*/
private boolean isLeDesk() {
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_DOCK_EVENT);
Intent dockStatus = mContext.registerReceiver(null, intentFilter);
if (dockStatus == null) {
return false;
}
int dockState = dockStatus.getIntExtra(Intent.EXTRA_DOCK_STATE, -1);
return dockState == Intent.EXTRA_DOCK_STATE_LE_DESK;
}
}