Obtainium icon indicating copy to clipboard operation
Obtainium copied to clipboard

App gallery doesn't work properly

Open ceskyDJ opened this issue 1 year ago • 25 comments

Prerequisites

There is a problem with apps from App gallery. I get an error for every update.

Describe the bug

When I force scan for updates of apps or automatic scan occurs, I get an error: FormatException: Trying to read yy from hu-aw-ei at 0 [AI Life].

To Reproduce

Screenshot_20240110_003050.jpg

Please complete the following information:

  • Device: Samsung Galaxy S8
  • OS: Android 14
  • Obtainium Version: 0.15.8-beta

ceskyDJ avatar Jan 09 '24 23:01 ceskyDJ

Here is the example of HTTP response headers:

curl -D - -sS https://appgallery.cloud.huawei.com/appdl/C10406921
HTTP/1.1 302 Found
Date: Wed, 10 Jan 2024 16:15:13 GMT
Content-Type: application/octet-stream
Content-Length: 0
Connection: keep-alive
Set-Cookie: HWWAFSESID=f72da8860381244ce2; path=/
Set-Cookie: HWWAFSESTIME=1704903304461; path=/
location: https://appdlc-dre.hispace.dbankcloud.cn/dl/appdl/application/apk/2a/2a7dc726066546569d6578231f3f7688/com.huawei.smarthome.2312171752.apk?maple=0&trackId=0&distOpEntity=HWSW
X-Frame-Options: sameorigin
Server: elb

I think that 2312171752 (2023-12-17 17:52) is some kind of version. We need to update regex for its extraction.

ceskyDJ avatar Jan 10 '24 16:01 ceskyDJ

It looks like these lines handle it: https://github.com/ImranR98/Obtainium/blob/main/lib/app_sources/huaweiappgallery.dart#L39C1-L50C4

  appIdFromRedirectDlUrl(String redirectDlUrl) {
    var parts = redirectDlUrl
        .split('?')[0]
        .split('/')
        .last
        .split('.')
        .reversed
        .toList();
    parts.removeAt(0);
    parts.removeAt(0);
    return parts.reversed.join('.');
  }

I think regex will be better, if there is a support for regexes in Dart (I hope so). You can use something like: \.([0-9]+)\.apk.

ceskyDJ avatar Jan 10 '24 16:01 ceskyDJ

I don't know Dart, but it could looks something like that:

  appIdFromRedirectDlUrl(String redirectDlUrl) {
    RegExp exp = RegExp(r'\.([0-9]+)\.apk');
    RegExpMatch? match = exp.firstMatch(redirectDlUrl);

    return match![0];
  }

ceskyDJ avatar Jan 10 '24 16:01 ceskyDJ

For some reason I'm getting an incorrect "location" response header when sending the request via Flutter, even though it works fine through curl. Changing the User Agent and other request headers to match the curl request doesn't help. Very similar to https://github.com/ImranR98/Obtainium/issues/854#issuecomment-1705722003.

ImranR98 avatar Jan 11 '24 00:01 ImranR98

For some reason this is now working on my end despite no change in the app (at least no change that I expected to affect this issue) - maybe something on the server side. Could you confirm if it's working for you (or if it's app-specific)?

ImranR98 avatar Jan 14 '24 05:01 ImranR98

I have exactly the same problem. I also can't add another app from appgallery

Spp595 avatar Jan 14 '24 09:01 Spp595

For some reason this is now working on my end despite no change in the app (at least no change that I expected to affect this issue) - maybe something on the server side. Could you confirm if it's working for you (or if it's app-specific)?

It looks working now.

ceskyDJ avatar Jan 14 '24 10:01 ceskyDJ

sorry for the confusion, updated obtanium

Spp595 avatar Jan 14 '24 11:01 Spp595

sorry for the confusion, updated obtanium

So, does it work for you, too (after update)?

ceskyDJ avatar Jan 14 '24 11:01 ceskyDJ

yes, beta 8 was installed, after updating to the latest everything works fine

Spp595 avatar Jan 14 '24 12:01 Spp595

I still have this error on v0.15.11.

BingoKingo avatar Jan 15 '24 06:01 BingoKingo

For some reason this is now working on my end despite no change in the app (at least no change that I expected to affect this issue) - maybe something on the server side. Could you confirm if it's working for you (or if it's app-specific)?

The update checking for Huawei gallery worked occasionally but not consistently. Please reopen this issue.

gregist avatar Jan 15 '24 09:01 gregist

For some reason this is now working on my end despite no change in the app (at least no change that I expected to affect this issue) - maybe something on the server side. Could you confirm if it's working for you (or if it's app-specific)?

The update checking for Huawei gallery worked occasionally but not consistently. Please reopen this issue.

Ok, so I reopened it.

ceskyDJ avatar Jan 15 '24 11:01 ceskyDJ

The update checking for Huawei gallery worked occasionally but not consistently.

It seems like it works well for me. I haven't got any error for some time (I think since the update, that should not fix it 😅).

ceskyDJ avatar Jan 15 '24 11:01 ceskyDJ

I still have this error on v0.15.11.

Me too. Version 0.16.0

qqyc avatar Jan 20 '24 15:01 qqyc

I just noticed that some apps are working properly while some aren't. For example,

huawei health https://appgallery.huawei.com/app/C10414141 updates correctly, while 微信读书 https://appgallery.huawei.com/app/C10398894 throws the error as OP described.

Could it be the Chinese characters in the app name that causes the bug? Just a guess. But hope that helps.

gregist avatar Jan 25 '24 14:01 gregist

I just noticed that some apps are working properly while some aren't. For example,

huawei health https://appgallery.huawei.com/app/C10414141 updates correctly, while 微信读书 https://appgallery.huawei.com/app/C10398894 throws the error as OP described.

Could it be the Chinese characters in the app name that causes the bug? Just a guess. But hope that helps.

Hmm, it looks like a nice catch! I'll look at it in the evening, how it differs.

ceskyDJ avatar Jan 25 '24 15:01 ceskyDJ

hey, I have tested QQ. it also doesn't work. So the bug may be not made by Chinese characters

and, I noticed that I only can add the first party apps developed by appgallery, such like AI life, HMS core. These apps' author are Huawei AppGallery and apk name prefix are com.huawei

teteko233 avatar Feb 04 '24 15:02 teteko233

hey, I have tested QQ. it also doesn't work. So the bug may be not made by Chinese characters

and, I noticed that I only can add the first party apps developed by appgallery, such like AI life, HMS core. These apps' author are Huawei AppGallery and apk name prefix are com.huawei

It could be the problem.

Headers obtained by curl for the app QQ:

HTTP/1.1 302 Found Date: Mon, 05 Feb 2024 21:12:03 GMT Content-Type: application/octet-stream Content-Length: 0 Connection: keep-alive Set-Cookie: HWWAFSESID=52d2c82ab23d575f0e; path=/ Set-Cookie: HWWAFSESTIME=1707167519783; path=/ location: https://appdlc-dre.hispace.dbankcloud.cn/dl/appdl/application/apk/1b/1b6f570510cd479a9a1a60d047dc9458/com.tencent.mobileqq.2402021025.apk?maple=0&trackId=0&distOpEntity=HWSW X-Frame-Options: sameorigin Server: elb

ceskyDJ avatar Feb 05 '24 21:02 ceskyDJ

@ImranR98, did you try it for apps from different authors than Huawei (with prefix com.huawei)?

ceskyDJ avatar Feb 05 '24 21:02 ceskyDJ

No, didn't think it would make a difference - I'll try some of the apps mentioned here.

ImranR98 avatar Feb 05 '24 21:02 ImranR98

It's interesting, that Huawei apps works but 3rd party apps don't. The piece of code I discussed above should be universal, so it is possibly elsewhere.

ceskyDJ avatar Feb 05 '24 22:02 ceskyDJ

@gregist @teteko233

The situation that Huawei apps are fine but others are not may be caused by Huawei's data center allocation.

KFC app for example.

At my home network, China Unicom curl -v https://appgallery.cloud.huawei.com/appdl/C10640835 returns an incorrect location URL as mentioned before:

< location: https://appgallery.cloud.huawei.com

But as I sshed to a United States VPS, the same command returns as this:

< location: https://appdlc-dra.hispace.dbankcloud.com/dl/appdl/application/apk/a2/a240a62854a2495bb570c657c624f728/com.yek.android.kfc.activitys.2408021632.apk?maple=0&trackId=0&distOpEntity=HWSW

Is Huawei geoblocking Chinese IPs? No. Because the following command works in my home network, too.

curl https://appgallery.cloud.huawei.com/appdl/C10640835 --connect-to ::159.138.86.75

The IP 159.138.86.75, located in Singapore was resolved on my VPS, but the Beijing-based 121.36.118.136 which my home network resolved doesn't work both on China and US!

So Huawei's Chinese server has no ability of providing direct APK URL.

This is similar of Google, the Beijing Gu Xiang IPs can only provide a limited set of services like

  • www.google.cn
  • developers.google.cn
  • www.recaptcha.net

But for other services that an ordinary gws can serve like www.youtube.com a 404 error would occur.

UjuiUjuMandan avatar Sep 02 '24 15:09 UjuiUjuMandan

@ImranR98 At first I tried to MITM this app, but it seems it doesn't trust certificate signed by PCAPdroid CA even it's in system keychain not users, does Flutter has a separate CA storage?

UjuiUjuMandan avatar Sep 02 '24 15:09 UjuiUjuMandan

@UjuiUjuMandan seems so: https://github.com/ImranR98/Obtainium/issues/1258#issuecomment-1888267714

ImranR98 avatar Sep 02 '24 16:09 ImranR98