为什么奇巧需要使用isValidFragment的?(Why does Kit Kat require the use of the isValidFragment?)

来源:互联网 发布:git webhook php 编辑:程序博客网 时间:2024/05/19 09:01
问 题

Ever since KitKat was released, I've noticed a whole bunch of my apps updating with "Fixing a crash in Kit Kat". Recently when I released my own app, I figured out the likely source of that is the new "isValidFragment" requirement for using preference activities. I haven't been able to get anyone, however, to explain why this new class is suddenly needed to validate fragments. Can anyone offer me an explanation of why this is required?

自从奇巧发布后,我发现了一大堆我的应用程序使用“修复崩溃奇巧”更新。最近,当我发布我自己的应用程序时,我想通了,我发现可能的来源是使用preference activities的新要求“isValidFragment”。然而没有人能给我解释为什么这个新类是突然需要验证片段。谁可以给我解释为什么需要这个?

解决方案

Subclasses should override this method and verify that the given fragment is a valid type to be attached to this activity. The default implementation returns true for apps built for android:targetSdkVersion older than KITKAT. For later versions, it will throw an exception.

子类应覆盖此方法,并验证给定的fragment是一个有效的类型附加到这个活动。对于targetSdkVersion在KITKAT之前的Android默认返回true。对于以后的版本,它会抛出异常。

A New Vulnerability in the Android Framework: Fragment Injection
We have recently disclosed a new vulnerability to the Android Security Team. The vulnerability affected many apps, including Settings (the one that is found on every Android device), Gmail, Google Now, DropBox and Evernote. To be more accurate, any App which extended the PreferenceActivity class using an exported activity was automatically vulnerable. A patch has been provided in Android KitKat. If you wondered why your code is now broken, it is due to the Android KitKat patch which requires applications to override the new method, PreferenceActivity.isValidFragment, which has been added to the Android Framework.

在Android框架的新漏洞:片段注入 
  我们最近披露的一个新漏洞到Android安全团队。这个安全漏洞影响到许多应用程序,包括设置(每个Android设备上都能找到),Gmail,Google Now,DropBox 和Evernote。为了更准确,任何使用exported activity扩展PreferenceActivity类的应用程序自动易受攻击。补丁已经在Android的奇巧被提供。如果你想知道为什么你的code现在已经坏了,这是由于Android 奇巧的补丁需要应用到覆盖新方法,preferenceActivity.isValidFragment,已加入到Android Framework

阅读全文
0 0
原创粉丝点击