Apple is inching closer to Samsung in gloomy global smartphone market