Skip to content

Wrong name for Huawei Mate 20 X #57

@SanoKriss

Description

@SanoKriss

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions