Skip to content
This repository was archived by the owner on Mar 3, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: ci
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: gradle/wrapper-validation-action@v1
- run: ./gradlew build
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.gradle
/local.properties
/.idea
.gradle/
local.properties
.idea/
*.iml
.DS_Store
/build
build/
.watchmanconfig
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ![Devices by Year Class](https://github.com/facebook/device-year-class/raw/master/docs/images/logo_trans_square.png) Device Year Class

[![ci][1]][2]

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
Expand Down Expand Up @@ -65,3 +67,6 @@ See the [CONTRIBUTING.md](https://github.com/facebook/device-year-class/blob/mas

## License
Device Year Class is [BSD-licensed](https://github.com/facebook/device-year-class/blob/master/LICENSE). We also provide an additional patent grant.

[1]: https://github.com/facebook/device-year-class/workflows/ci/badge.svg
[2]: https://github.com/facebook/device-year-class/actions
10 changes: 7 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.android.tools.build:gradle:3.6.1'
}
}

allprojects {
repositories {
google()
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Tue Apr 11 17:45:27 SGT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
28 changes: 22 additions & 6 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions release.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ afterEvaluate { project ->

android.libraryVariants.all { variant ->
def name = variant.name.capitalize()
task "jar${name}"(type: Jar, dependsOn: variant.javaCompile) {
from variant.javaCompile.destinationDir
task "jar${name}"(type: Jar, dependsOn: variant.javaCompileProvider.get()) {
from variant.javaCompileProvider.get().destinationDir
}
}

Expand Down Expand Up @@ -65,7 +65,6 @@ afterEvaluate { project ->
authentication(
userName: getMavenRepositoryUsername(),
password: getMavenRepositoryPassword())

}

pom.project {
Expand Down
1 change: 0 additions & 1 deletion yearclass-sample/.gitignore

This file was deleted.

15 changes: 5 additions & 10 deletions yearclass-sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
apply plugin: 'com.android.application'

repositories {
jcenter()
}

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"

compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.facebook.device.yearclass.sample"
minSdkVersion 11
targetSdkVersion 25
minSdkVersion 14
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
}

dependencies {
compile project(':yearclass')
implementation project(':yearclass')
}
6 changes: 6 additions & 0 deletions yearclass-sample/lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="GoogleAppIndexingWarning" severity="ignore"/>
<issue id="GradleDependency" severity="informational"/>
<issue id="OldTargetApi" severity="informational"/>
</lint>
3 changes: 2 additions & 1 deletion yearclass-sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
package="com.facebook.device.yearclass.sample">

<application
android:allowBackup="true"
android:allowBackup="false"
android:icon="@drawable/ic_launcher"
android:fullBackupContent="false"
android:label="@string/app_name">
<activity
android:name=".MainActivity"
Expand Down
1 change: 0 additions & 1 deletion yearclass/.gitignore

This file was deleted.

27 changes: 8 additions & 19 deletions yearclass/build.gradle
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@
apply plugin: 'com.android.library'

repositories {
jcenter()
}

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"

compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
minSdkVersion 9
targetSdkVersion 25
minSdkVersion 14
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
}

dependencies {
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.0.21-beta'
testCompile ('org.powermock:powermock-api-mockito:1.6.3') {
exclude module: 'hamcrest-core'
exclude module: 'objenesis'
}
testCompile ('org.powermock:powermock-module-junit4:1.6.3') {
exclude module: 'hamcrest-core'
exclude module: 'objenesis'
}
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.0.21-beta'
testImplementation 'org.powermock:powermock-api-mockito:1.6.3'
testImplementation 'org.powermock:powermock-module-junit4:1.6.3'
}

apply from: rootProject.file('release.gradle')
6 changes: 1 addition & 5 deletions yearclass/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.facebook.device.yearclass">

<application/>

<manifest package="com.facebook.device.yearclass">
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ public class DeviceInfo {
* @return Number of CPU cores in the phone, or DEVICEINFO_UKNOWN = -1 in the event of an error.
*/
public static int getNumberOfCPUCores() {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
// Gingerbread doesn't support giving a single application access to both cores, but a
// handful of devices (Atrix 4G and Droid X2 for example) were released with a dual-core
// chipset and Gingerbread; that can let an app in the background run without impacting
// the foreground application. But for our purposes, it makes them single core.
return 1;
}
int cores;
try {
cores = getCoresFromFileInfo("/sys/devices/system/cpu/possible");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ public void testTotalRAM() {

@PrepareForTest(DeviceInfo.class)
@Test
public void testGetYearCategoryS7() {
public void testGetYearCategoryN8() {
// CPU, frequency, RAM, and YearClass values from Samsung Galaxy Note8 (USA edition).
int yearClass = getYearClass(8, 2350000, 6144L * 1024 * 1024);
assertEquals(YearClass.CLASS_2016, yearClass);
}

@PrepareForTest(DeviceInfo.class)
@Test
public void testTotalRAM() {
public void testTotalRAM2016() {
//Test with only total RAM information available.
int yearClass = getYearClass(DeviceInfo.DEVICEINFO_UNKNOWN,
DeviceInfo.DEVICEINFO_UNKNOWN, 6144L * 1024 * 1024);
Expand Down