Efficiency Class helps Google Maps ship premium experiences

Efficiency Class helps Google Maps ship premium experiences



Posted by Nevin Mital – Developer Relations Engineer, Android Media

The Android ecosystem incorporates a numerous vary of gadgets, and it may be troublesome to construct experiences that benefit from new or premium {hardware} options whereas nonetheless working effectively for customers on all gadgets. With Android 12, we launched the Media Efficiency Class (MPC) commonplace to assist builders higher perceive a tool’s capabilities and establish high-performing gadgets. For a refresher on what MPC is, please see our final weblog submit, Utilizing efficiency class to optimize your person expertise, or take a look at the Efficiency Class documentation.

Earlier this 12 months, we revealed the first steady launch of the Jetpack Core Efficiency library because the really helpful resolution for extra reliably acquiring a tool’s MPC stage. Particularly, this library introduces the PlayServicesDevicePerformance class, an API that queries Google Play Providers to get probably the most up-to-date MPC stage for the present gadget and construct. I’ll get into the technical particulars additional down, however let’s begin by looking at how Google Maps was in a position to tailor a function launch to greatest match every gadget with MPC.

Efficiency Class unblocks premium expertise launch for Google Maps

Google Maps not too long ago took benefit of the expanded gadget protection enabled by the Play Providers module to unblock a function launch. Google Maps wished to replace their UI by growing the transparency of some layers. Consequently, this meant they would wish to render extra of the map, and located they needed to cease the rollout attributable to latency will increase on many gadgets, particularly in the direction of the low-end. To resolve this, the Maps staff began by slicing an present key metric, “seconds to UI merchandise visibility”, by MPC stage, which revealed that whereas all gadgets had a small improve on this latency, gadgets with out an MPC stage had the most important improve.

A bar graph displays A/B test results for Seconds to UI item visibility, comparing control results with those using increased transparency across different Media Performance Class Levels.  A green horizontal line and text indicate the updated experience shipped to devices qualifying for MPC. A vertical green dotted line separates results for devices without a specific MPC level, which kept the previous UI.

With these leads to hand, Google Maps began their rollout once more, however this time solely launching the function on gadgets that report an MPC stage. As gadgets proceed to get up to date and meet the bar for MPC, the up to date Google Maps UI might be obtainable to them as effectively.

The brand new Play Providers module

MPC stage necessities are outlined within the Android Compatibility Definition Doc (CDD), then gadgets and Android builds are validated towards these necessities by the Android Compatibility Check Suite (CTS). The Play Providers module of the Jetpack Core Efficiency library leverages these take a look at outcomes to repeatedly replace a tool’s reported MPC stage with none extra effort in your finish. This additionally signifies that you’ll instantly have entry to the MPC stage for brand spanking new gadget launches without having to accumulate and take a look at every gadget your self, because it already handed CTS. If the MPC stage shouldn’t be obtainable from Google Play Providers, the library will fall again to the MPC stage declared by the OEM as a construct fixed.

A flowchart depicts the process of determining Performance Class levels for Android devices, involving manufacturers, CTS tests, a Grader, the Play Services module, and the CDD.

As of writing, greater than 190M in-market gadgets masking over 500 fashions throughout 40+ manufacturers report an MPC stage. This protection will proceed to develop over time, as older gadgets replace to newer builds, from Android 11 and up.

Utilizing the Core Efficiency library

To make use of Jetpack Core Efficiency, begin by including a dependency for the related modules in your Gradle configuration, and create an occasion of DevicePerformance. Initializing a DevicePerformance ought to solely occur as soon as in your app, as early as potential – for instance, within the onCreate() lifecycle occasion of your Utility. On this instance, we’ll use the Google Play providers implementation of DevicePerformance.

// Implementation of Jetpack Core library.
implementation("androidx.core:core-ktx:1.12.0")
// Allow APIs to question for device-reported efficiency class.
implementation("androidx.core:core-performance:1.0.0")
// Allow APIs to question Google Play Providers for efficiency class.
implementation("androidx.core:core-performance-play-services:1.0.0")

import androidx.core.efficiency.play.providers.PlayServicesDevicePerformance

class MyApplication : Utility() {
  lateinit var devicePerformance: DevicePerformance

  override enjoyable onCreate() {
    // Use a category derived from the DevicePerformance interface
    devicePerformance = PlayServicesDevicePerformance(applicationContext)
  }
}

Then, later in your app while you wish to retrieve the gadget’s MPC stage, you’ll be able to name getMediaPerformanceClass():

class MyActivity : Exercise() {
  personal lateinit var devicePerformance: DevicePerformance
  override enjoyable onCreate(savedInstanceState: Bundle?) {
    tremendous.onCreate(savedInstanceState)
    // Notice: Good app structure is to make use of a dependency framework. See
    // https://developer.android.com/coaching/dependency-injection for extra
    // info.
    devicePerformance = (utility as MyApplication).devicePerformance
  }

  override enjoyable onResume() {
    tremendous.onResume()
    when {
      devicePerformance.mediaPerformanceClass >= Construct.VERSION_CODES.UPSIDE_DOWN_CAKE -> {
        // MPC stage 34 and later.
        // Present probably the most premium expertise for the best performing gadgets.
      }
      devicePerformance.mediaPerformanceClass == Construct.VERSION_CODES.TIRAMISU -> {
        // MPC stage 33.
        // Present a top quality expertise.
      }
      else -> {
        // MPC stage 31, 30, or undefined.
        // Take away extras to maintain expertise useful.
      }
    }
  }
}

Methods for utilizing Efficiency Class

MPC is meant to establish high-end gadgets, so you’ll be able to count on to see MPC ranges for the highest gadgets from every year, that are the gadgets you’re more likely to need to have the ability to assist for the longest time. For instance, the Pixel 9 Professional launched with Android 14 and stories an MPC stage of 34, the most recent stage definition when it launched.

It is best to use MPC as a complement to any present System Clustering options you already use, corresponding to querying a tool’s static specs or manually blocklisting problematic gadgets. An space the place MPC generally is a significantly useful device is for brand spanking new gadget launches. New gadgets ought to be included at launch, so you should utilize MPC to gauge new gadgets’ capabilities proper from the beginning, without having to accumulate the {hardware} your self or manually take a look at every gadget.

An awesome first step to get entangled is to incorporate MPC ranges in your telemetry. This can assist you establish patterns in error stories or usually get a greater sense of the gadgets your person base makes use of in case you section key metrics by MPC stage. From there, you may think about using MPC as a dimension in your experimentation pipeline, for instance by organising A/B testing teams primarily based on MPC stage, or by beginning a function rollout with the best MPC stage and dealing your method down. As mentioned beforehand, that is the method that Google Maps took.

You may additional use MPC to tune a user-facing function, for instance by adjusting the variety of concurrent video playbacks your app makes an attempt primarily based on the MPC stage’s concurrent codec ensures. Nonetheless, be certain to nonetheless question a tool’s runtime capabilities when utilizing this method, as they could differ relying on the setting and state the gadget is in.

Get in contact!

If MPC sounds prefer it might be helpful on your app, please give it a attempt! You may get began by looking at our pattern code or documentation. We welcome you to share any questions or suggestions you’ve gotten on this quick type.

This weblog submit is part of Digicam and Media Highlight Week. We’re offering assets – weblog posts, movies, pattern code, and extra – all designed that will help you uplevel the media experiences in your app.

To be taught extra about what Highlight Week has to supply and the way it can profit you, remember to learn our overview weblog submit.

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 
rooshohttps://www.roosho.com
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here


Latest Articles

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog.