OAKLAND (AP) — Apple CEO Tim Cook described the company’s ironclad control over its mobile app store as the best way to serve and protect iPhone users, but he faced tough questions about competition issues from a judge Friday about allegations he oversees an illegal monopoly.

The rare courtroom appearance by one of the world’s best-known executives came during the closing phase of a three-week trial revolving around an antitrust case brought by Epic Games, maker of the popular video game Fortnite.

READ MORE: UPDATE: Many in East Bay Still Without Power

Epic is trying to topple the so-called “walled garden” for iPhone and iPad apps that welcomes users and developers while locking out competition. Created by Apple co-founder Steve Jobs a year after the iPhone’s 2007 debut, the App Store has become a key revenue source for Apple, helping power the company to a $57 billion profit in its last fiscal year.

The trial focuses on Epic’s contention that Apple has turned its store into a price-gouging vehicle that not only reaps a 15% to 30% commission from in-app transactions, but blocks apps from offering other payment alternatives. That ban extends to showing a link that would open a web page offering commission-free ways to pay for subscriptions, in-game items and the like.

Under friendly questioning from a company lawyer, Cook delivered polished remarks that sometimes sounded like a commercial for the iPhone and other Apple products.

But the normally unflappable CEO occasionally seemed flustered while being grilled by Epic lawyer Gary Bornstein. His unease was particularly evident when pressed about the level of profits in a store that Jobs initially thought would be lucky to break even. He seemed to stumble slightly again when when Bornstein confronted him about a deal in China that could compromise user privacy, even as the company maintains that protecting its customers’ personal information is a top priority.

Tim Cook, chief executive officer of Apple Inc., arrives at U.S. district court in Oakland, California, U.S., on Friday, May 21, 2021. About 47,600 games are featured on Apple’s App Store under the same “freemium” model used by Fortnite, according to court testimony from a senior executive at the iPhone maker, signaling that the outcome of a lawsuit brought by Epic Games Inc. could have broad ramifications for other game developers. Photographer: Nina Riggio/Bloomberg via Getty Images

Cook, though, never wavered during nearly four hours of testimony from his position that Apple’s grip on the app store helps it keep things simple for a loyal customer base that buys iPhones knowing they getting “something that just works.”

“They buy into an entire ecosystem when they buy an iPhone,” said Cook, who wore a face shield, but no mask in an Oakland, courtroom that has limited access because of the pandemic.

It wasn’t at all clear that the federal judge who will decide the case was buying everything Cook said on the stand.

READ MORE: Menlo Park Man Stabbed at Party

After the lawyers were done with their questioning, U.S. District Judge Yvonne Gonzalez Rogers asked why Apple can’t allow rival stores to offer an in-app transaction option on iPhones, iPads and iPods that might charge lower commissions. That is something Epic is fighting to make it happen, partly because it has a still unprofitable store that imposes a 12% commission.

Gonzalez Rogers seemed particularly troubled by a survey indicating 39% of iPhone app developers aren’t happy with the current distribution system. She also wondered about the fairness of a commission system requiring the makers of video games pay the bulk of the commissions, while digital services offered in other industries such as banking don’t pay anything, even though they are using the technology that powers iPhones.

“The gaming industry seems to be generating a disproportionate amount of money relative to the (intellectual property) that you are giving them and everybody else? In a sense it’s almost as if they are subsidizing everybody else,” Gonzalez Rogers said.

Cook agreed about the subsidy, but insisted there is still a fair balance because video game makers are able to reach a wider audience of consumers who become players while visiting the store looking at other apps. He took issue with the notion that most app makers are unhappy with the store’s current setup.

“We turn the place upside down for developers,” Cook said.

Gonzalez Rogers also didn’t seem to buy Apple’s explanation for a move it made last year when it lowered its commission on in-app commissions to 15% on the first $1 million in revenue. Although the price cut came after Epic filed its antitrust case in August, Apple said the discount was driven by desire to provide a helping hand during a pandemic-driven recession.

“At least what I’ve seen so far, that really wasn’t the result of competition, (but) the pressure you were feeling,” Gonzalez Rogers told Cook. Apple’s app store practices are being examined by regulators and lawmakers in the U.S. and Europe while Epic pursues its case.

Gonzalez Rogers is expected to elaborate issues still weighing on her mind Monday when she plans to pose questions to lawyers on both sides while they make their final points before she takes the matter under submission. The judge said she hopes to release her decision before Aug. 13 in a written ruling that could reshape the technology landscape.

MORE NEWS: One Dead, Three Wounded In Early Sunday Morning Shooting In Oakland's Uptown Neighborhood

© Copyright 2021 The Associated Press. All Rights Reserved. This material may not be published, broadcast, rewritten or redistributed.