termux-api icon indicating copy to clipboard operation
termux-api copied to clipboard

fix(call-log): Fix query call log raise Exception

Open KunoiSayami opened this issue 4 years ago • 4 comments

According to https://android.googlesource.com/platform/frameworks/base/+/fd02074fdd12039e905a515941ffd9a757f671c2/core/java/android/database/sqlite/SQLiteQueryBuilder.java#162 Google restrict his way to limit query call log with sql statement, So we should use new method to query call log: https://developer.android.com/reference/android/content/ContentProvider#query(android.net.Uri,%20java.lang.String[],%20android.os.Bundle,%20android.os.CancellationSignal)

  • fix #434

Signed-off-by: KunoiSayami [email protected]

KunoiSayami avatar Aug 23 '21 07:08 KunoiSayami

I have no idea how this works, probably you can review this @Grimler91

thunder-coding avatar Oct 28 '21 10:10 thunder-coding

There is a number of identical statements under if block for APIs >= Build.VERSION_CODES.O and others. I guess it would be better to refactor code in way that would allow reuse them and keep under conditional only parts that differ.

ghost avatar Oct 28 '21 10:10 ghost

I guess it would be better to refactor code in way that would allow reuse them and keep under conditional only parts that differ.

I tried by I failed, maybe you will have a better way to refactor it

KunoiSayami avatar Oct 28 '21 11:10 KunoiSayami

The offset parameter doesn't work with this implementation, and there is an issue with the sort descending arg:

11-21 14:15:43.872  9470  9510 W Bundle  : Attempt to cast generated internal exception:
11-21 14:15:43.872  9470  9510 W Bundle  : java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
11-21 14:15:43.872  9470  9510 W Bundle  : 	at android.os.BaseBundle.getString(BaseBundle.java:1199)
11-21 14:15:43.872  9470  9510 W Bundle  : 	at android.content.ContentProvider.query(ContentProvider.java:1470)
11-21 14:15:43.872  9470  9510 W Bundle  : 	at android.content.ContentProvider$Transport.query(ContentProvider.java:278)
11-21 14:15:43.872  9470  9510 W Bundle  : 	at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:106)
11-21 14:15:43.872  9470  9510 W Bundle  : 	at android.os.Binder.execTransactInternal(Binder.java:1159)
11-21 14:15:43.872  9470  9510 W Bundle  : 	at android.os.Binder.execTransact(Binder.java:1123)

For the latter, maybe QUERY_ARG_SORT_COLUMNS should be used instead of QUERY_ARG_SQL_SORT_ORDER.

I've played around with it but haven't managed to solve the offset issue, yet

Grimler91 avatar Nov 21 '21 13:11 Grimler91