android使用@hide标签的api

android源码中有些api加了@hide标签.这些api在sdk下是无法使用的.

如果我们有整个源码环境,可以打破这个限制.


1.重编sdk

直接envsetup,然后make PRODUCT-sdk-sdk ,编译一个新的sdk出来,android.jar这个文件替换掉sdk里的android.jar

2.重编framework架包

这种原理也是编一个架包出来,在configure build path中加入这个架包即可.


以pm中的installpackage举例

 /**
     * @hide
     *
     * Install a package. Since this may take a little while, the result will
     * be posted back to the given observer.  An installation will fail if the calling context
     * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
     * package named in the package file's manifest is already installed, or if there's no space
     * available on the device.
     *
     * @param packageURI The location of the package file to install.  This can be a 'file:' or a
     * 'content:' URI.
     * @param observer An observer callback to get notified when the package installation is
     * complete. {@link IPackageInstallObserver#packageInstalled(String, int)} will be
     * called when that happens.  observer may be null to indicate that no callback is desired.
     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
     * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
     * @param installerPackageName Optional package name of the application that is performing the
     * installation. This identifies which market the package came from.
     */
    public abstract void installPackage(
            Uri packageURI, IPackageInstallObserver observer, int flags,
            String installerPackageName);
首先去掉@hide标签

然后在android根目录make framework或者在framework目录下mm启动framework编译,拷贝linux编译生成的out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar到本机.在buildpath加上这个架包.

第三个就是我自己编译的framework架包,记得调整一下顺序,尽量保证我们自己编译的framework在上方.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值