├── settings.gradle ├── .github ├── ISSUE_TEMPLATE │ ├── config.yml │ ├── issue_zh_template_suggest.yml │ ├── issue_zh_template_question.yml │ ├── issue_en_template_suggest.yml │ ├── issue_en_template_question.yml │ ├── issue_zh_template_adaptation.yml │ ├── issue_en_template_adaptation.yml │ ├── issue_zh_template_bug.yml │ └── issue_en_template_bug.yml ├── workflows │ └── android.yml └── FUNDING.yml ├── logo.png ├── library ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── hjq │ │ └── device │ │ └── compat │ │ ├── SystemPropertyCompat.java │ │ ├── DeviceBrand.java │ │ ├── DeviceMarketName.java │ │ └── DeviceOs.java └── build.gradle ├── app ├── AppSignature.jks ├── gradle.properties ├── src │ └── main │ │ ├── res │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ └── styles.xml │ │ ├── values-v23 │ │ │ └── styles.xml │ │ └── layout │ │ │ ├── system_property_activity.xml │ │ │ └── main_activity.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── hjq │ │ └── device │ │ └── compat │ │ └── demo │ │ ├── SystemPropertyActivity.java │ │ ├── MainActivity.java │ │ └── ShellUtils.java ├── proguard-rules.pro └── build.gradle ├── picture ├── demo_os_miui.jpg ├── demo_os_one_ui.jpg ├── demo_os_color_os.jpg ├── demo_os_magic_os.jpg ├── demo_os_harmony_os.jpg ├── android_brand_os_summary.png ├── download_demo_apk_qr_code.png └── demo_os_harmony_os_next_android_compatible.jpg ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── common.gradle ├── gradlew.bat ├── gradlew ├── LICENSE └── README.md /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':library' 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getActivity/DeviceCompat/HEAD/logo.png -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/AppSignature.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getActivity/DeviceCompat/HEAD/app/AppSignature.jks -------------------------------------------------------------------------------- /picture/demo_os_miui.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getActivity/DeviceCompat/HEAD/picture/demo_os_miui.jpg -------------------------------------------------------------------------------- /picture/demo_os_one_ui.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getActivity/DeviceCompat/HEAD/picture/demo_os_one_ui.jpg -------------------------------------------------------------------------------- /picture/demo_os_color_os.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getActivity/DeviceCompat/HEAD/picture/demo_os_color_os.jpg -------------------------------------------------------------------------------- /picture/demo_os_magic_os.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getActivity/DeviceCompat/HEAD/picture/demo_os_magic_os.jpg -------------------------------------------------------------------------------- /picture/demo_os_harmony_os.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getActivity/DeviceCompat/HEAD/picture/demo_os_harmony_os.jpg -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getActivity/DeviceCompat/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /picture/android_brand_os_summary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getActivity/DeviceCompat/HEAD/picture/android_brand_os_summary.png -------------------------------------------------------------------------------- /picture/download_demo_apk_qr_code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getActivity/DeviceCompat/HEAD/picture/download_demo_apk_qr_code.png -------------------------------------------------------------------------------- /app/gradle.properties: -------------------------------------------------------------------------------- 1 | StoreFile = AppSignature.jks 2 | StorePassword = AndroidProject 3 | KeyAlias = AndroidProject 4 | KeyPassword = AndroidProject -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | .idea 3 | .cxx 4 | .externalNativeBuild 5 | build 6 | captures 7 | 8 | ._* 9 | *.iml 10 | .DS_Store 11 | local.properties -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getActivity/DeviceCompat/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getActivity/DeviceCompat/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getActivity/DeviceCompat/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | DeviceCompat 4 | -------------------------------------------------------------------------------- /picture/demo_os_harmony_os_next_android_compatible.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getActivity/DeviceCompat/HEAD/picture/demo_os_harmony_os_next_android_compatible.jpg -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #000000 4 | #000000 5 | #FF0033 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | zipStoreBase = GRADLE_USER_HOME 2 | zipStorePath = wrapper/dists 3 | distributionBase = GRADLE_USER_HOME 4 | distributionPath = wrapper/dists 5 | distributionUrl = https\://services.gradle.org/distributions/gradle-6.5-all.zip -------------------------------------------------------------------------------- /.github/workflows/android.yml: -------------------------------------------------------------------------------- 1 | name: Android CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v2 12 | - name: set up JDK 1.8 13 | uses: actions/setup-java@v1 14 | with: 15 | java-version: 1.8 16 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/values-v23/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: https://raw.githubusercontent.com/getActivity/Donate/master/picture/pay_ali.png 13 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\SDK\Studio\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /common.gradle: -------------------------------------------------------------------------------- 1 | // 通用配置 2 | android { 3 | 4 | // 编译源码版本 5 | compileSdk 34 6 | defaultConfig { 7 | // 最低安装版本 8 | minSdk 17 9 | // Android 版本适配指南:https://github.com/getActivity/AndroidVersionAdapter 10 | targetSdk 34 11 | versionCode 25 12 | versionName "2.5" 13 | } 14 | 15 | // 支持 Java JDK 8 16 | compileOptions { 17 | targetCompatibility JavaVersion.VERSION_1_8 18 | sourceCompatibility JavaVersion.VERSION_1_8 19 | } 20 | 21 | // 读取 local.properties 文件配置 22 | def properties = new Properties() 23 | def localPropertiesFile = rootProject.file("local.properties") 24 | if (localPropertiesFile.exists()) { 25 | localPropertiesFile.withInputStream { inputStream -> 26 | properties.load(inputStream) 27 | } 28 | } 29 | 30 | String buildDirPath = properties.getProperty("build.dir") 31 | if (buildDirPath != null && buildDirPath != "") { 32 | // 将构建文件统一输出到指定的目录下 33 | setBuildDir(new File(buildDirPath, rootProject.name + "/build/${path.replaceAll(':', '/')}")) 34 | } else { 35 | // 将构建文件统一输出到项目根目录下的 build 文件夹 36 | setBuildDir(new File(rootDir, "build/${path.replaceAll(':', '/')}")) 37 | } 38 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/system_property_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 18 | 19 | 26 | 27 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/hjq/device/compat/demo/SystemPropertyActivity.java: -------------------------------------------------------------------------------- 1 | package com.hjq.device.compat.demo; 2 | 3 | import android.content.Intent; 4 | import android.net.Uri; 5 | import android.os.Bundle; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.util.Log; 8 | import android.widget.TextView; 9 | import com.hjq.bar.OnTitleBarListener; 10 | import com.hjq.bar.TitleBar; 11 | import com.hjq.device.compat.demo.ShellUtils.CommandResult; 12 | 13 | public final class SystemPropertyActivity extends AppCompatActivity { 14 | 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.system_property_activity); 19 | 20 | TextView messageView = findViewById(R.id.tv_system_property_messages); 21 | 22 | TitleBar titleBar = findViewById(R.id.tb_system_property_bar); 23 | titleBar.setOnTitleBarListener(new OnTitleBarListener() { 24 | @Override 25 | public void onTitleClick(TitleBar titleBar) { 26 | Intent intent = new Intent(Intent.ACTION_VIEW); 27 | intent.setData(Uri.parse(titleBar.getTitle().toString())); 28 | startActivity(intent); 29 | } 30 | }); 31 | 32 | new Thread(() -> { 33 | CommandResult systemPropertyInfo = ShellUtils.execCmd("getprop", false, true); 34 | Log.i("DeviceCompat", systemPropertyInfo.successMsg); 35 | runOnUiThread(() -> messageView.setText(systemPropertyInfo.successMsg)); 36 | }).start(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/issue_zh_template_suggest.yml: -------------------------------------------------------------------------------- 1 | name: 提交建议 2 | description: 请告诉我框架的不足之处,让我做得更好! 3 | title: "[建议]:" 4 | labels: ["help wanted"] 5 | 6 | body: 7 | - type: markdown 8 | attributes: 9 | value: | 10 | ## [【警告:请务必按照 issue 模板填写,不要抱有侥幸心理,一旦发现 issue 没有按照模板认真填写,一律直接关闭】](https://github.com/getActivity/IssueTemplateGuide) 11 | - type: textarea 12 | id: input_id_1 13 | attributes: 14 | label: 你觉得框架有什么不足之处?【必答】 15 | description: 你可以描述框架有什么令你不满意的地方 16 | validations: 17 | required: true 18 | - type: dropdown 19 | id: input_id_2 20 | attributes: 21 | label: issue 是否有人曾提过类似的建议?【必答】 22 | description: 一旦出现重复提问我将不会再次解答 23 | multiple: false 24 | options: 25 | - "未选择" 26 | - "是" 27 | - "否" 28 | validations: 29 | required: true 30 | - type: dropdown 31 | id: input_id_3 32 | attributes: 33 | label: 框架文档是否提及了该问题【必答】 34 | description: 文档会提供最常见的问题解答,可以先看看是否有自己想要的 35 | multiple: false 36 | options: 37 | - "未选择" 38 | - "是" 39 | - "否" 40 | validations: 41 | required: true 42 | - type: dropdown 43 | id: input_id_4 44 | attributes: 45 | label: 是否已经查阅框架文档但还未能解决的【必答】 46 | description: 如果查阅了文档但还是没有解决的话,可以选择是 47 | multiple: false 48 | options: 49 | - "未选择" 50 | - "是" 51 | - "否" 52 | validations: 53 | required: true 54 | - type: textarea 55 | id: input_id_5 56 | attributes: 57 | label: 你觉得该怎么去完善会比较好?【非必答】 58 | description: 你可以提供一下自己的想法或者做法供作者参考 59 | validations: 60 | required: false -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply from : '../common.gradle' 3 | 4 | android { 5 | 6 | defaultConfig { 7 | applicationId "com.hjq.device.compat.demo" 8 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 9 | } 10 | 11 | // Apk 签名的那些事:https://www.jianshu.com/p/a1f8e5896aa2 12 | signingConfigs { 13 | config { 14 | storeFile file(StoreFile) 15 | storePassword StorePassword 16 | keyAlias KeyAlias 17 | keyPassword KeyPassword 18 | } 19 | } 20 | 21 | buildTypes { 22 | debug { 23 | minifyEnabled false 24 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 25 | signingConfig signingConfigs.config 26 | } 27 | 28 | release { 29 | minifyEnabled true 30 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 31 | signingConfig signingConfigs.config 32 | } 33 | } 34 | 35 | applicationVariants.configureEach { variant -> 36 | // apk 输出文件名配置 37 | variant.outputs.configureEach { output -> 38 | outputFileName = rootProject.getName() + '.apk' 39 | } 40 | } 41 | } 42 | 43 | dependencies { 44 | // 依赖 libs 目录下所有的 jar 和 aar 包 45 | implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs') 46 | 47 | implementation project(':library') 48 | 49 | implementation 'com.android.support:appcompat-v7:28.0.0' 50 | implementation 'com.android.support:design:28.0.0' 51 | 52 | // 标题栏框架:https://github.com/getActivity/TitleBar 53 | implementation 'com.github.getActivity:TitleBar:10.6' 54 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/issue_zh_template_question.yml: -------------------------------------------------------------------------------- 1 | name: 提出疑问 2 | description: 提出你的困惑,我会给你解答 3 | title: "[疑惑]:" 4 | labels: ["question"] 5 | 6 | body: 7 | - type: markdown 8 | attributes: 9 | value: | 10 | ## [【警告:请务必按照 issue 模板填写,不要抱有侥幸心理,一旦发现 issue 没有按照模板认真填写,一律直接关闭】](https://github.com/getActivity/IssueTemplateGuide) 11 | - type: textarea 12 | id: input_id_1 13 | attributes: 14 | label: 问题描述【必填】 15 | description: 请描述一下你的问题(注意:如果确定是框架 bug 请不要在这里提,否则一概不受理) 16 | validations: 17 | required: true 18 | - type: dropdown 19 | id: input_id_2 20 | attributes: 21 | label: 框架文档是否提及了该问题【必答】 22 | description: 文档会提供最常见的问题解答,可以先看看是否有自己想要的 23 | multiple: false 24 | options: 25 | - "未选择" 26 | - "是" 27 | - "否" 28 | validations: 29 | required: true 30 | - type: dropdown 31 | id: input_id_3 32 | attributes: 33 | label: 是否已经查阅框架文档但还未能解决的【必答】 34 | description: 如果查阅了文档但还是没有解决的话,可以选择是 35 | multiple: false 36 | options: 37 | - "未选择" 38 | - "是" 39 | - "否" 40 | validations: 41 | required: true 42 | - type: dropdown 43 | id: input_id_4 44 | attributes: 45 | label: issue 列表中是否有人曾提过类似的问题【必答】 46 | description: 可以在 issue 列表在搜索问题关键字,参考一下别人的解决方案 47 | multiple: false 48 | options: 49 | - "未选择" 50 | - "是" 51 | - "否" 52 | validations: 53 | required: true 54 | - type: dropdown 55 | id: input_id_5 56 | attributes: 57 | label: 是否已经搜索过了 issue 列表但还未能解决的【必答】 58 | description: 如果搜索过了 issue 列表但是问题没有解决的话,可以选择是 59 | multiple: false 60 | options: 61 | - "未选择" 62 | - "是" 63 | - "否" 64 | validations: 65 | required: true -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply from : '../common.gradle' 3 | 4 | android { 5 | 6 | resourcePrefix "demo_" 7 | 8 | // lintOptions { 9 | // // 忽略 lint 检查 10 | // ignoreWarnings = true 11 | // } 12 | 13 | lintOptions { 14 | abortOnError false // true by default 15 | checkAllWarnings false 16 | checkReleaseBuilds false 17 | ignoreWarnings true // false by default 18 | quiet true // false by default 19 | } 20 | 21 | android.libraryVariants.configureEach { variant -> 22 | // aar 输出文件名配置 23 | variant.outputs.all { output -> 24 | outputFileName = "${rootProject.name}-${android.defaultConfig.versionName}.aar" 25 | } 26 | } 27 | } 28 | 29 | dependencies { 30 | // noinspection GradleCompatible 31 | compileOnly 'com.android.support:support-annotations:24.2.0' 32 | } 33 | 34 | afterEvaluate { 35 | // 排除 BuildConfig.class 和 R.class 36 | generateReleaseBuildConfig.enabled = false 37 | generateDebugBuildConfig.enabled = false 38 | generateReleaseResValues.enabled = false 39 | generateDebugResValues.enabled = false 40 | } 41 | 42 | // 防止编码问题 43 | tasks.withType(Javadoc).configureEach { 44 | options.addStringOption('Xdoclint:none', '-quiet') 45 | options.addStringOption('encoding', 'UTF-8') 46 | options.addStringOption('charSet', 'UTF-8') 47 | } 48 | 49 | tasks.register('sourcesJar', Jar) { 50 | from android.sourceSets.main.java.srcDirs 51 | classifier = 'sources' 52 | } 53 | 54 | tasks.register('javadoc', Javadoc) { 55 | source = android.sourceSets.main.java.srcDirs 56 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 57 | } 58 | 59 | tasks.register('javadocJar', Jar) { 60 | dependsOn javadoc 61 | classifier = 'javadoc' 62 | from javadoc.destinationDir 63 | } 64 | 65 | artifacts { 66 | archives javadocJar 67 | archives sourcesJar 68 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/main_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 18 | 19 | 25 | 26 | 31 | 32 |