Skip to content

Commit

Permalink
i9300: fix dock audio
Browse files Browse the repository at this point in the history
Change-Id: I44b8c3ec52652ff9f57a70aacd4c5156818e0037
  • Loading branch information
codeworkx committed Mar 28, 2013
1 parent c775350 commit 09d3f13
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 3 deletions.
5 changes: 5 additions & 0 deletions DeviceSettings/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<resources>
<string name="app_name">Galaxy S III Einstellungen</string>

<string name="category_dock_title">Dock</string>
<string name="dockaudio_subcat_title">Audio</string>
<string name="use_dock_audio_title_head">USB-Dock Audio</string>
<string name="use_dock_audio_summary_head">Passive Audio-Ausgabe des USB-Docks verwenden</string>

<string name="category_haptic_title">Haptik</string>
<string name="vibrator_subcat_title">Vibrator</string>
<string name="vibrator_intensity_title_head">Vibrator Intensität</string>
Expand Down
5 changes: 5 additions & 0 deletions DeviceSettings/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<resources>
<string name="app_name">Galaxy S III Settings</string>

<string name="category_dock_title">Dock</string>
<string name="dockaudio_subcat_title">Dock Audio</string>
<string name="use_dock_audio_title_head">Use Dock USB Audio</string>
<string name="use_dock_audio_summary_head">Use the passive audio out on the dock</string>

<string name="category_haptic_title">Haptic</string>
<string name="vibrator_subcat_title">Vibrator</string>
<string name="vibrator_intensity_title_head">Vibrator Intensity</string>
Expand Down
26 changes: 26 additions & 0 deletions DeviceSettings/res/xml/dock_preferences.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 The CyanogenMod 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.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="@string/dockaudio_subcat_title">
<!-- Use Dock Audio -->
<CheckBoxPreference
android:key="dock_audio"
android:title="@string/use_dock_audio_title_head"
android:summary="@string/use_dock_audio_summary_head"
/>
</PreferenceCategory>
</PreferenceScreen>
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class DeviceSettings extends FragmentActivity {
public static final String KEY_LED_FADE = "led_fade";
public static final String KEY_TOUCHKEY_LIGHT = "touchkey_light";
public static final String KEY_TOUCHKEY_TIMEOUT = "touchkey_timeout";
public static final String KEY_USE_DOCK_AUDIO = "dock_audio";

ViewPager mViewPager;
TabsAdapter mTabsAdapter;
Expand All @@ -63,6 +64,8 @@ protected void onCreate(Bundle savedInstanceState) {
bar.setDisplayHomeAsUpEnabled(true);

mTabsAdapter = new TabsAdapter(this, mViewPager);
mTabsAdapter.addTab(bar.newTab().setText(R.string.category_dock_title),
DockFragmentActivity.class, null);
mTabsAdapter.addTab(bar.newTab().setText(R.string.category_radio_title),
RadioFragmentActivity.class, null);
mTabsAdapter.addTab(bar.newTab().setText(R.string.category_screen_title),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright (C) 2012 The CyanogenMod 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 com.cyanogenmod.settings.device;

import android.app.ActivityManagerNative;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.UserHandle;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.util.Log;

import com.cyanogenmod.settings.device.R;

public class DockFragmentActivity extends PreferenceFragment {

private static final String PREF_ENABLED = "1";
private static final String TAG = "GalaxyS3Settings_Dock";

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

addPreferencesFromResource(R.xml.dock_preferences);
PreferenceScreen prefSet = getPreferenceScreen();

}

@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {

String boxValue;
String key = preference.getKey();

Log.w(TAG, "key: " + key);

if (key.compareTo(DeviceSettings.KEY_USE_DOCK_AUDIO) == 0) {
boxValue = (((CheckBoxPreference)preference).isChecked() ? "1" : "0");
Intent i = new Intent("com.cyanogenmod.settings.SamsungDock");
i.putExtra("data", boxValue);
ActivityManagerNative.broadcastStickyIntent(i, null, UserHandle.USER_ALL);
}

return true;
}

public static void restore(Context context) {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean dockAudio = sharedPrefs.getBoolean(DeviceSettings.KEY_USE_DOCK_AUDIO, false);
Intent i = new Intent("com.cyanogenmod.settings.SamsungDock");
i.putExtra("data", (dockAudio? "1" : "0"));
ActivityManagerNative.broadcastStickyIntent(i, null, UserHandle.USER_ALL);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class Startup extends BroadcastReceiver {

@Override
public void onReceive(final Context context, final Intent bootintent) {
DockFragmentActivity.restore(context);
HapticFragmentActivity.restore(context);
Hspa.restore(context);
RadioFragmentActivity.restore(context);
Expand Down
11 changes: 9 additions & 2 deletions audio/audio_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,9 @@ static void set_incall_device(struct m0_audio_device *adev)
device_type = SOUND_AUDIO_PATH_HANDSET;
break;
case AUDIO_DEVICE_OUT_SPEAKER:
case AUDIO_DEVICE_OUT_AUX_DIGITAL:
case AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET:
case AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET:
case AUDIO_DEVICE_OUT_AUX_DIGITAL:
device_type = SOUND_AUDIO_PATH_SPEAKER;
break;
case AUDIO_DEVICE_OUT_WIRED_HEADSET:
Expand Down Expand Up @@ -577,6 +578,12 @@ static void select_output_device(struct m0_audio_device *adev)
case AUDIO_DEVICE_OUT_ALL_SCO:
ALOGD("%s: AUDIO_DEVICE_OUT_ALL_SCO", __func__);
break;
case AUDIO_DEVICE_OUT_USB_ACCESSORY:
ALOGD("%s: AUDIO_DEVICE_OUT_USB_ACCESSORY", __func__);
break;
case AUDIO_DEVICE_OUT_USB_DEVICE:
ALOGD("%s: AUDIO_DEVICE_OUT_USB_DEVICE", __func__);
break;
default:
ALOGD("%s: AUDIO_DEVICE_OUT_ALL", __func__);
break;
Expand Down Expand Up @@ -2744,7 +2751,7 @@ static const struct {
{ AUDIO_DEVICE_OUT_WIRED_HEADSET | AUDIO_DEVICE_OUT_WIRED_HEADPHONE, "headphone" },
{ AUDIO_DEVICE_OUT_EARPIECE, "earpiece" },
{ AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET, "analog-dock" },
{ AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET, "digital-dock" },
{ AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET, "analog-dock" },
{ AUDIO_DEVICE_OUT_ALL_SCO, "sco-out" },

{ AUDIO_DEVICE_IN_BUILTIN_MIC, "builtin-mic" },
Expand Down
3 changes: 2 additions & 1 deletion overlay/packages/apps/Settings/res/values/bools.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
-->

<resources xmlns:xliff="urnasis:names:tc:xliff:document:1.2 ">
<bool name="has_powercontrol_widget">true</bool>
<!-- Whether or not the dock settings are to be displayed for this device when docked -->
<bool name="has_dock_settings">true</bool>
</resources>
21 changes: 21 additions & 0 deletions overlay/packages/apps/Settings/res/values/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2012 The CyanogenMod 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.
-->

<resources xmlns:xliff="urnasis:names:tc:xliff:document:1.2 ">
<!-- Volume Rocker Wake -->
<bool name="config_show_volumeRockerWake">true</bool>
</resources>

3 comments on commit 09d3f13

@hectorC
Copy link

@hectorC hectorC commented on 09d3f13 Apr 5, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this! Will it enable the use of USB audio DACs via USB OTG? Will this be ported to d2tmo?

@Tajgeer
Copy link

@Tajgeer Tajgeer commented on 09d3f13 Apr 5, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just follow the changelog of your device and you will know, if it will be added in the next nightly build.

http://changelog.bbqdroid.org/#d2tmo/cm10.1/next

@smar000
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dock audio through car dock (Infuse 4G one) still does not seem to be working, even on latest nightlies with the recent overlay fix.

Please sign in to comment.