Loading AndroidManifest.xml +3 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,9 @@ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_DREAM_STATE" /> <uses-permission android:name="android.permission.WRITE_DREAM_STATE" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WRITE_SETTINGS" /> <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" /> <uses-permission android:name="android.permission.DEVICE_POWER" /> Loading src/com/android/settings/bluetooth/BluetoothPairingDialog.java +38 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,11 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.os.PowerManager; import android.os.RemoteException; import android.os.ServiceManager; import android.service.dreams.DreamService; import android.service.dreams.IDreamManager; import android.text.Editable; import android.text.Html; import android.text.InputFilter; Loading Loading @@ -111,6 +116,12 @@ public final class BluetoothPairingDialog extends AlertActivity implements finish(); return; } // If a pairing request is received and the device is dreaming (i.e. the screen timeout // occurred while the user was initiating pairing), wake it up when this dialog is // displayed. wakeDeviceUpFromDreamIfDreaming(); mCachedDeviceManager = mBluetoothManager.getCachedDeviceManager(); mDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); Loading Loading @@ -168,6 +179,33 @@ public final class BluetoothPairingDialog extends AlertActivity implements registerReceiver(mReceiver, new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED)); } /** * If the device is in a daydream, wake it up. */ private void wakeDeviceUpFromDreamIfDreaming() { IDreamManager dreamManagerService = IDreamManager.Stub.asInterface( ServiceManager.getService(DreamService.DREAM_SERVICE)); try { if (dreamManagerService != null && dreamManagerService.isDreaming()) { dreamManagerService.awaken(); PowerManager pm = (PowerManager) getSystemService( Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock( PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, TAG); wl.acquire(); // Just wake the device, then release. wl.release(); } } catch (RemoteException e) { Log.w(TAG, "Failed to awaken from dream", e); } } private void createUserEntryDialog() { final AlertController.AlertParams p = mAlertParams; p.mTitle = getString(R.string.bluetooth_pairing_request); Loading Loading
AndroidManifest.xml +3 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,9 @@ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_DREAM_STATE" /> <uses-permission android:name="android.permission.WRITE_DREAM_STATE" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WRITE_SETTINGS" /> <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" /> <uses-permission android:name="android.permission.DEVICE_POWER" /> Loading
src/com/android/settings/bluetooth/BluetoothPairingDialog.java +38 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,11 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.os.PowerManager; import android.os.RemoteException; import android.os.ServiceManager; import android.service.dreams.DreamService; import android.service.dreams.IDreamManager; import android.text.Editable; import android.text.Html; import android.text.InputFilter; Loading Loading @@ -111,6 +116,12 @@ public final class BluetoothPairingDialog extends AlertActivity implements finish(); return; } // If a pairing request is received and the device is dreaming (i.e. the screen timeout // occurred while the user was initiating pairing), wake it up when this dialog is // displayed. wakeDeviceUpFromDreamIfDreaming(); mCachedDeviceManager = mBluetoothManager.getCachedDeviceManager(); mDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); Loading Loading @@ -168,6 +179,33 @@ public final class BluetoothPairingDialog extends AlertActivity implements registerReceiver(mReceiver, new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED)); } /** * If the device is in a daydream, wake it up. */ private void wakeDeviceUpFromDreamIfDreaming() { IDreamManager dreamManagerService = IDreamManager.Stub.asInterface( ServiceManager.getService(DreamService.DREAM_SERVICE)); try { if (dreamManagerService != null && dreamManagerService.isDreaming()) { dreamManagerService.awaken(); PowerManager pm = (PowerManager) getSystemService( Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock( PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, TAG); wl.acquire(); // Just wake the device, then release. wl.release(); } } catch (RemoteException e) { Log.w(TAG, "Failed to awaken from dream", e); } } private void createUserEntryDialog() { final AlertController.AlertParams p = mAlertParams; p.mTitle = getString(R.string.bluetooth_pairing_request); Loading