Giter Club home page Giter Club logo

aosp-android-jar's Introduction

aosp-android-jar

jar包使用方法:

替换 ${Android Sdk}/platforms/andorid-api/ 下的android.jar,之后sync一下。

针对非 SDK 接口的限制说明

有以下情况需要说明一下:

  • 能调用到不代表可以调用,例如黑名单api还是会受到上面限制

  • 如果你是系统应用,或者有root权限可以无视以上限制

  • Android.jar的接口和当前AOSP接口保持一致,但是部分类会做修改,修改是添加旧系统接口,修改会添加在对应Jar包目录说明中,需要简短适配,例如:

 final IPackageInstaller iPackageInstaller = AppGlobals.getPackageManager().getPackageInstaller();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
                packageInstaller = new PackageInstaller(iPackageInstaller, null, null, UserHandle.myUserId());
            } else {
                packageInstaller = new PackageInstaller(iPackageInstaller, null, UserHandle.myUserId());
            }
  • 部分新版sdk接口的返回值可能和旧版sdk接口不同,那么如果不接收返回值,则可能导致编译正常运行报错,这种情况需要判断使用反射形式调用,例如:
//此方法在api29和28之前返回值不同
lockPatternUtils.saveLockPassword(it, null, DevicePolicyManager.PASSWORD_QUALITY_COMPLEX, UserHandle.myUserId())

使用这种方式有什么好处:

  • 有调用提示,方法列表可以点出来

  • 减少适配成本,版本更新之后,不适配的方法会直接以错误的形式体现出来,不会如反射一样直接编译通过而运行时报错

  • 无意中会学会更多知识,列出方法列表会更加接近源码,偶尔留下的印象也许会在某天突然融会贯通

License

MIT License

Copyright (c) 2020 鼎鼎鼎

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


aosp-android-jar's People

Contributors

reginer avatar

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.