diff options
author | Thorsten Behrens <tbehrens@suse.com> | 2012-11-24 14:59:56 +0100 |
---|---|---|
committer | Thorsten Behrens <tbehrens@suse.com> | 2012-11-24 14:59:56 +0100 |
commit | c2c9d8a99b7cdac0268e6bdaa042aeca7481ffb1 (patch) | |
tree | 833880195e789b7f44930c8329cb55468b88cdb0 /android | |
parent | fa6be97997f6142884accef5a88d6491bb1b3b76 (diff) |
Fix crashes in android remote.
Several objects become invalid after ending show prematurely. Data
transmission may be flawed, don't rely on valid base64 etc.
Change-Id: I9bb6929b9cd6b3183948662b472f92e2fa67a7e6
Diffstat (limited to 'android')
4 files changed, 33 insertions, 21 deletions
diff --git a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java index bf04750ba49c..5256f98cd40d 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java +++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java @@ -95,7 +95,8 @@ public class PresentationActivity extends SherlockFragmentActivity { Intent aIntent = new Intent(this, SelectorActivity.class); aIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(aIntent); - mCommunicationService.disconnect(); + if ( mCommunicationService != null ) + mCommunicationService.disconnect(); } @Override @@ -542,4 +543,4 @@ public class PresentationActivity extends SherlockFragmentActivity { } }; } -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java b/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java index 029f1d315d2f..3c768b248b61 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java +++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java @@ -119,13 +119,15 @@ public class PresentationFragment extends SherlockFragment { if (mNewCoverflowHeight != 0) { ThumbnailAdapter aAdapter = (ThumbnailAdapter) mTopView .getAdapter(); - aAdapter.setHeight(mNewCoverflowHeight); - mTopView.setImageHeight(mNewCoverflowHeight); - aAdapter.setWidth(mNewCoverflowWidth); - mTopView.setImageWidth(mNewCoverflowWidth); + if ( aAdapter != null ) { + aAdapter.setHeight(mNewCoverflowHeight); + mTopView.setImageHeight(mNewCoverflowHeight); + aAdapter.setWidth(mNewCoverflowWidth); + mTopView.setImageWidth(mNewCoverflowWidth); - // We need to update the view now - aAdapter.notifyDataSetChanged(); + // We need to update the view now + aAdapter.notifyDataSetChanged(); + } } IntentFilter aFilter = new IntentFilter( diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java b/android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java index df6aded140b6..0322b1f6dd11 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java @@ -83,16 +83,20 @@ public class Receiver { } else if (aInstruction.equals("slide_preview")) { int aSlideNumber = Integer.parseInt(aCommand.get(1)); String aImageString = aCommand.get(2); - byte[] aImage = Base64.decode(aImageString, Base64.DEFAULT); - - // Store image internally - mSlideShow.putImage(aSlideNumber, aImage); - - Intent aIntent = new Intent( - CommunicationService.MSG_SLIDE_PREVIEW); - aIntent.putExtra("slide_number", aSlideNumber); - LocalBroadcastManager.getInstance(mContext).sendBroadcast( - aIntent); + try { + byte[] aImage = Base64.decode(aImageString, Base64.DEFAULT); + + // Store image internally + mSlideShow.putImage(aSlideNumber, aImage); + + Intent aIntent = new Intent( + CommunicationService.MSG_SLIDE_PREVIEW); + aIntent.putExtra("slide_number", aSlideNumber); + LocalBroadcastManager.getInstance(mContext).sendBroadcast( + aIntent); + } catch (IllegalArgumentException e) { + // Bad data - tough luck + } } else if (aInstruction.equals("slide_notes")) { int aSlideNumber = Integer.parseInt(aCommand.get(1)); String aNotes = new String(); @@ -114,4 +118,4 @@ public class Receiver { } } -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/SlideShow.java b/android/sdremote/src/org/libreoffice/impressremote/communication/SlideShow.java index a74fb2eeed77..0b292372d48c 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/SlideShow.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/SlideShow.java @@ -54,7 +54,12 @@ public class SlideShow { return BitmapFactory.decodeResource(mContext.getResources(), R.drawable.image_loading); } - return BitmapFactory.decodeByteArray(aImage, 0, aImage.length); + Bitmap aBitmap = BitmapFactory.decodeByteArray(aImage, 0, aImage.length); + if (aBitmap == null) { + return BitmapFactory.decodeResource(mContext.getResources(), + R.drawable.image_loading); + } + return aBitmap; } protected void putNotes(int aSlide, String aNotes) { @@ -178,4 +183,4 @@ public class SlideShow { } } } -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |