Apple released OS X/Darwin open source, but kept the moneymaking frameworks (cocoa, carbon) closed source. This generated positive PR while keeping the secret sauce needed to ship polished applications under lock and key
Google released Android open source, but then made unlocking bootloaders and flashing devices as difficult as possible for laymen. So they get to point at AOSP and say "open source" but in practice the vast majority of users end up running proprietary builds with big G's telemetry baked in