Loading AndroidManifest.xml +2 −8 Original line number Diff line number Diff line Loading @@ -489,20 +489,14 @@ </activity> <receiver android:name=".bluetooth.DockAudioStateChangeReceiver" > android:name=".bluetooth.DockEventReceiver"> <intent-filter> <action android:name="android.intent.action.DOCK_EVENT" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </receiver> <activity android:name=".bluetooth.DockSettingsActivity" android:label="@string/bluetooth_dock_settings" android:launchMode="singleTask" android:excludeFromRecents="true" android:theme="@*android:style/Theme.Dialog.Alert"> </activity> <service android:name=".bluetooth.DockService" /> <activity android:name=".bluetooth.RequestPermissionActivity" android:label="@string/bluetooth_permission_request" Loading res/values/strings.xml +0 −2 Original line number Diff line number Diff line Loading @@ -653,8 +653,6 @@ <string name="bluetooth_dock_settings_a2dp">For music and media</string> <!-- Bluetooth settings. Dock Setting Dialog - Remember setting and don't ask user again --> <string name="bluetooth_dock_settings_remember">Remember settings</string> <!-- Bluetooth settings. Dock Setting Dialog - Hint for the user to chagne setting after checking "remember settings" --> <string name="bluetooth_dock_settings_hint">"Change with Settings under Sound & display > Dock audio</string> <!-- Wi-Fi settings --> <!-- Used in the 2nd-level settings screen to turn on Wi-Fi --> Loading src/com/android/settings/SoundAndDisplaySettings.java +24 −23 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package com.android.settings; import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT; import com.android.settings.bluetooth.DockSettingsActivity; import com.android.settings.bluetooth.DockEventReceiver; import android.content.BroadcastReceiver; import android.content.ContentResolver; Loading Loading @@ -356,8 +356,9 @@ public class SoundAndDisplaySettings extends PreferenceActivity implements Settings.System.NOTIFICATION_LIGHT_PULSE, value ? 1 : 0); } else if (preference == mDockSettings) { Intent i = new Intent(mDockIntent); i.setClass(this, DockSettingsActivity.class); startActivity(i); i.setAction(DockEventReceiver.ACTION_DOCK_SHOW_UI); i.setClass(this, DockEventReceiver.class); sendBroadcast(i); } return true; Loading src/com/android/settings/bluetooth/CachedBluetoothDevice.java +33 −31 Original line number Diff line number Diff line Loading @@ -227,6 +227,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> } public void onProfileStateChanged(Profile profile, int newProfileState) { synchronized (workQueue) { if (D) { Log.d(TAG, "onProfileStateChanged:" + workQueue.toString()); } Loading Loading @@ -267,6 +268,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> processCommands(); } } } /* * This method is called in 2 places: Loading src/com/android/settings/bluetooth/DockAudioStateChangeReceiver.java→src/com/android/settings/bluetooth/DockEventReceiver.java +112 −0 Original line number Diff line number Diff line Loading @@ -16,61 +16,97 @@ package com.android.settings.bluetooth; import android.app.Service; import android.bluetooth.BluetoothDevice; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.PowerManager; import android.util.Log; public class DockAudioStateChangeReceiver extends BroadcastReceiver { public class DockEventReceiver extends BroadcastReceiver { private static final boolean DBG = true; private static final String TAG = "DockAudioStateChangeReceiver"; private static final boolean DEBUG = true; private static final String TAG = "DockEventReceiver"; public static final String ACTION_DOCK_SHOW_UI = "com.android.settings.bluetooth.action.DOCK_SHOW_UI"; private static final int EXTRA_INVALID = -1234; static final Object mStartingServiceSync = new Object(); static PowerManager.WakeLock mStartingService; @Override public void onReceive(Context context, Intent intent) { if (intent == null) return; if (DBG) { Log.e(TAG, "Action:" + intent.getAction() + " State:" + intent.getIntExtra(Intent.EXTRA_DOCK_STATE, Intent.EXTRA_DOCK_STATE_UNDOCKED)); int state = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, EXTRA_INVALID); BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); if (DEBUG) { Log.d(TAG, "Action: " + intent.getAction() + " State:" + state + " Device: " + (device == null ? "null" : device.getName())); } if (Intent.ACTION_DOCK_EVENT.equals(intent.getAction())) { BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); if (Intent.ACTION_DOCK_EVENT.equals(intent.getAction()) || ACTION_DOCK_SHOW_UI.endsWith(intent.getAction())) { if (device == null) { if (DBG) Log.e(TAG, "Device is missing"); if (DEBUG) Log.e(TAG, "Device is missing"); return; } LocalBluetoothManager localManager = LocalBluetoothManager.getInstance(context); int state = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, Intent.EXTRA_DOCK_STATE_UNDOCKED); switch (state) { case Intent.EXTRA_DOCK_STATE_UNDOCKED: DockSettingsActivity.handleUndocked(context, localManager, device); break; case Intent.EXTRA_DOCK_STATE_CAR: case Intent.EXTRA_DOCK_STATE_DESK: if (DockSettingsActivity.getAutoConnectSetting(localManager)) { // Auto connect DockSettingsActivity.handleDocked(context, localManager, device, state); } else { // Don't auto connect. Show dialog. Intent i = new Intent(intent); i.setClass(context, DockSettingsActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); } i.setClass(context, DockService.class); beginStartingService(context, i); break; default: Log.e(TAG, "Unknown state"); if (DEBUG) Log.e(TAG, "Unknown state"); break; } } } /** * Start the service to process the current event notifications, acquiring * the wake lock before returning to ensure that the service will run. */ public static void beginStartingService(Context context, Intent intent) { synchronized (mStartingServiceSync) { if (mStartingService == null) { PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); mStartingService = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "StartingDockService"); mStartingService.setReferenceCounted(false); } mStartingService.acquire(); if (context.startService(intent) == null) { Log.e(TAG, "Can't start DockService"); mStartingService.release(); } } } /** * Called back by the service when it has finished processing notifications, * releasing the wake lock if the service is now stopping. */ public static void finishStartingService(Service service, int startId) { synchronized (mStartingServiceSync) { if (mStartingService != null) { if (service.stopSelfResult(startId)) { mStartingService.release(); } } } } } Loading
AndroidManifest.xml +2 −8 Original line number Diff line number Diff line Loading @@ -489,20 +489,14 @@ </activity> <receiver android:name=".bluetooth.DockAudioStateChangeReceiver" > android:name=".bluetooth.DockEventReceiver"> <intent-filter> <action android:name="android.intent.action.DOCK_EVENT" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </receiver> <activity android:name=".bluetooth.DockSettingsActivity" android:label="@string/bluetooth_dock_settings" android:launchMode="singleTask" android:excludeFromRecents="true" android:theme="@*android:style/Theme.Dialog.Alert"> </activity> <service android:name=".bluetooth.DockService" /> <activity android:name=".bluetooth.RequestPermissionActivity" android:label="@string/bluetooth_permission_request" Loading
res/values/strings.xml +0 −2 Original line number Diff line number Diff line Loading @@ -653,8 +653,6 @@ <string name="bluetooth_dock_settings_a2dp">For music and media</string> <!-- Bluetooth settings. Dock Setting Dialog - Remember setting and don't ask user again --> <string name="bluetooth_dock_settings_remember">Remember settings</string> <!-- Bluetooth settings. Dock Setting Dialog - Hint for the user to chagne setting after checking "remember settings" --> <string name="bluetooth_dock_settings_hint">"Change with Settings under Sound & display > Dock audio</string> <!-- Wi-Fi settings --> <!-- Used in the 2nd-level settings screen to turn on Wi-Fi --> Loading
src/com/android/settings/SoundAndDisplaySettings.java +24 −23 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package com.android.settings; import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT; import com.android.settings.bluetooth.DockSettingsActivity; import com.android.settings.bluetooth.DockEventReceiver; import android.content.BroadcastReceiver; import android.content.ContentResolver; Loading Loading @@ -356,8 +356,9 @@ public class SoundAndDisplaySettings extends PreferenceActivity implements Settings.System.NOTIFICATION_LIGHT_PULSE, value ? 1 : 0); } else if (preference == mDockSettings) { Intent i = new Intent(mDockIntent); i.setClass(this, DockSettingsActivity.class); startActivity(i); i.setAction(DockEventReceiver.ACTION_DOCK_SHOW_UI); i.setClass(this, DockEventReceiver.class); sendBroadcast(i); } return true; Loading
src/com/android/settings/bluetooth/CachedBluetoothDevice.java +33 −31 Original line number Diff line number Diff line Loading @@ -227,6 +227,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> } public void onProfileStateChanged(Profile profile, int newProfileState) { synchronized (workQueue) { if (D) { Log.d(TAG, "onProfileStateChanged:" + workQueue.toString()); } Loading Loading @@ -267,6 +268,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> processCommands(); } } } /* * This method is called in 2 places: Loading
src/com/android/settings/bluetooth/DockAudioStateChangeReceiver.java→src/com/android/settings/bluetooth/DockEventReceiver.java +112 −0 Original line number Diff line number Diff line Loading @@ -16,61 +16,97 @@ package com.android.settings.bluetooth; import android.app.Service; import android.bluetooth.BluetoothDevice; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.PowerManager; import android.util.Log; public class DockAudioStateChangeReceiver extends BroadcastReceiver { public class DockEventReceiver extends BroadcastReceiver { private static final boolean DBG = true; private static final String TAG = "DockAudioStateChangeReceiver"; private static final boolean DEBUG = true; private static final String TAG = "DockEventReceiver"; public static final String ACTION_DOCK_SHOW_UI = "com.android.settings.bluetooth.action.DOCK_SHOW_UI"; private static final int EXTRA_INVALID = -1234; static final Object mStartingServiceSync = new Object(); static PowerManager.WakeLock mStartingService; @Override public void onReceive(Context context, Intent intent) { if (intent == null) return; if (DBG) { Log.e(TAG, "Action:" + intent.getAction() + " State:" + intent.getIntExtra(Intent.EXTRA_DOCK_STATE, Intent.EXTRA_DOCK_STATE_UNDOCKED)); int state = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, EXTRA_INVALID); BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); if (DEBUG) { Log.d(TAG, "Action: " + intent.getAction() + " State:" + state + " Device: " + (device == null ? "null" : device.getName())); } if (Intent.ACTION_DOCK_EVENT.equals(intent.getAction())) { BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); if (Intent.ACTION_DOCK_EVENT.equals(intent.getAction()) || ACTION_DOCK_SHOW_UI.endsWith(intent.getAction())) { if (device == null) { if (DBG) Log.e(TAG, "Device is missing"); if (DEBUG) Log.e(TAG, "Device is missing"); return; } LocalBluetoothManager localManager = LocalBluetoothManager.getInstance(context); int state = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, Intent.EXTRA_DOCK_STATE_UNDOCKED); switch (state) { case Intent.EXTRA_DOCK_STATE_UNDOCKED: DockSettingsActivity.handleUndocked(context, localManager, device); break; case Intent.EXTRA_DOCK_STATE_CAR: case Intent.EXTRA_DOCK_STATE_DESK: if (DockSettingsActivity.getAutoConnectSetting(localManager)) { // Auto connect DockSettingsActivity.handleDocked(context, localManager, device, state); } else { // Don't auto connect. Show dialog. Intent i = new Intent(intent); i.setClass(context, DockSettingsActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); } i.setClass(context, DockService.class); beginStartingService(context, i); break; default: Log.e(TAG, "Unknown state"); if (DEBUG) Log.e(TAG, "Unknown state"); break; } } } /** * Start the service to process the current event notifications, acquiring * the wake lock before returning to ensure that the service will run. */ public static void beginStartingService(Context context, Intent intent) { synchronized (mStartingServiceSync) { if (mStartingService == null) { PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); mStartingService = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "StartingDockService"); mStartingService.setReferenceCounted(false); } mStartingService.acquire(); if (context.startService(intent) == null) { Log.e(TAG, "Can't start DockService"); mStartingService.release(); } } } /** * Called back by the service when it has finished processing notifications, * releasing the wake lock if the service is now stopping. */ public static void finishStartingService(Service service, int startId) { synchronized (mStartingServiceSync) { if (mStartingService != null) { if (service.stopSelfResult(startId)) { mStartingService.release(); } } } } }