(Reuters) - BlackBerry Ltd reported better-than-expected adjusted earnings for the sixth straight quarter, as the smartphone pioneer’s shift to the higher-margin software business paid off.

A Blackberry logo hangs behind a Canadian flag at their offices on the day of their annual general meeting for shareholders in Waterloo, Canada June 23, 2015. REUTERS/Mark Blinch/File Photo

The Canadian firm also said on Friday it expects to be profitable on an adjusted basis for the second year in a row, and generate positive free cash flow in the year ending February 2018.

The company’s U.S. shares closed up 11.5 percent at $7.75 on Friday, and its Toronto-listed shares closed up 11 percent at C$10.30.

Waterloo, Ontario-based BlackBerry has focused on building a robust software business after scrapping production of its once-iconic smartphones, which lost favor with the arrival of sleek and fully touchscreen handsets.

The company outsourced the development of its smartphones last year, signing a deal with Indonesia’s BB Merah Putih to make and distribute new BlackBerry-branded devices. It has also signed similar deals with China’s TCL and India-based Optiemus Infracom Ltd.

Adjusted revenue from the software and services unit, which includes mobile device management products and the QNX industrial operating system, rose 12.2 percent to $193 million in the fourth quarter ended Feb. 28, from the preceding quarter.

QNX is crucial to BlackBerry’s efforts in the self-driving vehicle industry. The company already has a partnership with Ford Motor Co to develop autonomous driving software, and Chief Executive John Chen hopes to forge such deals with carmakers around the world.

On an adjusted basis, the company’s total revenue was $297 million, beating analysts’ average estimate of $289.3 million.

“They (Blackberry) put up a good quarter on the software revenue side, but if you dig a little deeper a lot of that beat was driven by relatively lumpy professional services revenue,” Cavan Yie, portfolio manager at Manulife Asset Management, told Reuters.

Yie said Manulife has stayed away from the stock due to Blackberry’s lack of free cash-flow generation, but that could change given the “potential for good things to come out” of the software business.

Gross margin jumped to 60.1 percent in the quarter from 43.3 percent last year.

BlackBerry received more than 3,500 enterprise customer orders in the quarter, a 16.7 percent increase from the third quarter.

“Looking ahead to fiscal 2018, we expect to grow at or above the overall market in our software business,” Chen said in a statement.

Excluding one-time items, the company earned 4 cents per share. Analysts on average had expected the company to break even, according to Thomson Reuters I/B/E/S.

Operating expenses nearly halved to $229 million.