Skip to content

Deal with activity property ExcludeFromRecents, to avoid Mobile Legnends has two recent task problem #366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 7, 2018

Conversation

WindySha
Copy link

@WindySha WindySha commented Sep 6, 2018

Deal with activity property excludeFromRecents.
The app Mobile Legnends has two tasks in the recent task list, when launching from VituralXposed.

@tiann
Copy link
Member

tiann commented Sep 6, 2018

Good job.

顺便问下,这个可以通过 Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS 解决么?

@tiann
Copy link
Member

tiann commented Sep 6, 2018

比如说,在 ActivityStack里这么做:

    private Intent startActivityProcess(int userId, ActivityRecord sourceRecord, Intent intent, ActivityInfo info) {
        intent = new Intent(intent);
        ProcessRecord targetApp = mService.startProcessIfNeedLocked(info.processName, userId, info.packageName);
        if (targetApp == null) {
            return null;
        }
        Intent targetIntent = new Intent();
        targetIntent.setClassName(VirtualCore.get().getHostPkg(), fetchStubActivity(targetApp.vpid, info));
        ComponentName component = intent.getComponent();
        if (component == null) {
            component = ComponentUtils.toComponentName(info);
        }
        targetIntent.setType(component.flattenToString());
        StubActivityRecord saveInstance = new StubActivityRecord(intent, info,
                sourceRecord != null ? sourceRecord.component : null, userId);
        saveInstance.saveToIntent(targetIntent);

        if (((info.flags & ActivityInfo.FLAG_EXCLUDE_FROM_RECENTS) != 0)) {
            intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        }
        return targetIntent;
    }

@WindySha
Copy link
Author

WindySha commented Sep 6, 2018

之前就尝试过intent设置flag这种方法,并不可行,初次跳转到Mobile Legends的时候,最近任务只有一个任务,回到桌面再看任务栏,一个任务都没有了。
因此,需要使system_server进程中的PM去读取manifest中配置的EXCLUDE_FROM_RECENTS标签才能解决此问题。这种方法确实不是很优雅,但暂时没有找到其他解决方式。
通过这个问题,应该容易得知,VA框架对于manifest中配置的组件属性支持不是很好,此处应该会有不少坑。

@tiann tiann merged commit 895d3a3 into android-hacker:exposed Sep 7, 2018
tiann added a commit that referenced this pull request Nov 15, 2018
Deal with activity property ExcludeFromRecents, to avoid Mobile Legnends has two recent task problem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants