private void applyFlagsToComponentInfo ( ComponentInfo componentInfo , int flags ) throws NameNotFoundException { componentInfo . name = ( componentInfo . name == null ) ? "" : componentInfo . name ; ApplicationInfo applicationInfo = componentInfo . applicationInfo ; boolean isApplicationEnabled = true ; if ( applicationInfo != null ) { if ( applicationInfo . packageName == null ) { applicationInfo . packageName = componentInfo . packageName ; } applyFlagsToApplicationInfo ( componentInfo . applicationInfo , flags ) ; componentInfo . packageName = applicationInfo . packageName ; isApplicationEnabled = applicationInfo . enabled ; } if ( ( flags & GET_META_DATA ) == 0 ) { componentInfo . metaData = null ; } boolean isComponentEnabled = isComponentEnabled ( componentInfo ) ; if ( ( flags & MATCH_ALL ) != 0 && Build . VERSION . SDK_INT >= 23 ) { return ; } // Android don't override the enabled field of component with the actual value. boolean isEnabledForFiltering = isComponentEnabled && ( Build . VERSION . SDK_INT >= 24 ? isApplicationEnabled : true ) ; if ( ( flags & MATCH_DISABLED_COMPONENTS ) == 0 && ! isEnabledForFiltering ) { throw new NameNotFoundException ( "Disabled component: " + componentInfo ) ; } if ( isFlagSet ( flags , PackageManager . MATCH_SYSTEM_ONLY ) ) { if ( applicationInfo == null ) { // TODO: for backwards compatibility just skip filtering. In future should just remove // invalid resolve infos from list } else { final int applicationFlags = applicationInfo . flags ; if ( ( applicationFlags & ApplicationInfo . FLAG_SYSTEM ) != ApplicationInfo . FLAG_SYSTEM ) { throw new NameNotFoundException ( "Not system component: " + componentInfo ) ; } } } if ( ! isFlagSet ( flags , MATCH_UNINSTALLED_PACKAGES ) && isValidComponentInfo ( componentInfo ) && hiddenPackages . contains ( componentInfo . applicationInfo . packageName ) ) { throw new NameNotFoundException ( "Uninstalled package: " + componentInfo ) ; } }
Modifies the component in place using .