Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong name for Huawei Mate 20 X #57

Open
SanoKriss opened this issue May 23, 2022 · 0 comments
Open

Wrong name for Huawei Mate 20 X #57

SanoKriss opened this issue May 23, 2022 · 0 comments

Comments

@SanoKriss
Copy link

SanoKriss commented May 23, 2022

Hi,
for my Huawei Mate 20 X model EVR-AL00 getDeviceName return HUAWEI Mate 20 X (5G) which is wrong.
I made code inspection with following results:

  • in database is correct name, checked by SQLLite DB browser:
  • HUAWEI Mate 20 X (5G) HWEVR EVR-AN00
    HUAWEI Mate 20 X (5G) HWEVR EVR-N29
    Huawei Mate 20 X HWEVR EVR-L29
    Huawei Mate 20 X HWEVR EVR-TL00
    Huawei Mate 20 X (5G) HWEVR EVR-N29
    Huwei Mate 20 X HWEVR EVR-AL00

  • there is also mistake "Huwei" should be "Huawei"
  • in source code DeviceDatabase.java is in line 60-62:
  • if (codename != null && model != null) { selection = COLUMN_CODENAME + " LIKE ? OR " + COLUMN_MODEL + " LIKE ?"; selectionArgs = new String[] { codename, model };
  • that "OR" in condition and next moveToFirst in line 77:
  • if (cursor.moveToFirst()) { name = cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_NAME)); }
  • caused that first row is returned, which is HUAWEI Mate 20 X (5G) HWEVR EVR-AN00 which is different from EVR-AL00

Probably would be better first try select from database with "AND" operator and when nothing is returned, then try with OR operator.

Suggested change:

  • DeviceDatabase.java:
  • line 95 public DeviceInfo queryToDevice(@Nullable String codename, @Nullable String model, boolean exactly) {
  • line 102-103 if (!TextUtils.isEmpty(codename) && !TextUtils.isEmpty(model)) { if (exactly) { selection = COLUMN_CODENAME + " LIKE ? AND " + COLUMN_MODEL + " LIKE ?"; } else { selection = COLUMN_CODENAME + " LIKE ? OR " + COLUMN_MODEL + " LIKE ?"; }
  • DeviceName.java:
  • line 195: DeviceInfo info = database.queryToDevice(codename, model, true); if (info == null) { info = database.queryToDevice(codename, model, false); }

Alexander

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant