Fixed
Status Update
Comments
ap...@google.com <ap...@google.com> #2
Perhaps make a defensive copy of ApplicationInfo
or read the process name early in the process lifecycle as ApplicationInfo
is a mutable singleton.
da...@google.com <da...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 0c92b8c8dd935872c4b425cae16f45ea0981226f
Author: Rahul Ravikumar <tikurahul@gmail.com>
Date: Thu Sep 17 10:38:46 2020
[GH] Use `ApplicationInfo` to determine the default app process name.
* Previously `context.getPackageName()` was used to determine the default app process name.
This is not always correct, because the app may have overriden the process name.
Fixes: b/168716641
Test: Ran integration tests.
This is an imported pull request fromhttps://github.com/androidx/androidx/pull/78 .
Resolves #78
Github-Pr-Head-Sha: 4ee23d5b6fdaf7aa18a95a4289f15332d0209c93
GitOrigin-RevId: 9e113c7cdb36b37d4038f021ee691762c0feb132
Change-Id: I2add7f9b051e59ffb880b2fc5ffac220cf4b858e
M work/workmanager/src/main/java/androidx/work/impl/utils/ProcessUtils.java
https://android-review.googlesource.com/1429950
Branch: androidx-master-dev
commit 0c92b8c8dd935872c4b425cae16f45ea0981226f
Author: Rahul Ravikumar <tikurahul@gmail.com>
Date: Thu Sep 17 10:38:46 2020
[GH] Use `ApplicationInfo` to determine the default app process name.
* Previously `context.getPackageName()` was used to determine the default app process name.
This is not always correct, because the app may have overriden the process name.
Fixes:
Test: Ran integration tests.
This is an imported pull request from
Resolves #78
Github-Pr-Head-Sha: 4ee23d5b6fdaf7aa18a95a4289f15332d0209c93
GitOrigin-RevId: 9e113c7cdb36b37d4038f021ee691762c0feb132
Change-Id: I2add7f9b051e59ffb880b2fc5ffac220cf4b858e
M work/workmanager/src/main/java/androidx/work/impl/utils/ProcessUtils.java
sk...@gmail.com <sk...@gmail.com> #4
Don't fixed.
For method:
@Query("SELECT * FROM downhills WHERE track_id = :trackId AND type = :type")
suspend fun getByTrackIdAndType(trackId: Long, type: DownhillEntity.Type): List<DownhillEntity>
Where DownhillEntity.Type has TypeConverter, and has corresponding annotation in my RoomDatabase class.
Generated code for this method:
@Override
public Object getByTrackIdAndType(final long trackId, final DownhillEntity.Type type,
final Continuation<? super List<DownhillEntity>> p2) {
final String _sql = "SELECT * FROM downhills WHERE track_id = ? AND type = ?";
final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 2);
int _argIndex = 1;
_statement.bindLong(_argIndex, trackId);
_argIndex = 2;
final String _tmp;
_tmp = __downhillTypeConverter.fromDownhillType(type);
if (_tmp == null) {
_statement.bindNull(_argIndex);
} else {
_statement.bindString(_argIndex, _tmp);
}
final Cursor _cursor = DBUtil.query(__db, _statement, false);
try {
final Object _result;
if(_cursor.moveToFirst()) {
_result = new Object();
} else {
_result = null;
}
return _result;
} finally {
_cursor.close();
_statement.release();
}
}
It's incorrect.
For method:
@Query("SELECT * FROM downhills WHERE track_id = :trackId AND type = :type")
suspend fun getByTrackIdAndType(trackId: Long, type: DownhillEntity.Type): List<DownhillEntity>
Where DownhillEntity.Type has TypeConverter, and has corresponding annotation in my RoomDatabase class.
Generated code for this method:
@Override
public Object getByTrackIdAndType(final long trackId, final DownhillEntity.Type type,
final Continuation<? super List<DownhillEntity>> p2) {
final String _sql = "SELECT * FROM downhills WHERE track_id = ? AND type = ?";
final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 2);
int _argIndex = 1;
_statement.bindLong(_argIndex, trackId);
_argIndex = 2;
final String _tmp;
_tmp = __downhillTypeConverter.fromDownhillType(type);
if (_tmp == null) {
_statement.bindNull(_argIndex);
} else {
_statement.bindString(_argIndex, _tmp);
}
final Cursor _cursor = DBUtil.query(__db, _statement, false);
try {
final Object _result;
if(_cursor.moveToFirst()) {
_result = new Object();
} else {
_result = null;
}
return _result;
} finally {
_cursor.close();
_statement.release();
}
}
It's incorrect.
yb...@google.com <yb...@google.com>
da...@google.com <da...@google.com> #5
Данил can you share a sample project that reproduces the issue describes in comment #4 ? Is your suspend function defined in a super interface or class? It seems that Room is failing to detect getByTrackIdAndType() is a suspend function and is generating a blocking implementation, this doesn't seem to be related to the usage of TypeConverters.
sk...@gmail.com <sk...@gmail.com>
da...@google.com <da...@google.com> #6
Данил thanks for the sample project. It seems Room is failing to detect that the function is a suspend function. I've created a separate issue (https://issuetracker.google.com/issues/123767877 ) since its not related to the TypeConverters issue that you originally reported.
Description
Version used: 2.1.0-alpha03
Devices/Android versions reproduced on: compilation error
When using suspend SELECT method with TypeConverter parameter, room-compiler generate incorrect method code with return type java.lang.Object.
Compilation exceptions:
• The query returns some columns [...] which are not used by java.lang.Object. You can use @ColumnInfo annotation on the fields to specify the mapping. You can suppress this warning by annotating the method with @SuppressWarnings(RoomWarnings.CURSOR_MISMATCH).
• Not sure how to convert a Cursor to this method's return type (java.lang.Object).
• Query method parameters should either be a type that can be converted into a database column or a List / Array that contains such type. You can consider adding a Type Adapter for this.
But when I remove suspend modifier all is ok.