Obtainium
Obtainium copied to clipboard
App gallery doesn't work properly
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
Please complete the following information:
- Device: Samsung Galaxy S8
- OS: Android 14
- Obtainium Version: 0.15.8-beta
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.
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
.
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];
}
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.
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)?
I have exactly the same problem. I also can't add another app from appgallery
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.
sorry for the confusion, updated obtanium
sorry for the confusion, updated obtanium
So, does it work for you, too (after update)?
yes, beta 8 was installed, after updating to the latest everything works fine
I still have this error on v0.15.11.
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.
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.
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 😅).
I still have this error on v0.15.11.
Me too. Version 0.16.0
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.
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.
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
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
@ImranR98, did you try it for apps from different authors than Huawei (with prefix com.huawei)?
No, didn't think it would make a difference - I'll try some of the apps mentioned here.
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.
@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.
@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 seems so: https://github.com/ImranR98/Obtainium/issues/1258#issuecomment-1888267714