Android包中写入元信息安装 [英] Write meta information during Android package install

查看:198
本文介绍了Android包中写入元信息安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问:如何写在android源码包或在哪里安装意图, PackageManagerService 处理的元信息? (说明如下)。

Question: How to write meta information about a package OR Where is the installation intent handled in PackageManagerService in android source? (Description follows.)

我修改Android源在安装中节省约一个包中的一些元数据信息。它可以存储在任何位置,但必须由系统读取。我第一次尝试是使用 / SD卡(<一个href=\"http://stackoverflow.com/questions/15424603/android-source-error-reading-file-from-sdcard/15424662?noredirect=1\">Android源错误读取SD卡从文件),但是,这似乎并没有因为权限的工作。

I'm modifying Android source to save some meta information about a package during installation. It can be stored in any location but has to be readable by the system. My first attempt was to use /sdcard (Android source error reading file from sdcard) But that does not seem to work because of permissions.

现在,我希望能够发送元信息到 PackageManagerService ,以便它可以写之前安装。如果写它本身,它应该可以稍后阅读。

Now, I want to be able to send the meta information to the PackageManagerService so that it can write it before install. If it writes it itself, it should be able to read it later.

我已经确定的点 PackageInstallerActivity ,其中安装意图提高的地方:

I've identified the point in PackageInstallerActivity, the place where the installation intent is raised:

if(v == mOk) {
            // Start subactivity to actually install the application
            Intent newIntent = new Intent();
            newIntent.putExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO,
                    mPkgInfo.applicationInfo);
            newIntent.setData(mPackageURI);
            newIntent.setClass(this, InstallAppProgress.class);
            String installerPackageName = getIntent().getStringExtra(Intent.EXTRA_INSTALLER_PACKAGE_NAME);
            if (installerPackageName != null) {
                newIntent.putExtra(Intent.EXTRA_INSTALLER_PACKAGE_NAME, installerPackageName);
            }
            if(localLOGV) Log.i(TAG, "downloaded app uri="+mPackageURI);

我可以把一个额外的意图,但我不知道在哪里的PackageManagerService这个意图的处理。

I can put an "extra" in the intent but I don't know where in the PackageManagerService this intent is handled.

所以,qustion:在哪里安装在意向处理PackageManagerService在Android源?

So, the qustion: Where is the installation intent handled in PackageManagerService in android source?

推荐答案

正如你所见,其目的是与组件的明确意图。 InstallAppProgress.class

As you see, the intent is an explicit intent with a component: InstallAppProgress.class.

这样的意图将被InstallAppProgress优先处理。它也是在PackageInstaller一个组件。它负责显示安装进度(initView()的InstallAppProgress.java)。而在initView()方法,它将调用PackageManagerService:

So that intent will be handled first by InstallAppProgress. It is also a component in PackageInstaller. It is responsible for displaying the installation progress(initView() in InstallAppProgress.java). And in the initView() method, it will call PackageManagerService:

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Intent intent = getIntent();
    mAppInfo = intent.getParcelableExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO);
    mPackageURI = intent.getData();
    initView();
}

public void initView() {
    ...
    String installerPackageName = getIntent().getStringExtra(
            Intent.EXTRA_INSTALLER_PACKAGE_NAME);
    PackageInstallObserver observer = new PackageInstallObserver();
    pm.installPackage(mPackageURI, observer, installFlags, installerPackageName);
}

所以意图不是由PackageManagerService处理,它是由InstallAppProgress处理,然后将其简单地调用PackageManagerService安装该应用程序。

So the intent is not handled by PackageManagerService, it is handled by the InstallAppProgress, then it simply call PackageManagerService to install that app.

我曾经在一个局部的权限在Android系统的授权工作。我所做的是一个论点PMS添加到installPackage方法,所以我觉得你可以不喜欢它这一点。软件包管理系统是一个AIDL服务,所以你也需要修改AIDL文件了。它是在框架/基/核心/ JAVA /安卓/内容/ PM /

I used to working on a partial permission granting system on Android. What I did is to add an argument to installPackage method in PMS, so I think you can do it like that, too. PackageManager is an aidl service, so you also need to modify the aidl file too. It is under framework/base/core/java/android/content/pm/

这篇关于Android包中写入元信息安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆