Skip to content
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

collect configChanges attribute of Activity from AndroidManifest. #418

Merged
merged 1 commit into from
May 6, 2017

Conversation

iceboundrock
Copy link
Contributor

This change can make the activity handle configChanges setting correctly. Activities in plugin do not respect it's configChanges setting right now, because Small just ignore this attribute. So I add some code to read this setting from AndroidManifest and set it into ActivityInfo object.

This change can make the activity handle configChanges correctly
@galenlin
Copy link
Member

galenlin commented Feb 7, 2017

Well, though we can read the attribute and set it to PLUGIN ActivityInfo but it's too late.

The system process will read the ActivityInfo from our STUB activity and this can not be hook or simply reset.

@iceboundrock
Copy link
Contributor Author

Oh? but I just tested it, it seems working just fine on all my test devices.

@iceboundrock
Copy link
Contributor Author

我看了android的源码,我觉得在处理configChanges和screenOrientation 并没有本质区别啊,不知道您说的系统读取的地方在哪儿? 我看的是这个地方,http://androidxref.com/5.0.0_r2/xref/frameworks/base/core/java/android/content/pm/PackageParser.java#3092

@galenlin
Copy link
Member

galenlin commented May 6, 2017

@iceboundrock 系统进程只保留 宿主 manifest注册的 configChanges 属性 (com.android.server.am.ActivityRecord),在ActivityStack.ensureActivityConfigurationLocked 方法中会判断宿主的 configChanges 属性是否注册了相应changes,如果没有的话,会 重启 当前 Activity 。而这个重启过程显然是跟我们预想所违背的。

这个过程在系统进程执行,所以即使我们记录了插件的 configChanges 属性,也只是在我们的应用进程里 (android.app.ActivityThread$ActivityClientRecord)。

进一步改进

在观察 InstantAppAndroidManifest.xml 时, 发现其预埋了所有的 configChanges,这样可以避免 重启,同时我相信在 mH 里有机会拦截到 ACTIVITY_CONFIGURATION_CHANGED 事件,这个时候在我们的进程里,我们可以依据记录的 configChanges 属性作进一步处理。

因此,我将先 Merge 你这个 PR,再进行下一步处理。

@galenlin galenlin merged commit b8fc12d into wequick:master May 6, 2017
galenlin added a commit that referenced this pull request May 7, 2017
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