[Nexus 7 (2013) Android Development] zman0900:
Wifi Broken

Wifi is not working at all on my flo. I've tried with both the latest nightly (3/28) and the oldest available (3/24) and both have the same problem. I've tried with and without installing gapps, and once I even tried installing the Glitch kernel and using its option to disable selinux. All of these installs have been completely clean including a system partition wipe. My encrypted data partition remains, but I did a factory reset between every install to clean it out.

In all cases, wifi refuses to turn on.

It worked fine on CM 11 M12, so it shouldn't be a hardware issue. I noticed that there were quite a few wifi related changes on 3/24 (according to this: http://www.cmxlog.com/12/flo#cm-12-20150324-NIGHTLY-flo.zip). I planned to try the previous 3/22 nightly, but it and everything older 404 on the download page.

Here is an excerpt from logcat. This is a clean install of 3/28 with no gapps and no custom kernel. It looks like there is some issue with the firmware.

E/rmt_storage( 4736): Unable to change dir
E/rmt_storage( 4736): Failed in getting the physical address for shared mem
E/ELEVEN ( 4141): calling refresh!
D/WifiService( 2002): New client listening to asynchronous messages
D/WifiService( 2002): setWifiEnabled: true pid=3994, uid=1000
E/WifiService( 2002): Invoking mWifiStateMachine.setWifiEnabled
D/audio_hw_primary( 1581): select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
D/ACDB-LOADER( 1581): ACDB -> send_afe_cal
D/audio_hw_primary( 1581): enable_snd_device: snd_device(2: speaker)
D/audio_hw_primary( 1581): enable_audio_route: apply and update mixer path: low-latency-playback
E/WifiHW ( 1577): Failed to write wlan fw path param (Operation not permitted)
E/SoftapController( 1577): Softap fwReload failed
E/WifiStateMachine( 2002): Failed to reload STA firmware java.lang.IllegalStateException: command '16 softap fwreload wlan0 STA' failed with '400 16 SoftAP command has failed'
W/CommandListener( 1577): Failed to retrieve HW addr for wlan0 (No such device)
D/CommandListener( 1577): Setting iface cfg
E/WifiStateMachine( 2002): Unable to change interface settings: java.lang.IllegalStateException: command '18 interface setcfg wlan0 0.0.0.0 0 down' failed with '400 18 Failed to set address (No such device)'
I/ActivityManager( 2002): START u0 {act=com.android.net.wifi.SETUP_WIFI_NETWORK cmp=com.android.settings/.wifi.WifiSetupActivity (has extras)} from uid 1000 on display 0
I/wpa_supplicant( 4745): Successfully initialized wpa_supplicant
I/wpa_supplicant( 4745): rfkill: Cannot open RFKILL control device
E/wpa_supplicant( 4745): Could not read interface p2p0 flags: No such device
E/wpa_supplicant( 4745): Could not read interface p2p0 flags: No such device
E/wpa_supplicant( 4745): p2p0: Failed to initialize driver interface
W/WindowManager( 2002): Token{e008268 ActivityRecord{2788918b u0 com.android.settings/.wifi.WifiSetupActivity t2}} failed creating starting window
W/WindowManager( 2002): java.lang.RuntimeException: Failed to resolve attribute at index 6
W/WindowManager( 2002):	at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:603)
W/WindowManager( 2002):	at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:6423)
W/WindowManager( 2002):	at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:6591)
W/WindowManager( 2002):	at android.widget.LinearLayout$LayoutParams.<init>(LinearLayout.java:1864)
W/WindowManager( 2002):	at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1776)
W/WindowManager( 2002):	at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:62)
W/WindowManager( 2002):	at android.view.LayoutInflater.rInflate(LayoutInflater.java:808)
W/WindowManager( 2002):	at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
W/WindowManager( 2002):	at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
W/WindowManager( 2002):	at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
W/WindowManager( 2002):	at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:3748)
W/WindowManager( 2002):	at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3820)
W/WindowManager( 2002):	at com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:1967)
W/WindowManager( 2002):	at com.android.internal.policy.impl.PhoneWindowManager.addStartingWindow(PhoneWindowManager.java:2299)
W/WindowManager( 2002):	at com.android.server.wm.WindowManagerService$H.handleMessage(WindowManagerService.java:7692)
W/WindowManager( 2002):	at android.os.Handler.dispatchMessage(Handler.java:102)
W/WindowManager( 2002):	at android.os.Looper.loop(Looper.java:135)
W/WindowManager( 2002):	at android.os.HandlerThread.run(HandlerThread.java:61)
W/WindowManager( 2002):	at com.android.server.ServiceThread.run(ServiceThread.java:46)
E/WifiStateMachine( 2002): Failed to start supplicant!
I/ActivityManager( 2002): Start proc com.android.settings for activity com.android.settings/.wifi.WifiSetupActivity: pid=4752 uid=1000 gids={41000, 9997, 3003, 1028, 1015, 3002, 3001} abi=armeabi-v7a
W/MediaScanner( 3931): Error opening directory '/storage/usbdisk/', skipping: Permission denied.

EDIT 1: I removed the encryption by formatting the data partition then re-installed the 3/28 nightly the same as above, and the wifi works now. So this means either the encryption itself or something stored in my /sdcard partition was somehow breaking wifi. I originally created the encryption by just flashing stock 5.0.2, setting a lock screen password, then clicking the encrypt option. After that I restored my files to /sdcard that I had backed up from before, installed TWRP, performed a factory reset, and started installing CM.

EDIT 2: I redid the encryption from within the 3/28 install I did in the last edit, and wifi continued to work. Does CM do something different in the way it sets up encryption compared to stock? I am going to factory reset and reflash 3/28 again now that I have an encrypted partition created by CM...

EDIT 3: Ok, looks like the problem is just encryption in general. I did a factory reset and formatted /system, leaving just the (now empty) encrypted data partition created by CM. The only stuff in /sdcard on that encrypted partition is what was automatically created by android and the cm nightly zip. Again I installed the 3/28 nightly and when it booted up, the first boot wizard couldn't turn on wifi, and after completing that I can't turn it on myself either. The same errors are in the log as above. Here is the complete logcat up through exiting the first boot wizard and entering the settings to turn on adb: http://pastebin.com/cKZFX8qP

EDIT 4: Yesterday I did the same process on my nexus 4 to get a clean, encrypted install of CM 12 and it worked with no issues, so this is probably something specific to this device. For clarity, the exact process used on both devices:

Backup contents of /sdcard to computer with adb pull

Flash latest stock lollipop image

Set lock screen password

Turn on encryption

Install TWRP 2.8.2.2. (2.8.5.2 for nexus 4) Older versions required because all newer are broken for encryption.

Use TWRP's factory reset (formats cache and deletes everything in /data but not in /data/media)

Format /system partition

Use adb push to restore backup of files previously in /sdcard/

Install latest CM 12 nightly and gapps

Reboot

Also, while I've been typing this, I tried doing an actual factory reset from with CM while the wifi was broken, and it just put me into a boot loop with the twrp splash screen flashing on and off. It seems to have actually damaged the recovery partition somehow, because even after I stopped the loop, trying to boot recovery starts it again. But this is probably unrelated to the main issue here.

EDIT 5: Not sure what that factory reset did, but even reflashing the recovery didn't fix it. Had to do a fastboot -w to format everything just to get back into recovery.

EDIT 6: I did one final experiment. I formatted all partitions (removing encryption), installed 3/24 nightly with gapps, set up encryption, then upgraded to 3/28 nightly. The wifi continued to work the entire time.

Then I performed factory reset in TWRP (clears everything except /data/media from /data and formats cache), but didn't format /system and installed 3/28 nightly plus gapps again. Now I'm back to the first boot wizard and wifi won't work.

So this seems to prove that something is getting written to /data during the first boot that is required for wifi to work, but that doesn't happen when encryption is already in place. Encryption basically makes android do a boot with /data unmounted just to accept the password then soft-reboot after mounting /data. So maybe whatever is written that makes wifi work only happens on the very first boot, the boot to the password screen while /data isn't mounted yet, so the write fails. Then it is not retrying on the "real" boot when /data is unlocked and mounted. Strange the nexus 4 doesn't have this problem, but maybe this problem is specific to the wifi driver.