diff options
-rw-r--r-- | core/java/android/server/BluetoothService.java | 60 | ||||
-rw-r--r-- | docs/html/guide/samples/images/ContactManager1.png | bin | 0 -> 54351 bytes | |||
-rw-r--r-- | docs/html/guide/samples/images/ContactManager2.png | bin | 0 -> 40027 bytes | |||
-rw-r--r-- | libs/surfaceflinger/LayerBuffer.cpp | 116 | ||||
-rw-r--r-- | libs/surfaceflinger/LayerBuffer.h | 3 |
5 files changed, 99 insertions, 80 deletions
diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java index 1b117c7..018f7d7 100644 --- a/core/java/android/server/BluetoothService.java +++ b/core/java/android/server/BluetoothService.java @@ -37,6 +37,7 @@ import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.content.SharedPreferences; import android.os.Binder; import android.os.Handler; import android.os.IBinder; @@ -72,7 +73,6 @@ public class BluetoothService extends IBluetooth.Stub { private int mNativeData; private BluetoothEventLoop mEventLoop; - private IntentFilter mIntentFilter; private boolean mIsAirplaneSensitive; private int mBluetoothState; private boolean mRestart = false; // need to call enable() after disable() @@ -89,6 +89,9 @@ public class BluetoothService extends IBluetooth.Stub { private static final String DOCK_ADDRESS_PATH = "/sys/class/switch/dock/bt_addr"; private static final String DOCK_PIN_PATH = "/sys/class/switch/dock/bt_pin"; + private static final String SHARED_PREFERENCE_DOCK_ADDRESS = "dock_bluetooth_address"; + private static final String SHARED_PREFERENCES_NAME = "bluetooth_service_settings"; + private static final int MESSAGE_REGISTER_SDP_RECORDS = 1; private static final int MESSAGE_FINISH_DISABLE = 2; private static final int MESSAGE_UUID_INTENT = 3; @@ -163,32 +166,14 @@ public class BluetoothService extends IBluetooth.Stub { mUuidIntentTracker = new ArrayList<String>(); mUuidCallbackTracker = new HashMap<RemoteService, IBluetoothCallback>(); mServiceRecordToPid = new HashMap<Integer, Integer>(); - registerForAirplaneMode(); IntentFilter filter = new IntentFilter(); + registerForAirplaneMode(filter); + filter.addAction(Intent.ACTION_DOCK_EVENT); - mContext.registerReceiver(mBroadcastReceiver, filter); + mContext.registerReceiver(mReceiver, filter); } - private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (intent != null) { - String action = intent.getAction(); - - if (Intent.ACTION_DOCK_EVENT.equals(action)) { - int state = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, - Intent.EXTRA_DOCK_STATE_UNDOCKED); - if (DBG) Log.v(TAG, "Received ACTION_DOCK_EVENT with State:" + state); - if (state == Intent.EXTRA_DOCK_STATE_UNDOCKED) { - mDockAddress = null; - mDockPin = null; - } - } - } - } - }; - public static synchronized String readDockBluetoothAddress() { if (mDockAddress != null) return mDockAddress; @@ -263,9 +248,7 @@ public class BluetoothService extends IBluetooth.Stub { @Override protected void finalize() throws Throwable { - if (mIsAirplaneSensitive) { - mContext.unregisterReceiver(mReceiver); - } + mContext.unregisterReceiver(mReceiver); try { cleanupNativeDataNative(); } finally { @@ -1086,8 +1069,10 @@ public class BluetoothService extends IBluetooth.Stub { } public synchronized boolean isBluetoothDock(String address) { - if (address.equals(mDockAddress)) return true; - return false; + SharedPreferences sp = mContext.getSharedPreferences(SHARED_PREFERENCES_NAME, + mContext.MODE_PRIVATE); + + return sp.contains(SHARED_PREFERENCE_DOCK_ADDRESS + address); } /*package*/ boolean isRemoteDeviceInCache(String address) { @@ -1577,6 +1562,8 @@ public class BluetoothService extends IBluetooth.Stub { private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { + if (intent == null) return; + String action = intent.getAction(); if (action.equals(Intent.ACTION_AIRPLANE_MODE_CHANGED)) { ContentResolver resolver = context.getContentResolver(); @@ -1591,18 +1578,31 @@ public class BluetoothService extends IBluetooth.Stub { disable(false); } } + } else if (Intent.ACTION_DOCK_EVENT.equals(action)) { + int state = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, + Intent.EXTRA_DOCK_STATE_UNDOCKED); + if (DBG) Log.v(TAG, "Received ACTION_DOCK_EVENT with State:" + state); + if (state == Intent.EXTRA_DOCK_STATE_UNDOCKED) { + mDockAddress = null; + mDockPin = null; + } else { + SharedPreferences.Editor editor = + mContext.getSharedPreferences(SHARED_PREFERENCES_NAME, + mContext.MODE_PRIVATE).edit(); + editor.putBoolean(SHARED_PREFERENCE_DOCK_ADDRESS + mDockAddress, true); + editor.commit(); + } } } }; - private void registerForAirplaneMode() { + private void registerForAirplaneMode(IntentFilter filter) { String airplaneModeRadios = Settings.System.getString(mContext.getContentResolver(), Settings.System.AIRPLANE_MODE_RADIOS); mIsAirplaneSensitive = airplaneModeRadios == null ? true : airplaneModeRadios.contains(Settings.System.RADIO_BLUETOOTH); if (mIsAirplaneSensitive) { - mIntentFilter = new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED); - mContext.registerReceiver(mReceiver, mIntentFilter); + filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED); } } diff --git a/docs/html/guide/samples/images/ContactManager1.png b/docs/html/guide/samples/images/ContactManager1.png Binary files differnew file mode 100644 index 0000000..5bfd27b --- /dev/null +++ b/docs/html/guide/samples/images/ContactManager1.png diff --git a/docs/html/guide/samples/images/ContactManager2.png b/docs/html/guide/samples/images/ContactManager2.png Binary files differnew file mode 100644 index 0000000..0a11ec3 --- /dev/null +++ b/docs/html/guide/samples/images/ContactManager2.png diff --git a/libs/surfaceflinger/LayerBuffer.cpp b/libs/surfaceflinger/LayerBuffer.cpp index 137c5c0..2ff6167 100644 --- a/libs/surfaceflinger/LayerBuffer.cpp +++ b/libs/surfaceflinger/LayerBuffer.cpp @@ -364,43 +364,6 @@ LayerBuffer::BufferSource::BufferSource(LayerBuffer& layer, return; } - if (mLayer.mBlitEngine) { - // create our temporary buffer and corresponding EGLImageKHR. - // note that the size of this buffer doesn't really matter, - // the final image will always be drawn with proper aspect ratio. - - int w = layer.mTransformedBounds.width(); - int h = layer.mTransformedBounds.height(); - if (buffers.w * h != buffers.h * w) { - int t = w; w = h; h = t; - } - if (buffers.w * h == buffers.h * w) { - // same pixel area, don't use filtering - layer.mUseLinearFiltering = false; - } - - mTempGraphicBuffer.clear(); - mTempGraphicBuffer = new GraphicBuffer( - w, h, HAL_PIXEL_FORMAT_RGB_565, - GraphicBuffer::USAGE_HW_TEXTURE | - GraphicBuffer::USAGE_HW_2D); - - if (mTempGraphicBuffer->initCheck() == NO_ERROR) { - NativeBuffer& dst(mTempBuffer); - dst.img.w = mTempGraphicBuffer->getStride(); - dst.img.h = h; - dst.img.format = mTempGraphicBuffer->getPixelFormat(); - dst.img.handle = (native_handle_t *)mTempGraphicBuffer->handle; - dst.img.base = 0; - dst.crop.l = 0; - dst.crop.t = 0; - dst.crop.r = w; - dst.crop.b = h; - } else { - mTempGraphicBuffer.clear(); - } - } - mBufferHeap = buffers; mLayer.setNeedsBlending((info.h_alpha - info.l_alpha) > 0); mBufferSize = info.getScanlineSize(buffers.hor_stride)*buffers.ver_stride; @@ -492,18 +455,7 @@ void LayerBuffer::BufferSource::onDraw(const Region& clip) const copybit_device_t* copybit = mLayer.mBlitEngine; if (copybit) { // create our EGLImageKHR the first time - if (mTexture.image == EGL_NO_IMAGE_KHR) { - err = NO_MEMORY; - if (mTempGraphicBuffer!=0) { - err = mLayer.initializeEglImage( - mTempGraphicBuffer, &mTexture); - // once the EGLImage has been created (whether it fails - // or not) we don't need the graphic buffer reference - // anymore. - mTempGraphicBuffer.clear(); - } - } - + err = initTempBuffer(); if (err == NO_ERROR) { // NOTE: Assume the buffer is allocated with the proper USAGE flags const NativeBuffer& dst(mTempBuffer); @@ -542,6 +494,72 @@ void LayerBuffer::BufferSource::onDraw(const Region& clip) const mLayer.drawWithOpenGL(clip, mTexture); } +status_t LayerBuffer::BufferSource::initTempBuffer() const +{ + // figure out the size we need now + const ISurface::BufferHeap& buffers(mBufferHeap); + uint32_t w = mLayer.mTransformedBounds.width(); + uint32_t h = mLayer.mTransformedBounds.height(); + if (buffers.w * h != buffers.h * w) { + int t = w; w = h; h = t; + } + + if (mTexture.image != EGL_NO_IMAGE_KHR) { + // we have an EGLImage, make sure the needed size didn't change + if (w!=mTexture.width || h!= mTexture.height) { + // delete the EGLImage and texture + EGLDisplay dpy(mLayer.mFlinger->graphicPlane(0).getEGLDisplay()); + glDeleteTextures(1, &mTexture.name); + eglDestroyImageKHR(dpy, mTexture.image); + Texture defaultTexture; + mTexture = defaultTexture; + mTempGraphicBuffer.clear(); + } else { + // we're good, we have an EGLImageKHR and it's (still) the + // right size + return NO_ERROR; + } + } + + // figure out if we need linear filtering + if (buffers.w * h == buffers.h * w) { + // same pixel area, don't use filtering + mLayer.mUseLinearFiltering = false; + } + + // Allocate a temporary buffer and create the corresponding EGLImageKHR + + status_t err; + mTempGraphicBuffer.clear(); + mTempGraphicBuffer = new GraphicBuffer( + w, h, HAL_PIXEL_FORMAT_RGB_565, + GraphicBuffer::USAGE_HW_TEXTURE | + GraphicBuffer::USAGE_HW_2D); + + err = mTempGraphicBuffer->initCheck(); + if (err == NO_ERROR) { + NativeBuffer& dst(mTempBuffer); + dst.img.w = mTempGraphicBuffer->getStride(); + dst.img.h = h; + dst.img.format = mTempGraphicBuffer->getPixelFormat(); + dst.img.handle = (native_handle_t *)mTempGraphicBuffer->handle; + dst.img.base = 0; + dst.crop.l = 0; + dst.crop.t = 0; + dst.crop.r = w; + dst.crop.b = h; + + err = mLayer.initializeEglImage( + mTempGraphicBuffer, &mTexture); + // once the EGLImage has been created (whether it fails + // or not) we don't need the graphic buffer reference + // anymore. + mTempGraphicBuffer.clear(); + } + + return err; +} + // --------------------------------------------------------------------------- LayerBuffer::OverlaySource::OverlaySource(LayerBuffer& layer, diff --git a/libs/surfaceflinger/LayerBuffer.h b/libs/surfaceflinger/LayerBuffer.h index 1abb103..2ca63ac 100644 --- a/libs/surfaceflinger/LayerBuffer.h +++ b/libs/surfaceflinger/LayerBuffer.h @@ -130,13 +130,14 @@ private: virtual bool transformed() const; virtual void destroy() { } private: + status_t initTempBuffer() const; mutable Mutex mBufferSourceLock; sp<Buffer> mBuffer; status_t mStatus; ISurface::BufferHeap mBufferHeap; size_t mBufferSize; mutable LayerBase::Texture mTexture; - NativeBuffer mTempBuffer; + mutable NativeBuffer mTempBuffer; mutable sp<GraphicBuffer> mTempGraphicBuffer; }; |