openintents / notepad

OpenIntents Notepad
http://www.openintents.org/notepad/
47 stars 39 forks source link

Crash when launching notepad after 1.5.2 upgrade #13

Open menasheh opened 8 years ago

menasheh commented 8 years ago

Cyanogen 12.1 based ROM on LG G2 OI Safe version 1.4.2

E/AndroidRuntime(14536): java.lang.SecurityException: Permission Denial: starting Intent { act=org.openintents.action.DECRYPT cmp=org.openintents.safe/.IntentHandler (has extras) } from ProcessRecord{d1fba18 14536:org.openintents.notepad/u0a162} (pid=14536, uid=10162) requires org.openintents.safe.ACCESS_INTENTS

E/AndroidRuntime(14536):    at android.os.Parcel.readException(Parcel.java:1546)

E/AndroidRuntime(14536):    at android.os.Parcel.readException(Parcel.java:1499)

E/AndroidRuntime(14536):    at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2449)

E/AndroidRuntime(14536):    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1496)

E/AndroidRuntime(14536):    at android.app.Activity.startActivityForResult(Activity.java:3745)

E/AndroidRuntime(14536):    at android.app.Activity.startActivityForResult(Activity.java:3706)

E/AndroidRuntime(14536):    at org.openintents.notepad.noteslist.NotesList.decryptTitle(NotesList.java:915)

E/AndroidRuntime(14536):    at org.openintents.notepad.noteslist.NotesList$3.run(NotesList.java:896)

E/AndroidRuntime(14536):    at android.os.Handler.handleCallback(Handler.java:739)

E/AndroidRuntime(14536):    at android.os.Handler.dispatchMessage(Handler.java:95)

E/AndroidRuntime(14536):    at android.os.Looper.loop(Looper.java:135)

E/AndroidRuntime(14536):    at android.app.ActivityThread.main(ActivityThread.java:5289)

E/AndroidRuntime(14536):    at java.lang.reflect.Method.invoke(Native Method)

E/AndroidRuntime(14536):    at java.lang.reflect.Method.invoke(Method.java:372)

E/AndroidRuntime(14536):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)

E/AndroidRuntime(14536):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)

W/ActivityManager(  766):   Force finishing activity 1 org.openintents.notepad/.noteslist.NotesList
friedger commented 8 years ago

Do you have OI Safe installed? If yes, does it matter which order you installed it.

I saw this in the Google Play console but it is not reproducible for me.

aperomsik commented 8 years ago

Full disclosure: Menasheh is my son.

Both were already installed and got upgraded. We did try uninstalling and reinstalling OI Safe but it didn't help. To do the same for OI Notepad we would want to back up the data first, but can't get to Convert CSV because of the crash. Which seems a bit odd considering that on my phone it doesn't seem to decrypt any notes until I click on them.

I guess we should try adb backup.

aperomsik commented 8 years ago

Probably we should try to catch this exception and show a dialog explaining what to do.

aperomsik commented 8 years ago

This worked:

adb backup -f notepad.ab org.openintents.notepad (uninstall, reinstall OI Notepad) adb restore notepad.ab

Probably we should still try to catch the exception and give instructions.

menasheh commented 8 years ago

Could this be considered an android bug? Why is that necessary?

friedger commented 8 years ago

I tried different things, but not sure what is going on. My assumption is that OI Notepad still uses its own permission handle/hash for the ACCESS_INTENTS permission, while OI Safe provides a different handle/hash that does not match. I have pushed a release that shows a dialog if the permission is not granted.

dicer commented 8 years ago

I could reproduce this. At least once. Didn't try the whole thing again...:

  1. Had OiSafe 1.4.2 and OiNotepad 1.4.07 installed on Android 4.4.4 (CM11)
  2. Made a adb backup of OiNotepad (wouldn't work with OiSafe)
  3. adb restore of OiNotepad on Android 6.0.1 (CM13)
  4. adb install oisafe 1.4.2 -> fails, because of the permission they both had back then. Got removed from notepad last year
  5. updated OiNotepad to 1.5.3
  6. adb install oisafe 1.4.2 and restore from backup

Now I would get a little popup saying "decryption changed due to changes in the operating system". oinotepad I could also see that the extra permission "encrypt and decrypt data" is available in the Android settings, but I could only turn it on for OiSafe. The setting for OiNotepad would just not stick. Even though OiNotepad would give me lots of the above popups, it still worked. Except for encrypted notes. When opening those notes, I got the above exception.

I then did a new backup and restore, so I could restore straight to version 1.5.3: adb backup -f oinotes.ab -apk org.openintents.notepad adb restore oinotes.ab

And then it worked. I guess there is really something wrong if you upgrade from an old version. Still can't enable the extra permission for OiNotepad, but that seems not to be a problem. Decryption works fine now.

stebeh commented 6 years ago

Just FYI: I just experienced a similar issue when starting Notepad from within Shoppinglist in Android Studio emulator. It seems that one has to install ShoppingList first and then Notepad. When I do it the other way around, I get the the security exception below. I think the problem also occurs when you change code and recompile Shoppinglist; it seems that during re-installation the identities of the ShoppingList permissions change and Notepad cannot launch due to lack of permission. I would have guessed some of you folks must have seen that problem before....


java.lang.SecurityException: Permission Denial: opening provider org.openintents.shopping.provider.ShoppingProvider from ProcessRecord{d673cf5 3363:org.openintents.notepad/u0a62} (pid=3363, uid=10062) requires org.openintents.shopping.READ_PERMISSION or org.openintents.shopping.WRITE_PERMISSION