对isEphemeralDisabled进行PackageManager检查会导致Android 7.1出现死锁

时间:2017-07-26 03:30:01

标签: android android-package-managers android-7.1-nougat android-instant-apps

private boolean isEphemeralAllowed(
        Intent intent, List<ResolveInfo> resolvedActivities, int userId,
        boolean skipPackageCheck) {

    // Short circuit and return early if possible.
    if (isEphemeralDisabled()) {
        return false;
    }
    final int callingUser = UserHandle.getCallingUserId();
    if (callingUser != UserHandle.USER_SYSTEM) {
        return false;
    }
    if (mEphemeralResolverConnection == null) {
        return false;
    }
    if (intent.getComponent() != null) {
        return false;
    }
    if ((intent.getFlags() & Intent.FLAG_IGNORE_EPHEMERAL) != 0) {
        return false;
    }
    if (!skipPackageCheck && intent.getPackage() != null) {
        return false;
    }
    final boolean isWebUri = hasWebURI(intent);



private boolean isEphemeralDisabled() {
    // ephemeral apps have been disabled across the board
    if (DISABLE_EPHEMERAL_APPS) {
        return true;
    }
    // system isn't up yet; can't read settings, so, assume no ephemeral apps
    if (!mSystemReady) {
        return true;
    }

    // we can't get a content resolver until the system is ready; these checks must happen last
    final ContentResolver resolver = mContext.getContentResolver();
    if (Global.getInt(resolver, Global.ENABLE_EPHEMERAL_FEATURE, 1) == 0) {
        return true;
    }
    return Secure.getInt(resolver, Secure.WEB_ACTION_ENABLED, 1) == 0;

}

对于Android 7.0,DISABLE_EPHEMERAL_APPS默认为true

private static final boolean DISABLE_EPHEMERAL_APPS = true;

但在Android 7.1中,Google启用了即时应用支持:https://android.googlesource.com/platform/frameworks/base.git/+/7ef97b6624054fff0d712d85336a45eee70bcc3f%5E%21/#F0

对于isEphemeralAllowed方法,如果调用resolveIntent,大多数意图将调用isEphemeralAllowed方法,因此这将导致PackageManager服务用户绑定器调用settingProvider,并且可能导致死锁。< / p>

0 个答案:

没有答案