pwn20wndstuff/Undecimus

[iOS 11+12] Please fix cydia-no-network error for China devices

laoyur opened this issue · 59 comments

Hi, you may not know the fact that iOS asks network permission for an app when it get the first launch on all China device models. Network for that app is not available until user grant the permission.

However, with some reason, after the initial JB, Cydia just get no chance to show that alert. Users can not even find Cydia item in Preferences app. As a result, Cydia just not work after the initial JB.

A workaround is to delete some Network Extensions files or using a VPN to bypass, but that's very tricky and dirty.

The best method is to call AppWirelessDataUsageManager(link to /System/Library/PrivateFrameworks/Preferences.framework/Preferences) for Cydia explicitly.

code for iOS 11:

NSString *cydiaBundleId = @"com.saurik.Cydia";
[AppWirelessDataUsageManager setAppWirelessDataOption:[NSNumber numberWithInt:3] 
                                      forBundleIdentifier:cydiaBundleId completionHandler:nil];
[AppWirelessDataUsageManager setAppCellularDataEnabled:[NSNumber numberWithInt:1] 
                                       forBundleIdentifier:cydiaBundleId completionHandler:nil];

code for iOS 12:

        Class K_PSAppDataUsagePolicyCache = objc_getClass("PSAppDataUsagePolicyCache");
        PSAppDataUsagePolicyCache *cache = [K_PSAppDataUsagePolicyCache sharedInstance];
        [cache setUsagePoliciesForBundle:@"com.saurik.Cydia" cellular:true wifi:true];

and the entitlements required for iOS 11 & 12:

 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
     <dict>
         <key>com.apple.CommCenter.fine-grained</key>
         <array>
             <string>cellular-plan</string>
             <string>data-usage</string>
             <string>data-allowed-write</string>
             <string>preferences-write</string>
         </array>
         <key>platform-application</key>
         <true/>
     </dict>
 </plist>

The code is required to call only once after the initial JB.
Could you guys consider adding that piece of code?

大神说的没错,我最开始从Electra Rollectra,再用Unc0ver越狱,更新过两个插件后,Cydia就没有联网权限了,只能通过ConditionalWifi3来打开,确实这是个问题。如果Pwn能解决就方便了。

非常棒的解决方法 你能fork一下unc0ver并且将其添加进去吗

go to /Library/Preferences/, remove com.apple.network*.plist, reboot your device and JB again, Cydia should be able to have internet. This is a workaround for China Models.

README before you try this on iOS12:

Since someone starts acting like a kid giving down thumbs only because my workaround does not work on iOS12..(if you really see the date I post this workaround, there was even no iOS12 JB yet), the workaround I mentioned is only tested on pre-iOS12 devices. and here's a free new workaround for now: buy a non-China model.

@liuxuan30 thanks, but we are talking about solution rather than workaround here

I understand that. and above is just FYI. I hope it can be fixed as well.

@laoyur I just tried a new phone, it seems my workaround is not working. any idea?

@liuxuan30 I don't know, the workaround itself is very tricky :(
I will consider forking unc0ver later when I have spare time.

after trying reinstall Cydia and deleting those plist several times, it worked again... weird.

But I strongly support you and @pwn20wndstuff and maybe @saurik can help add this. It has been painful for Chinese devices!

@Cryptiiiic what more info you need? I'm intersted in this

@liuxuan30 pwn doesn't fully understand what this is, neither do I.

@Cryptiiiic
Cydia cannot use WLAN/4G after JB on China devices.
Users need to use VPN or other ugly workaround to bypass.
if you can call AppWirelessDataUsageManager related API for Cydia's bundleid after initial JB, this problem can be fixed gracefully.

Hope you can understand now. :)

@Cryptiiiic @pwn20wndstuff So let me repeat what @laoyur said from an user perspective:

The iPhone sold officially in mainland China has a special feature since iOS 10.3, that when you first time download the app and open it, iOS will prompt a popup to ask you do you wish to allow the app to have internet access. Some iOS built-in apps will also have this popup, like calendar ( I guess they are those apps can be delete and reinstall from AppStore).

Here are some screenshots to help you understand:
1. first time open an app, e.g. the calendar:
image

2. in settings -> WLAN, there is a page to list all apps using WLAN & cellular:
image

3. if you click:
image
this is my dev machine, the DPIHelper is my app. You can see there are AppStore and Settings. I didn't launch calendar app here for the first time when I capture this, so you won't see it. But I have launched Cydia and make it work, it still not shows Cydia.

4. and if you choose Settings:
image

So this is how it looks and functions. I was told this feature is dedicated only for mainland China because laws demand this. It seems like the iOS is reading the iPhone's hardware info to decide if the phone would have this feature. Only devices with Cellular are impacted. I have WIFI only iPad, which is fine. But I didn't have a cellular iPad, so I cannot confirm whether Cellular iPad has this feature.

About Cydia:

If you open Cydia for the first time, it will not have the prompt, nor the internet access. It's not even shown up in the above settings. Just like a ghost. I'm gussing it's because Cydia is installed in /Applications rather than the AppStore apps path in /var/mobile/...

The current workaround I'm using is to JB and ssh into the device, delete all com.apple.network*.plist in /Library/Preferences and reboot again. Then Cydia will have access to internet, but still not showing up in the settings list.

Note if you upgrade the Cydia bundle, it will be blocked again, and you have to repeat above steps to make it work again.

Hope this can help you understand.

Yep. Can confirm all Chinese devices have this issue. Just FYI an indication that the device is a Chinese one is if you go to Settings, in the section where it should say “Wi-Fi”, it shows “WLAN” instead. Also if the device is SIM-compatible, let it be an iPhone or an iPad, in the tab Cellular it gives you the option to choose whether an app can use WLAN or both.

Source: have an iPhone purchased in China and looks like all iDevices whose serials end with CH/A have this problem.

Just want to add that if your device has this issue, using a VPN app that sets up a SOCKS server on localhost may help (possibly). It has to be on localhost so it won’t work if you add a VPN configuration directly in Settings.

Dunno why but /var/preferences/com.apple.networkextension.cache.plist seems to have something to do with it as well. My workaround when this was troubling my iPhone 5S on yalu used to be to SSH into the device first and then rm -rf /var/preferences/com.apple.networkextension.cache.plist, reboot and dang, everything worked. And when this is happening again on unc0ver I was like bugger it and boom, it works. So maybe anyone of greater knowledge than me can look into that file to see what’s going on (not sure whether it’ll be present on non-Chinese devices as well tho).

I don't believe it has been resloved under WIFI without any reply from Saurik nor the authors.

Encounter the same issue here on my Chinese Models of iPhone X.
All apps run as root involved.

Get a VPN and then try it see if it works
If it doesn’t move out of China

Code for iOS 12 updated.

We can make a NetworkFix.deb and people can scp it to the device and then exec for Cydia.
But I do hope unc0ver can embed the deb as built-in resource and call NetworkFix for Cydia during initial JB.
It will help a lot of ordinary people living in China.

@Cryptiiiic @pwn20wndstuff So let me repeat what @laoyur said from an user perspective:

The iPhone sold officially in mainland China has a special feature since iOS 10.3, that when you first time download the app and open it, iOS will prompt a popup to ask you do you wish to allow the app to have internet access. Some iOS built-in apps will also have this popup, like calendar ( I guess they are those apps can be delete and reinstall from AppStore).

Here are some screenshots to help you understand:
1. first time open an app, e.g. the calendar:
image

2. in settings -> WLAN, there is a page to list all apps using WLAN & cellular:
image

3. if you click:
image
this is my dev machine, the DPIHelper is my app. You can see there are AppStore and Settings. I didn't launch calendar app here for the first time when I capture this, so you won't see it. But I have launched Cydia and make it work, it still not shows Cydia.

4. and if you choose Settings:
image

So this is how it looks and functions. I was told this feature is dedicated only for mainland China because laws demand this. It seems like the iOS is reading the iPhone's hardware info to decide if the phone would have this feature. Only devices with Cellular are impacted. I have WIFI only iPad, which is fine. But I didn't have a cellular iPad, so I cannot confirm whether Cellular iPad has this feature.

About Cydia:

If you open Cydia for the first time, it will not have the prompt, nor the internet access. It's not even shown up in the above settings. Just like a ghost. I'm gussing it's because Cydia is installed in /Applications rather than the AppStore apps path in /var/mobile/...

The current workaround I'm using is to JB and ssh into the device, delete all com.apple.network*.plist in /Library/Preferences and reboot again. Then Cydia will have access to internet, but still not showing up in the settings list.

Note if you upgrade the Cydia bundle, it will be blocked again, and you have to repeat above steps to make it work again.

Hope this can help you understand.

Tried this method with the latest release on iOS12, didn't work.

This seems to be the oldest open issue as of now but still unresolved after several months.

I confirm the problem still persists with iOS 12.1 on iPhone 6 with unc0ver v3.0.0%b42.

Symptoms: Cydia does not connect; network permission dialog does not pop up; no "Cydia" in network settings (under Cellular where you can assign network access for apps).

What is worse is that the removing plist trick does not work either @JQ555888.
By "no working" I mean, after deleting those files (and with or without rebooting) --
Cydia still fails connection;
Network permission dialog still does not pop up;
Cydia is still not in network settings so I cannot allow it manually either.

Tried multiple times, no luck.

Installing @laoyur Network Fix deb files does not seem to have any effect either (his fork of unc0ver does not support iOS 12 so I tried to install the deb file with dpkg).

Restoring network settings does not seem to have any effect.
Reinstalling Cydia does not seem to have any effect, even combined with deleting the plist files or restoring network settings or installing @laoyur deb file.

@bfrggit the deb in my fork is for iOS 11 only -- I haven't update it with iOS 12 support
I will upload a new version later.

@bfrggit
com.laoyur.network-fixer.deb.zip

try this one and feedback :)
remove the .zip file extension before install with dpkg
usage: NetworkFixer com.saurik.Cydia

@bfrggit downthumbing me is no sense and won't help anything. The time I comment on the workaround is way before an iOS12 JB POC. I didn't say it would work on iOS12 - it works on iOS 10.3 and iOS 11, though it's sad to find out this.

this is ONLY for China sold iPhones, so I assume you have one if them. If you are in the US, the easiest way is to buy a US model.

@bfrggit
com.laoyur.network-fixer.deb.zip

try this one and feedback :)
remove the .zip file extension before install with dpkg
usage: NetworkFixer com.saurik.Cydia

It worked for me.

  • I downloaded the new file and renamed it to remove ".zip".
  • I SCP-ed it onto the phone.
  • I installed it with dpkg -i.
  • I then ran the command exactly as @laoyur said; note "Cydia" has capital C.
  • Then "Cydia" appears in the list of apps under network settings, and WLAN + Cellular are enabled for it.
  • Cydia works.

@hyl946 Did you try exactly these steps too? What is the output of command NetworkFixer com.saurik.Cydia?

Edit:

  • For @hyl946 I am on 12.1 instead of 12.1.2 so might be different?
  • I cannot really help you debug with the output of the command but I noticed that there were some relevant info there when the command runs... (I did not screenshot sorry...) But the author might be able to help if you provide more details.

uploaded a new deb with a postinst script which should auto call NetworkFixer for Cydia during installation.

com.laoyur.network-fixer-0.1-2.deb.zip

usage:
0. download com.laoyur.network-fixer-0.1-2.deb.zip 👆, and then rename to com.laoyur.network-fixer-0.1-2.deb(remove the .zip part)

  1. scp deb to your phone
  2. install
  3. enjoy Cydia :)
qip commented

Just FYI, apps installed from Cydia can encounter the very same problem, say, Flex 3.
One solution is to get package name from app's Info.plist (might need to convert to xml by plutil in case of bplist), and then run NetworkFixer package.name provided by @laoyur.
Probably not the best way to do it but oh well.

@JQ555888 Menopause?

@JQ555888 Already solved, thank you

Hdot1 commented

@laoyur sorry, all of you people are a bit too technical, idk what scp deb is :(

@laoyur sorry, all of you people are a bit too technical, idk what scp deb is :(

Never expected such comment on Github.
Anyway, why don't you google?

@laoyur 's method works just fine on iOS 12.1.1~12.1.2, across my Chinese region devices, should forget about deleting those plist files.

@Hdot1 so essentially it’s a way to copy files from your PC to your phone via SSH (secure shell) and “scp” is the terminal command to do so. “deb” stands for debian package and it’s the installation file format for jailbroken iOS used by dpkg. You can switch to a graphical interface by using apps like Cyberduck (if on mac) or WinSCP (Windows). Both should do :)

Hdot1 commented

@JQ555888 so I download WinSCP, connect my iPhone to my pc and paste ‘https://github.com/pwn20wndstuff/Undecimus/files/2948085/com.laoyur.network-fixer-0.1-2.deb.zip’ into the WinSCP??

@Hdot1 if you have Filza installed, you can upload deb via webdav, and then install the deb in Filza

Hdot1 commented

@laoyur do I download Filza off safari? What’s webdev?

@Hdot1 actually you don’t have to connect your phone to the PC; just make sure it’s in the same network as your PC. Also you’ll need to get your phone’s internal IPv4 address, and in WinSCP use that IPv4 for host, “root” for username and “alpine” for password so that the client can correctly identify the host

Hdot1 commented

@JQ555888 IPv4? So once the host has been identified I just paste that code into it or something?😂

Hdot1 commented

@JQ555888 much appreciated

Hdot1 commented

@JQ555888 idk what ipv4 is, i thought it was the ip address of my network that everything is connected to

Hdot1 commented

@laoyur how do i use filza i have it downloaded from tweekbox ios 12

@Hdot1 Filza - Preferences - Enable WebDav server - browse PHONE_IP:11111 on your PC - upload deb file to /var/mobile - install deb file in Filza

I am Vietnamese. I bought a Chinese iphone during a trip in China.
And I'm also having this problem. Perhaps buying an iphone in China is a mistake My device is in ios 12.1 😁

. Have you fixed the error? @Hdot1

@laoyur the trouble i'm having is my iphone doesnt have "Open SHH" installed because Cydia dosent have a network connection to download it. How else can i enable my SHH so when i open WinSCP it can find my device ?

@Orgmist unc0ver - settings - check install openssh - hit Jailbreak

@laoyur Thank you, ive copied the file into my temp folder, now how can i install it ? i pressed CTRL T then what ?

@Orgmist
1- Down File .deb

2-CSP .deb file into the var/mobile path (in fact, anywhere)
2-Use WinSPC no wifi or iPhone Tunnel (Terminal) to Console (shortcut Ctrl + T) and then type the following

3-command:
dpkg -i filename.deb

For example install the application
abcde.deb
dpkg -i abcde.deb

4- Reboot machine -> enjoy Cydia
:)))
Sorry, I'm not good at English. :(
and the presentation is too long lại please read the above instructions from @laoyur again

@laoyur @Kidsmile88 Thanks for the help guys i managed !

@Orgmist
Chúc mừng bạn !
🤗

First of all, Chinese people is jailed by their gov. I think they must jailbreak first. lol

long time no one cared about this problem. I don't know if any official bug fixes have been released for "ordinary people" in China. ??? I look forward to it even though I'm not a Chinese citizen. I'm sorry if I bother people again for this comment. 😊

I have the same problem...

IOS12.1 Solution

  • 步驟1. cd「/var/preferences」資料夾內

  • 步驟2. 找到底下三個檔案刪除,刪除前可先備份一次,這三個檔案重開機會自動重新產生。
    com.apple.networkextension.plist、com.apple.networkextension.cache.plist、com.apple.networkextension.necp.plist

  • 步驟3. 最後在刪除三個檔案後,「cinditionalwifi3」插件安裝後就能完美改善此問題。

In china mainland, the iphone has a special function. Anyone who need help, please use www.baidu.com, install a software on PC called“爱思助手”, and then install the tweak called "乐网". and the guide is all over the baidu. Enjoy yourself!

was it fixed on v3.5?

fix nothing

@bfrggit
com.laoyur.network-fixer.deb.zip

try this one and feedback :)
remove the .zip file extension before install with dpkg
usage: NetworkFixer com.saurik.Cydia

it works!

ONLYA commented

@bfrggit
com.laoyur.network-fixer.deb.zip

try this one and feedback :)
remove the .zip file extension before install with dpkg
usage: NetworkFixer com.saurik.Cydia

Thank you! That worked perfectly!

I get an error while installing that states” is not a Debian format archive” . Any fixes? And when I try in filza it says command not found.