Coder Social home page Coder Social logo

device-year-class's Introduction

Devices by Year Class Device Year Class

Device Year Class is an Android library that implements a simple algorithm that maps a device's RAM, CPU cores, and clock speed to the year where those combination of specs were considered high end. This allows a developer to easily modify application behavior based on the capabilities of the phone's hardware.

Most Popular Devices by Year Class

Mappings as of this writing (RAM is a ceiling):

RAM condition Year Class
768MB 1 core 2009
2+ cores 2010
1GB <1.3GHz 2011
1.3GHz+ 2012
1.5GB <1.8GHz 2012
1.8GHz+ 2013
2GB 2013
3GB 2014
5GB 2015
more 2016

Integration

Download

Download the latest JARs or grab via Gradle:

compile 'com.facebook.device.yearclass:yearclass:2.1.0'

or Maven:

<dependency>
  <groupId>com.facebook.device.yearclass</groupId>
  <artifactId>yearclass</artifactId>
  <version>2.1.0</version>
</dependency>

Calculate Device Year Class

Calculating the current device's Year Class is simple.

int year = YearClass.get(getApplicationContext());

Then, later on, you can use the year class to make decisions in your app, or send it along with your analytics.

if (year >= 2013) {
    // Do advanced animation
} else if (year > 2010) {
    // Do simple animation
} else {
    // Phone too slow, don't do any animations
}

See the yearclass-sample project for more details.

Improve Device Year Class!

See the CONTRIBUTING.md file for how to help out.

License

Device Year Class is BSD-licensed. We also provide an additional patent grant.

device-year-class's People

Contributors

ashishb avatar dasmer avatar divayprakash avatar elizahale avatar friederbluemle avatar lozzle avatar macarse avatar rrong avatar seyelenteco avatar trevor-e avatar zlern2k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

device-year-class's Issues

Why doing & 0x01?

I noticed you guys are using:

if ((componentYears.size() & 0x01) == 1) {  // Odd number; pluck the median.

Why not using % directly?

2016/2017 year class profiles

I recently spoke to someone at DroidconSF about whether this library was stale or not and they indicated it wasn't. They had mentioned that it had been updated internally for newer device year classes and that they should be released publicly and requested I open an issue as there might be a problem with the release process. It'd be great if this library could get a public update with profiles for 2016/2017. Thanks.

Year class for Nexus 6P is 2013?

I get 2013 for the Nexus 6p which is clearly wrong since this device was considered high end in 2015 and 2016. I'm using the latest Android 7.1 dev preview.

It's also weird because for a Samsung S6 which has similar specs, i get 2014 which is more reasonable but should really be 2015. The Samsung is running on Android 6 which makes me think there's something wrong with Android 7.

Define the standards for 2015 year class

Now that 2015 has come to a close, and we are now in 2016, it should be possible to declare the standards necessary for a YearClass.CLASS_2015 device year classification.

can not read cpu info with android N

virtual core file permission denied - i.e. sys/devices/system/cpu/cpu6/cpufreq/cpuinfo_max_freq

add if (cpuInfoMaxFreqFile.canRead()) { to LINE 84 of DeviceInfo to f

profiles after 2016

👋

We are actively using this library(and thanks!) and would love to see profiles after 2016. Will there be an update in the near future?

-Jingwei

5.0 crash when use in attachBaseContext

4 Caused by:
5 java.lang.IllegalStateException:System services not available to Activities before onCreate()
6 android.app.Activity.getSystemService(Activity.java:5027)
7 com.facebook.device.yearclass.DeviceInfo.getTotalMemory(SourceFile:183)
8 com.facebook.device.yearclass.YearClass.categorizeByYear2016Method(SourceFile:65)
9 com.facebook.device.yearclass.YearClass.get(SourceFile:45)
10 cn.jingzhuan.stock.ui.BaseActivity.attachBaseContext(SourceFile:37)
11 android.app.Activity.attach(Activity.java:5910)
12 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2402)
13 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2530)
14 android.app.ActivityThread.access$800(ActivityThread.java:171)
15 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1425)
16 android.os.Handler.dispatchMessage(Handler.java:111)
17 android.os.Looper.loop(Looper.java:194)
18 android.app.ActivityThread.main(ActivityThread.java:5572)
19 java.lang.reflect.Method.invoke(Native Method)
20 java.lang.reflect.Method.invoke(Method.java:372)
21 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:966)
22 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.