Program: 190991
Project: 190991
Buggy source:
public PackageManagerService(Context context,Installer installer,boolean factoryTest,boolean onlyCore){
  EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_START,SystemClock.uptimeMillis());
  if (mSdkVersion <= 0) {
    Slog.w(TAG,"String_Node_Str");
  }
  mContext=context;
  mFactoryTest=factoryTest;
  mOnlyCore=onlyCore;
  mMetrics=new DisplayMetrics();
  mSettings=new Settings(mPackages);
  mSettings.addSharedUserLPw("String_Node_Str",Process.SYSTEM_UID,ApplicationInfo.FLAG_SYSTEM,ApplicationInfo.PRIVATE_FLAG_PRIVILEGED);
  mSettings.addSharedUserLPw("String_Node_Str",RADIO_UID,ApplicationInfo.FLAG_SYSTEM,ApplicationInfo.PRIVATE_FLAG_PRIVILEGED);
  mSettings.addSharedUserLPw("String_Node_Str",LOG_UID,ApplicationInfo.FLAG_SYSTEM,ApplicationInfo.PRIVATE_FLAG_PRIVILEGED);
  mSettings.addSharedUserLPw("String_Node_Str",NFC_UID,ApplicationInfo.FLAG_SYSTEM,ApplicationInfo.PRIVATE_FLAG_PRIVILEGED);
  mSettings.addSharedUserLPw("String_Node_Str",BLUETOOTH_UID,ApplicationInfo.FLAG_SYSTEM,ApplicationInfo.PRIVATE_FLAG_PRIVILEGED);
  mSettings.addSharedUserLPw("String_Node_Str",SHELL_UID,ApplicationInfo.FLAG_SYSTEM,ApplicationInfo.PRIVATE_FLAG_PRIVILEGED);
  String separateProcesses=SystemProperties.get("String_Node_Str");
  if (separateProcesses != null && separateProcesses.length() > 0) {
    if ("String_Node_Str".equals(separateProcesses)) {
      mDefParseFlags=PackageParser.PARSE_IGNORE_PROCESSES;
      mSeparateProcesses=null;
      Slog.w(TAG,"String_Node_Str");
    }
 else {
      mDefParseFlags=0;
      mSeparateProcesses=separateProcesses.split("String_Node_Str");
      Slog.w(TAG,"String_Node_Str" + separateProcesses);
    }
  }
 else {
    mDefParseFlags=0;
    mSeparateProcesses=null;
  }
  mInstaller=installer;
  mPackageDexOptimizer=new PackageDexOptimizer(installer,mInstallLock,context,"String_Node_Str");
  mMoveCallbacks=new MoveCallbacks(FgThread.get().getLooper());
  mOnPermissionChangeListeners=new OnPermissionChangeListeners(FgThread.get().getLooper());
  getDefaultDisplayMetrics(context,mMetrics);
  SystemConfig systemConfig=SystemConfig.getInstance();
  mGlobalGids=systemConfig.getGlobalGids();
  mSystemPermissions=systemConfig.getSystemPermissions();
  mAvailableFeatures=systemConfig.getAvailableFeatures();
  mProtectedPackages=new ProtectedPackages(mContext);
synchronized (mInstallLock) {
synchronized (mPackages) {
      mHandlerThread=new ServiceThread(TAG,Process.THREAD_PRIORITY_BACKGROUND,true);
      mHandlerThread.start();
      mHandler=new PackageHandler(mHandlerThread.getLooper());
      mProcessLoggingHandler=new ProcessLoggingHandler();
      Watchdog.getInstance().addThread(mHandler,WATCHDOG_TIMEOUT);
      mDefaultPermissionPolicy=new DefaultPermissionGrantPolicy(this);
      File dataDir=Environment.getDataDirectory();
      mAppInstallDir=new File(dataDir,"String_Node_Str");
      mAppLib32InstallDir=new File(dataDir,"String_Node_Str");
      mEphemeralInstallDir=new File(dataDir,"String_Node_Str");
      mAsecInternalPath=new File(dataDir,"String_Node_Str").getPath();
      mDrmAppPrivateInstallDir=new File(dataDir,"String_Node_Str");
      sUserManager=new UserManagerService(context,this,mPackages);
      ArrayMap<String,SystemConfig.PermissionEntry> permConfig=systemConfig.getPermissions();
      for (int i=0; i < permConfig.size(); i++) {
        SystemConfig.PermissionEntry perm=permConfig.valueAt(i);
        BasePermission bp=mSettings.mPermissions.get(perm.name);
        if (bp == null) {
          bp=new BasePermission(perm.name,"String_Node_Str",BasePermission.TYPE_BUILTIN);
          mSettings.mPermissions.put(perm.name,bp);
        }
        if (perm.gids != null) {
          bp.setGids(perm.gids,perm.perUser);
        }
      }
      ArrayMap<String,String> libConfig=systemConfig.getSharedLibraries();
      for (int i=0; i < libConfig.size(); i++) {
        mSharedLibraries.put(libConfig.keyAt(i),new SharedLibraryEntry(libConfig.valueAt(i),null));
      }
      mFoundPolicyFile=SELinuxMMAC.readInstallPolicy();
      mFirstBoot=!mSettings.readLPw(sUserManager.getUsers(false));
      if (mFirstBoot) {
        requestCopyPreoptedFiles();
      }
      String customResolverActivity=Resources.getSystem().getString(R.string.config_customResolverActivity);
      if (TextUtils.isEmpty(customResolverActivity)) {
        customResolverActivity=null;
      }
 else {
        mCustomResolverComponentName=ComponentName.unflattenFromString(customResolverActivity);
      }
      long startTime=SystemClock.uptimeMillis();
      EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_SYSTEM_SCAN_START,startTime);
      final int scanFlags=SCAN_NO_PATHS | SCAN_DEFER_DEX | SCAN_BOOTING| SCAN_INITIAL;
      final String bootClassPath=System.getenv("String_Node_Str");
      final String systemServerClassPath=System.getenv("String_Node_Str");
      if (bootClassPath == null) {
        Slog.w(TAG,"String_Node_Str");
      }
      if (systemServerClassPath == null) {
        Slog.w(TAG,"String_Node_Str");
      }
      final List<String> allInstructionSets=InstructionSets.getAllInstructionSets();
      final String[] dexCodeInstructionSets=getDexCodeInstructionSets(allInstructionSets.toArray(new String[allInstructionSets.size()]));
      if (mSharedLibraries.size() > 0) {
        for (        String dexCodeInstructionSet : dexCodeInstructionSets) {
          for (          SharedLibraryEntry libEntry : mSharedLibraries.values()) {
            final String lib=libEntry.path;
            if (lib == null) {
              continue;
            }
            try {
              int dexoptNeeded=DexFile.getDexOptNeeded(lib,dexCodeInstructionSet,getCompilerFilterForReason(REASON_SHARED_APK),false);
              if (dexoptNeeded != DexFile.NO_DEXOPT_NEEDED) {
                mInstaller.dexopt(lib,Process.SYSTEM_UID,dexCodeInstructionSet,dexoptNeeded,DEXOPT_PUBLIC,getCompilerFilterForReason(REASON_SHARED_APK),StorageManager.UUID_PRIVATE_INTERNAL,SKIP_SHARED_LIBRARY_CHECK);
              }
            }
 catch (            FileNotFoundException e) {
              Slog.w(TAG,"String_Node_Str" + lib);
            }
catch (            IOException|InstallerException e) {
              Slog.w(TAG,"String_Node_Str" + lib + "String_Node_Str"+ e.getMessage());
            }
          }
        }
      }
      File frameworkDir=new File(Environment.getRootDirectory(),"String_Node_Str");
      final VersionInfo ver=mSettings.getInternalVersion();
      mIsUpgrade=!Build.FINGERPRINT.equals(ver.fingerprint);
      mPromoteSystemApps=mIsUpgrade && ver.sdkVersion <= Build.VERSION_CODES.LOLLIPOP_MR1;
      mIsPreNUpgrade=mIsUpgrade && ver.sdkVersion < Build.VERSION_CODES.N;
      mIsPreNMR1Upgrade=mIsUpgrade && ver.sdkVersion < Build.VERSION_CODES.N_MR1;
      if (mPromoteSystemApps) {
        Iterator<PackageSetting> pkgSettingIter=mSettings.mPackages.values().iterator();
        while (pkgSettingIter.hasNext()) {
          PackageSetting ps=pkgSettingIter.next();
          if (isSystemApp(ps)) {
            mExistingSystemPackages.add(ps.name);
          }
        }
      }
      File vendorOverlayDir=new File(VENDOR_OVERLAY_DIR);
      scanDirTracedLI(vendorOverlayDir,mDefParseFlags | PackageParser.PARSE_IS_SYSTEM | PackageParser.PARSE_IS_SYSTEM_DIR| PackageParser.PARSE_TRUSTED_OVERLAY,scanFlags | SCAN_TRUSTED_OVERLAY,0);
      scanDirTracedLI(frameworkDir,mDefParseFlags | PackageParser.PARSE_IS_SYSTEM | PackageParser.PARSE_IS_SYSTEM_DIR| PackageParser.PARSE_IS_PRIVILEGED,scanFlags | SCAN_NO_DEX,0);
      final File privilegedAppDir=new File(Environment.getRootDirectory(),"String_Node_Str");
      scanDirTracedLI(privilegedAppDir,mDefParseFlags | PackageParser.PARSE_IS_SYSTEM | PackageParser.PARSE_IS_SYSTEM_DIR| PackageParser.PARSE_IS_PRIVILEGED,scanFlags,0);
      final File systemAppDir=new File(Environment.getRootDirectory(),"String_Node_Str");
      scanDirTracedLI(systemAppDir,mDefParseFlags | PackageParser.PARSE_IS_SYSTEM | PackageParser.PARSE_IS_SYSTEM_DIR,scanFlags,0);
      File vendorAppDir=new File("String_Node_Str");
      try {
        vendorAppDir=vendorAppDir.getCanonicalFile();
      }
 catch (      IOException e) {
      }
      scanDirTracedLI(vendorAppDir,mDefParseFlags | PackageParser.PARSE_IS_SYSTEM | PackageParser.PARSE_IS_SYSTEM_DIR,scanFlags,0);
      final File oemAppDir=new File(Environment.getOemDirectory(),"String_Node_Str");
      scanDirTracedLI(oemAppDir,mDefParseFlags | PackageParser.PARSE_IS_SYSTEM | PackageParser.PARSE_IS_SYSTEM_DIR,scanFlags,0);
      final List<String> possiblyDeletedUpdatedSystemApps=new ArrayList<String>();
      if (!mOnlyCore) {
        Iterator<PackageSetting> psit=mSettings.mPackages.values().iterator();
        while (psit.hasNext()) {
          PackageSetting ps=psit.next();
          if ((ps.pkgFlags & ApplicationInfo.FLAG_SYSTEM) == 0) {
            continue;
          }
          final PackageParser.Package scannedPkg=mPackages.get(ps.name);
          if (scannedPkg != null) {
            if (mSettings.isDisabledSystemPackageLPr(ps.name)) {
              logCriticalInfo(Log.WARN,"String_Node_Str" + ps.name + "String_Node_Str"+ ps.codePathString+ "String_Node_Str"+ ps.installStatus+ "String_Node_Str"+ ps.versionCode+ "String_Node_Str"+ scannedPkg.mVersionCode);
              removePackageLI(scannedPkg,true);
              mExpectingBetter.put(ps.name,ps.codePath);
            }
            continue;
          }
          if (!mSettings.isDisabledSystemPackageLPr(ps.name)) {
            psit.remove();
            logCriticalInfo(Log.WARN,"String_Node_Str" + ps.name + "String_Node_Str");
          }
 else {
            final PackageSetting disabledPs=mSettings.getDisabledSystemPkgLPr(ps.name);
            if (disabledPs.codePath == null || !disabledPs.codePath.exists()) {
              possiblyDeletedUpdatedSystemApps.add(ps.name);
            }
          }
        }
      }
      ArrayList<PackageSetting> deletePkgsList=mSettings.getListOfIncompleteInstallPackagesLPr();
      for (int i=0; i < deletePkgsList.size(); i++) {
        final String packageName=deletePkgsList.get(i).name;
        logCriticalInfo(Log.WARN,"String_Node_Str" + packageName);
synchronized (mPackages) {
          mSettings.removePackageLPw(packageName);
        }
      }
      deleteTempPackageFiles();
      mSettings.pruneSharedUsersLPw();
      if (!mOnlyCore) {
        EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_DATA_SCAN_START,SystemClock.uptimeMillis());
        scanDirTracedLI(mAppInstallDir,0,scanFlags | SCAN_REQUIRE_KNOWN,0);
        scanDirTracedLI(mDrmAppPrivateInstallDir,mDefParseFlags | PackageParser.PARSE_FORWARD_LOCK,scanFlags | SCAN_REQUIRE_KNOWN,0);
        scanDirLI(mEphemeralInstallDir,mDefParseFlags | PackageParser.PARSE_IS_EPHEMERAL,scanFlags | SCAN_REQUIRE_KNOWN,0);
        for (        String deletedAppName : possiblyDeletedUpdatedSystemApps) {
          PackageParser.Package deletedPkg=mPackages.get(deletedAppName);
          mSettings.removeDisabledSystemPackageLPw(deletedAppName);
          String msg;
          if (deletedPkg == null) {
            msg="String_Node_Str" + deletedAppName + "String_Node_Str";
          }
 else {
            msg="String_Node_Str" + deletedAppName + "String_Node_Str"+ deletedAppName;
            deletedPkg.applicationInfo.flags&=~ApplicationInfo.FLAG_SYSTEM;
            PackageSetting deletedPs=mSettings.mPackages.get(deletedAppName);
            deletedPs.pkgFlags&=~ApplicationInfo.FLAG_SYSTEM;
          }
          logCriticalInfo(Log.WARN,msg);
        }
        for (int i=0; i < mExpectingBetter.size(); i++) {
          final String packageName=mExpectingBetter.keyAt(i);
          if (!mPackages.containsKey(packageName)) {
            final File scanFile=mExpectingBetter.valueAt(i);
            logCriticalInfo(Log.WARN,"String_Node_Str" + packageName + "String_Node_Str");
            int reparseFlags=mDefParseFlags;
            if (FileUtils.contains(privilegedAppDir,scanFile)) {
              reparseFlags=PackageParser.PARSE_IS_SYSTEM | PackageParser.PARSE_IS_SYSTEM_DIR | PackageParser.PARSE_IS_PRIVILEGED;
            }
 else             if (FileUtils.contains(systemAppDir,scanFile)) {
              reparseFlags=PackageParser.PARSE_IS_SYSTEM | PackageParser.PARSE_IS_SYSTEM_DIR;
            }
 else             if (FileUtils.contains(vendorAppDir,scanFile)) {
              reparseFlags=PackageParser.PARSE_IS_SYSTEM | PackageParser.PARSE_IS_SYSTEM_DIR;
            }
 else             if (FileUtils.contains(oemAppDir,scanFile)) {
              reparseFlags=PackageParser.PARSE_IS_SYSTEM | PackageParser.PARSE_IS_SYSTEM_DIR;
            }
 else {
              Slog.e(TAG,"String_Node_Str" + scanFile);
              continue;
            }
            mSettings.enableSystemPackageLPw(packageName);
            try {
              scanPackageTracedLI(scanFile,reparseFlags,scanFlags,0,null);
            }
 catch (            PackageManagerException e) {
              Slog.e(TAG,"String_Node_Str" + e.getMessage());
            }
          }
        }
      }
      mExpectingBetter.clear();
      mSetupWizardPackage=getSetupWizardPackageName();
      if (mProtectedFilters.size() > 0) {
        if (DEBUG_FILTERS && mSetupWizardPackage == null) {
          Slog.i(TAG,"String_Node_Str" + "String_Node_Str");
        }
        for (        ActivityIntentInfo filter : mProtectedFilters) {
          if (filter.activity.info.packageName.equals(mSetupWizardPackage)) {
            if (DEBUG_FILTERS) {
              Slog.i(TAG,"String_Node_Str" + "String_Node_Str" + filter.getPriority() + "String_Node_Str"+ "String_Node_Str"+ filter.activity.info.packageName+ "String_Node_Str"+ filter.activity.className+ "String_Node_Str"+ filter.getPriority());
            }
            continue;
          }
          Slog.w(TAG,"String_Node_Str" + "String_Node_Str" + filter.activity.info.packageName + "String_Node_Str"+ filter.activity.className+ "String_Node_Str"+ filter.getPriority());
          filter.setPriority(0);
        }
      }
      mDeferProtectedFilters=false;
      mProtectedFilters.clear();
      updateAllSharedLibrariesLPw();
      for (      SharedUserSetting setting : mSettings.getAllSharedUsersLPw()) {
        adjustCpuAbisForSharedUserLPw(setting.packages,null,false);
      }
      mPackageUsage.read(mPackages);
      mCompilerStats.read();
      EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_SCAN_END,SystemClock.uptimeMillis());
      Slog.i(TAG,"String_Node_Str" + ((SystemClock.uptimeMillis() - startTime) / 1000f) + "String_Node_Str");
      int updateFlags=UPDATE_PERMISSIONS_ALL;
      if (ver.sdkVersion != mSdkVersion) {
        Slog.i(TAG,"String_Node_Str" + ver.sdkVersion + "String_Node_Str"+ mSdkVersion+ "String_Node_Str");
        updateFlags|=UPDATE_PERMISSIONS_REPLACE_PKG | UPDATE_PERMISSIONS_REPLACE_ALL;
      }
      updatePermissionsLPw(null,null,StorageManager.UUID_PRIVATE_INTERNAL,updateFlags);
      ver.sdkVersion=mSdkVersion;
      if (!onlyCore && (mPromoteSystemApps || mFirstBoot)) {
        for (        UserInfo user : sUserManager.getUsers(true)) {
          mSettings.applyDefaultPreferredAppsLPw(this,user.id);
          applyFactoryDefaultBrowserLPw(user.id);
          primeDomainVerificationsLPw(user.id);
        }
      }
      final int storageFlags;
      if (StorageManager.isFileEncryptedNativeOrEmulated()) {
        storageFlags=StorageManager.FLAG_STORAGE_DE;
      }
 else {
        storageFlags=StorageManager.FLAG_STORAGE_DE | StorageManager.FLAG_STORAGE_CE;
      }
      reconcileAppsDataLI(StorageManager.UUID_PRIVATE_INTERNAL,UserHandle.USER_SYSTEM,storageFlags);
      if (mIsUpgrade && !onlyCore) {
        Slog.i(TAG,"String_Node_Str");
        for (int i=0; i < mSettings.mPackages.size(); i++) {
          final PackageSetting ps=mSettings.mPackages.valueAt(i);
          if (Objects.equals(StorageManager.UUID_PRIVATE_INTERNAL,ps.volumeUuid)) {
            clearAppDataLIF(ps.pkg,UserHandle.USER_ALL,StorageManager.FLAG_STORAGE_DE | StorageManager.FLAG_STORAGE_CE | Installer.FLAG_CLEAR_CODE_CACHE_ONLY);
          }
        }
        ver.fingerprint=Build.FINGERPRINT;
      }
      checkDefaultBrowser();
      mExistingSystemPackages.clear();
      mPromoteSystemApps=false;
      ver.databaseVersion=Settings.CURRENT_DATABASE_VERSION;
      mSettings.writeLPr();
      if ((isFirstBoot() || isUpgrade() || VMRuntime.didPruneDalvikCache()) && !onlyCore) {
        long start=System.nanoTime();
        List<PackageParser.Package> coreApps=new ArrayList<>();
        for (        PackageParser.Package pkg : mPackages.values()) {
          if (pkg.coreApp) {
            coreApps.add(pkg);
          }
        }
        int[] stats=performDexOptUpgrade(coreApps,false,getCompilerFilterForReason(REASON_CORE_APP));
        final int elapsedTimeSeconds=(int)TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - start);
        MetricsLogger.histogram(mContext,"String_Node_Str",elapsedTimeSeconds);
        if (DEBUG_DEXOPT) {
          Slog.i(TAG,"String_Node_Str" + elapsedTimeSeconds + "String_Node_Str"+ stats[0]+ "String_Node_Str"+ stats[1]+ "String_Node_Str"+ stats[2]+ "String_Node_Str");
        }
      }
      EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_READY,SystemClock.uptimeMillis());
      if (!mOnlyCore) {
        mRequiredVerifierPackage=getRequiredButNotReallyRequiredVerifierLPr();
        mRequiredInstallerPackage=getRequiredInstallerLPr();
        mRequiredUninstallerPackage=getRequiredUninstallerLPr();
        mIntentFilterVerifierComponent=getIntentFilterVerifierComponentNameLPr();
        mIntentFilterVerifier=new IntentVerifierProxy(mContext,mIntentFilterVerifierComponent);
        mServicesSystemSharedLibraryPackageName=getRequiredSharedLibraryLPr(PackageManager.SYSTEM_SHARED_LIBRARY_SERVICES);
        mSharedSystemSharedLibraryPackageName=getRequiredSharedLibraryLPr(PackageManager.SYSTEM_SHARED_LIBRARY_SHARED);
      }
 else {
        mRequiredVerifierPackage=null;
        mRequiredInstallerPackage=null;
        mRequiredUninstallerPackage=null;
        mIntentFilterVerifierComponent=null;
        mIntentFilterVerifier=null;
        mServicesSystemSharedLibraryPackageName=null;
        mSharedSystemSharedLibraryPackageName=null;
      }
      mInstallerService=new PackageInstallerService(context,this);
      final ComponentName ephemeralResolverComponent=getEphemeralResolverLPr();
      final ComponentName ephemeralInstallerComponent=getEphemeralInstallerLPr();
      if (ephemeralInstallerComponent != null && ephemeralResolverComponent != null) {
        if (DEBUG_EPHEMERAL) {
          Slog.i(TAG,"String_Node_Str" + ephemeralResolverComponent + "String_Node_Str"+ ephemeralInstallerComponent);
        }
        mEphemeralResolverComponent=ephemeralResolverComponent;
        mEphemeralInstallerComponent=ephemeralInstallerComponent;
        setUpEphemeralInstallerActivityLP(mEphemeralInstallerComponent);
        mEphemeralResolverConnection=new EphemeralResolverConnection(mContext,mEphemeralResolverComponent);
      }
 else {
        if (DEBUG_EPHEMERAL) {
          final String missingComponent=(ephemeralResolverComponent == null) ? (ephemeralInstallerComponent == null) ? "String_Node_Str" : "String_Node_Str" : "String_Node_Str";
          Slog.i(TAG,"String_Node_Str" + missingComponent);
        }
        mEphemeralResolverComponent=null;
        mEphemeralInstallerComponent=null;
        mEphemeralResolverConnection=null;
      }
      mEphemeralApplicationRegistry=new EphemeralApplicationRegistry(this);
    }
  }
  Runtime.getRuntime().gc();
  mInstaller.setWarnIfHeld(mPackages);
  LocalServices.addService(PackageManagerInternal.class,new PackageManagerInternalImpl());
}

Fixed version (ground truth):
public PackageManagerService(Context context,Installer installer,boolean factoryTest,boolean onlyCore){
  EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_START,SystemClock.uptimeMillis());
  if (mSdkVersion <= 0) {
    Slog.w(TAG,"String_Node_Str");
  }
  mContext=context;
  mFactoryTest=factoryTest;
  mOnlyCore=onlyCore;
  mMetrics=new DisplayMetrics();
  mSettings=new Settings(mPackages);
  mSettings.addSharedUserLPw("String_Node_Str",Process.SYSTEM_UID,ApplicationInfo.FLAG_SYSTEM,ApplicationInfo.PRIVATE_FLAG_PRIVILEGED);
  mSettings.addSharedUserLPw("String_Node_Str",RADIO_UID,ApplicationInfo.FLAG_SYSTEM,ApplicationInfo.PRIVATE_FLAG_PRIVILEGED);
  mSettings.addSharedUserLPw("String_Node_Str",LOG_UID,ApplicationInfo.FLAG_SYSTEM,ApplicationInfo.PRIVATE_FLAG_PRIVILEGED);
  mSettings.addSharedUserLPw("String_Node_Str",NFC_UID,ApplicationInfo.FLAG_SYSTEM,ApplicationInfo.PRIVATE_FLAG_PRIVILEGED);
  mSettings.addSharedUserLPw("String_Node_Str",BLUETOOTH_UID,ApplicationInfo.FLAG_SYSTEM,ApplicationInfo.PRIVATE_FLAG_PRIVILEGED);
  mSettings.addSharedUserLPw("String_Node_Str",SHELL_UID,ApplicationInfo.FLAG_SYSTEM,ApplicationInfo.PRIVATE_FLAG_PRIVILEGED);
  String separateProcesses=SystemProperties.get("String_Node_Str");
  if (separateProcesses != null && separateProcesses.length() > 0) {
    if ("String_Node_Str".equals(separateProcesses)) {
      mDefParseFlags=PackageParser.PARSE_IGNORE_PROCESSES;
      mSeparateProcesses=null;
      Slog.w(TAG,"String_Node_Str");
    }
 else {
      mDefParseFlags=0;
      mSeparateProcesses=separateProcesses.split("String_Node_Str");
      Slog.w(TAG,"String_Node_Str" + separateProcesses);
    }
  }
 else {
    mDefParseFlags=0;
    mSeparateProcesses=null;
  }
  mInstaller=installer;
  mPackageDexOptimizer=new PackageDexOptimizer(installer,mInstallLock,context,"String_Node_Str");
  mMoveCallbacks=new MoveCallbacks(FgThread.get().getLooper());
  mOnPermissionChangeListeners=new OnPermissionChangeListeners(FgThread.get().getLooper());
  getDefaultDisplayMetrics(context,mMetrics);
  SystemConfig systemConfig=SystemConfig.getInstance();
  mGlobalGids=systemConfig.getGlobalGids();
  mSystemPermissions=systemConfig.getSystemPermissions();
  mAvailableFeatures=systemConfig.getAvailableFeatures();
  mProtectedPackages=new ProtectedPackages(mContext);
synchronized (mInstallLock) {
synchronized (mPackages) {
      mHandlerThread=new ServiceThread(TAG,Process.THREAD_PRIORITY_BACKGROUND,true);
      mHandlerThread.start();
      mHandler=new PackageHandler(mHandlerThread.getLooper());
      mProcessLoggingHandler=new ProcessLoggingHandler();
      Watchdog.getInstance().addThread(mHandler,WATCHDOG_TIMEOUT);
      mDefaultPermissionPolicy=new DefaultPermissionGrantPolicy(this);
      File dataDir=Environment.getDataDirectory();
      mAppInstallDir=new File(dataDir,"String_Node_Str");
      mAppLib32InstallDir=new File(dataDir,"String_Node_Str");
      mEphemeralInstallDir=new File(dataDir,"String_Node_Str");
      mAsecInternalPath=new File(dataDir,"String_Node_Str").getPath();
      mDrmAppPrivateInstallDir=new File(dataDir,"String_Node_Str");
      sUserManager=new UserManagerService(context,this,mPackages);
      ArrayMap<String,SystemConfig.PermissionEntry> permConfig=systemConfig.getPermissions();
      for (int i=0; i < permConfig.size(); i++) {
        SystemConfig.PermissionEntry perm=permConfig.valueAt(i);
        BasePermission bp=mSettings.mPermissions.get(perm.name);
        if (bp == null) {
          bp=new BasePermission(perm.name,"String_Node_Str",BasePermission.TYPE_BUILTIN);
          mSettings.mPermissions.put(perm.name,bp);
        }
        if (perm.gids != null) {
          bp.setGids(perm.gids,perm.perUser);
        }
      }
      ArrayMap<String,String> libConfig=systemConfig.getSharedLibraries();
      for (int i=0; i < libConfig.size(); i++) {
        mSharedLibraries.put(libConfig.keyAt(i),new SharedLibraryEntry(libConfig.valueAt(i),null));
      }
      mFoundPolicyFile=SELinuxMMAC.readInstallPolicy();
      mFirstBoot=!mSettings.readLPw(sUserManager.getUsers(false));
      if (mFirstBoot) {
        requestCopyPreoptedFiles();
      }
      String customResolverActivity=Resources.getSystem().getString(R.string.config_customResolverActivity);
      if (TextUtils.isEmpty(customResolverActivity)) {
        customResolverActivity=null;
      }
 else {
        mCustomResolverComponentName=ComponentName.unflattenFromString(customResolverActivity);
      }
      long startTime=SystemClock.uptimeMillis();
      EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_SYSTEM_SCAN_START,startTime);
      final int scanFlags=SCAN_NO_PATHS | SCAN_DEFER_DEX | SCAN_BOOTING| SCAN_INITIAL;
      final String bootClassPath=System.getenv("String_Node_Str");
      final String systemServerClassPath=System.getenv("String_Node_Str");
      if (bootClassPath == null) {
        Slog.w(TAG,"String_Node_Str");
      }
      if (systemServerClassPath == null) {
        Slog.w(TAG,"String_Node_Str");
      }
      final List<String> allInstructionSets=InstructionSets.getAllInstructionSets();
      final String[] dexCodeInstructionSets=getDexCodeInstructionSets(allInstructionSets.toArray(new String[allInstructionSets.size()]));
      if (mSharedLibraries.size() > 0) {
        for (        String dexCodeInstructionSet : dexCodeInstructionSets) {
          for (          SharedLibraryEntry libEntry : mSharedLibraries.values()) {
            final String lib=libEntry.path;
            if (lib == null) {
              continue;
            }
            try {
              int dexoptNeeded=DexFile.getDexOptNeeded(lib,dexCodeInstructionSet,getCompilerFilterForReason(REASON_SHARED_APK),false);
              if (dexoptNeeded != DexFile.NO_DEXOPT_NEEDED) {
                mInstaller.dexopt(lib,Process.SYSTEM_UID,dexCodeInstructionSet,dexoptNeeded,DEXOPT_PUBLIC,getCompilerFilterForReason(REASON_SHARED_APK),StorageManager.UUID_PRIVATE_INTERNAL,SKIP_SHARED_LIBRARY_CHECK);
              }
            }
 catch (            FileNotFoundException e) {
              Slog.w(TAG,"String_Node_Str" + lib);
            }
catch (            IOException|InstallerException e) {
              Slog.w(TAG,"String_Node_Str" + lib + "String_Node_Str"+ e.getMessage());
            }
          }
        }
      }
      File frameworkDir=new File(Environment.getRootDirectory(),"String_Node_Str");
      final VersionInfo ver=mSettings.getInternalVersion();
      mIsUpgrade=!Build.FINGERPRINT.equals(ver.fingerprint);
      mPromoteSystemApps=mIsUpgrade && ver.sdkVersion <= Build.VERSION_CODES.LOLLIPOP_MR1;
      mIsPreNUpgrade=mIsUpgrade && ver.sdkVersion < Build.VERSION_CODES.N;
      mIsPreNMR1Upgrade=mIsUpgrade && ver.sdkVersion < Build.VERSION_CODES.N_MR1;
      if (mPromoteSystemApps) {
        Iterator<PackageSetting> pkgSettingIter=mSettings.mPackages.values().iterator();
        while (pkgSettingIter.hasNext()) {
          PackageSetting ps=pkgSettingIter.next();
          if (isSystemApp(ps)) {
            mExistingSystemPackages.add(ps.name);
          }
        }
      }
      File vendorOverlayDir=new File(VENDOR_OVERLAY_DIR);
      scanDirTracedLI(vendorOverlayDir,mDefParseFlags | PackageParser.PARSE_IS_SYSTEM | PackageParser.PARSE_IS_SYSTEM_DIR| PackageParser.PARSE_TRUSTED_OVERLAY,scanFlags | SCAN_TRUSTED_OVERLAY,0);
      scanDirTracedLI(frameworkDir,mDefParseFlags | PackageParser.PARSE_IS_SYSTEM | PackageParser.PARSE_IS_SYSTEM_DIR| PackageParser.PARSE_IS_PRIVILEGED,scanFlags | SCAN_NO_DEX,0);
      final File privilegedAppDir=new File(Environment.getRootDirectory(),"String_Node_Str");
      scanDirTracedLI(privilegedAppDir,mDefParseFlags | PackageParser.PARSE_IS_SYSTEM | PackageParser.PARSE_IS_SYSTEM_DIR| PackageParser.PARSE_IS_PRIVILEGED,scanFlags,0);
      final File systemAppDir=new File(Environment.getRootDirectory(),"String_Node_Str");
      scanDirTracedLI(systemAppDir,mDefParseFlags | PackageParser.PARSE_IS_SYSTEM | PackageParser.PARSE_IS_SYSTEM_DIR,scanFlags,0);
      File vendorAppDir=new File("String_Node_Str");
      try {
        vendorAppDir=vendorAppDir.getCanonicalFile();
      }
 catch (      IOException e) {
      }
      scanDirTracedLI(vendorAppDir,mDefParseFlags | PackageParser.PARSE_IS_SYSTEM | PackageParser.PARSE_IS_SYSTEM_DIR,scanFlags,0);
      final File oemAppDir=new File(Environment.getOemDirectory(),"String_Node_Str");
      scanDirTracedLI(oemAppDir,mDefParseFlags | PackageParser.PARSE_IS_SYSTEM | PackageParser.PARSE_IS_SYSTEM_DIR,scanFlags,0);
      final List<String> possiblyDeletedUpdatedSystemApps=new ArrayList<String>();
      if (!mOnlyCore) {
        Iterator<PackageSetting> psit=mSettings.mPackages.values().iterator();
        while (psit.hasNext()) {
          PackageSetting ps=psit.next();
          if ((ps.pkgFlags & ApplicationInfo.FLAG_SYSTEM) == 0) {
            continue;
          }
          final PackageParser.Package scannedPkg=mPackages.get(ps.name);
          if (scannedPkg != null) {
            if (mSettings.isDisabledSystemPackageLPr(ps.name)) {
              logCriticalInfo(Log.WARN,"String_Node_Str" + ps.name + "String_Node_Str"+ ps.codePathString+ "String_Node_Str"+ ps.installStatus+ "String_Node_Str"+ ps.versionCode+ "String_Node_Str"+ scannedPkg.mVersionCode);
              removePackageLI(scannedPkg,true);
              mExpectingBetter.put(ps.name,ps.codePath);
            }
            continue;
          }
          if (!mSettings.isDisabledSystemPackageLPr(ps.name)) {
            psit.remove();
            logCriticalInfo(Log.WARN,"String_Node_Str" + ps.name + "String_Node_Str");
          }
 else {
            final PackageSetting disabledPs=mSettings.getDisabledSystemPkgLPr(ps.name);
            if (disabledPs.codePath == null || !disabledPs.codePath.exists()) {
              possiblyDeletedUpdatedSystemApps.add(ps.name);
            }
          }
        }
      }
      ArrayList<PackageSetting> deletePkgsList=mSettings.getListOfIncompleteInstallPackagesLPr();
      for (int i=0; i < deletePkgsList.size(); i++) {
        final String packageName=deletePkgsList.get(i).name;
        logCriticalInfo(Log.WARN,"String_Node_Str" + packageName);
synchronized (mPackages) {
          mSettings.removePackageLPw(packageName);
        }
      }
      deleteTempPackageFiles();
      mSettings.pruneSharedUsersLPw();
      if (!mOnlyCore) {
        EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_DATA_SCAN_START,SystemClock.uptimeMillis());
        scanDirTracedLI(mAppInstallDir,0,scanFlags | SCAN_REQUIRE_KNOWN,0);
        scanDirTracedLI(mDrmAppPrivateInstallDir,mDefParseFlags | PackageParser.PARSE_FORWARD_LOCK,scanFlags | SCAN_REQUIRE_KNOWN,0);
        scanDirLI(mEphemeralInstallDir,mDefParseFlags | PackageParser.PARSE_IS_EPHEMERAL,scanFlags | SCAN_REQUIRE_KNOWN,0);
        for (        String deletedAppName : possiblyDeletedUpdatedSystemApps) {
          PackageParser.Package deletedPkg=mPackages.get(deletedAppName);
          mSettings.removeDisabledSystemPackageLPw(deletedAppName);
          String msg;
          if (deletedPkg == null) {
            msg="String_Node_Str" + deletedAppName + "String_Node_Str";
          }
 else {
            msg="String_Node_Str" + deletedAppName + "String_Node_Str"+ deletedAppName;
            deletedPkg.applicationInfo.flags&=~ApplicationInfo.FLAG_SYSTEM;
            PackageSetting deletedPs=mSettings.mPackages.get(deletedAppName);
            deletedPs.pkgFlags&=~ApplicationInfo.FLAG_SYSTEM;
          }
          logCriticalInfo(Log.WARN,msg);
        }
        for (int i=0; i < mExpectingBetter.size(); i++) {
          final String packageName=mExpectingBetter.keyAt(i);
          if (!mPackages.containsKey(packageName)) {
            final File scanFile=mExpectingBetter.valueAt(i);
            logCriticalInfo(Log.WARN,"String_Node_Str" + packageName + "String_Node_Str");
            int reparseFlags=mDefParseFlags;
            if (FileUtils.contains(privilegedAppDir,scanFile)) {
              reparseFlags=PackageParser.PARSE_IS_SYSTEM | PackageParser.PARSE_IS_SYSTEM_DIR | PackageParser.PARSE_IS_PRIVILEGED;
            }
 else             if (FileUtils.contains(systemAppDir,scanFile)) {
              reparseFlags=PackageParser.PARSE_IS_SYSTEM | PackageParser.PARSE_IS_SYSTEM_DIR;
            }
 else             if (FileUtils.contains(vendorAppDir,scanFile)) {
              reparseFlags=PackageParser.PARSE_IS_SYSTEM | PackageParser.PARSE_IS_SYSTEM_DIR;
            }
 else             if (FileUtils.contains(oemAppDir,scanFile)) {
              reparseFlags=PackageParser.PARSE_IS_SYSTEM | PackageParser.PARSE_IS_SYSTEM_DIR;
            }
 else {
              Slog.e(TAG,"String_Node_Str" + scanFile);
              continue;
            }
            mSettings.enableSystemPackageLPw(packageName);
            try {
              scanPackageTracedLI(scanFile,reparseFlags,scanFlags,0,null);
            }
 catch (            PackageManagerException e) {
              Slog.e(TAG,"String_Node_Str" + e.getMessage());
            }
          }
        }
      }
      mExpectingBetter.clear();
      mStorageManagerPackage=getStorageManagerPackageName();
      mSetupWizardPackage=getSetupWizardPackageName();
      if (mProtectedFilters.size() > 0) {
        if (DEBUG_FILTERS && mSetupWizardPackage == null) {
          Slog.i(TAG,"String_Node_Str" + "String_Node_Str");
        }
        for (        ActivityIntentInfo filter : mProtectedFilters) {
          if (filter.activity.info.packageName.equals(mSetupWizardPackage)) {
            if (DEBUG_FILTERS) {
              Slog.i(TAG,"String_Node_Str" + "String_Node_Str" + filter.getPriority() + "String_Node_Str"+ "String_Node_Str"+ filter.activity.info.packageName+ "String_Node_Str"+ filter.activity.className+ "String_Node_Str"+ filter.getPriority());
            }
            continue;
          }
          Slog.w(TAG,"String_Node_Str" + "String_Node_Str" + filter.activity.info.packageName + "String_Node_Str"+ filter.activity.className+ "String_Node_Str"+ filter.getPriority());
          filter.setPriority(0);
        }
      }
      mDeferProtectedFilters=false;
      mProtectedFilters.clear();
      updateAllSharedLibrariesLPw();
      for (      SharedUserSetting setting : mSettings.getAllSharedUsersLPw()) {
        adjustCpuAbisForSharedUserLPw(setting.packages,null,false);
      }
      mPackageUsage.read(mPackages);
      mCompilerStats.read();
      EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_SCAN_END,SystemClock.uptimeMillis());
      Slog.i(TAG,"String_Node_Str" + ((SystemClock.uptimeMillis() - startTime) / 1000f) + "String_Node_Str");
      int updateFlags=UPDATE_PERMISSIONS_ALL;
      if (ver.sdkVersion != mSdkVersion) {
        Slog.i(TAG,"String_Node_Str" + ver.sdkVersion + "String_Node_Str"+ mSdkVersion+ "String_Node_Str");
        updateFlags|=UPDATE_PERMISSIONS_REPLACE_PKG | UPDATE_PERMISSIONS_REPLACE_ALL;
      }
      updatePermissionsLPw(null,null,StorageManager.UUID_PRIVATE_INTERNAL,updateFlags);
      ver.sdkVersion=mSdkVersion;
      if (!onlyCore && (mPromoteSystemApps || mFirstBoot)) {
        for (        UserInfo user : sUserManager.getUsers(true)) {
          mSettings.applyDefaultPreferredAppsLPw(this,user.id);
          applyFactoryDefaultBrowserLPw(user.id);
          primeDomainVerificationsLPw(user.id);
        }
      }
      final int storageFlags;
      if (StorageManager.isFileEncryptedNativeOrEmulated()) {
        storageFlags=StorageManager.FLAG_STORAGE_DE;
      }
 else {
        storageFlags=StorageManager.FLAG_STORAGE_DE | StorageManager.FLAG_STORAGE_CE;
      }
      reconcileAppsDataLI(StorageManager.UUID_PRIVATE_INTERNAL,UserHandle.USER_SYSTEM,storageFlags);
      if (mIsUpgrade && !onlyCore) {
        Slog.i(TAG,"String_Node_Str");
        for (int i=0; i < mSettings.mPackages.size(); i++) {
          final PackageSetting ps=mSettings.mPackages.valueAt(i);
          if (Objects.equals(StorageManager.UUID_PRIVATE_INTERNAL,ps.volumeUuid)) {
            clearAppDataLIF(ps.pkg,UserHandle.USER_ALL,StorageManager.FLAG_STORAGE_DE | StorageManager.FLAG_STORAGE_CE | Installer.FLAG_CLEAR_CODE_CACHE_ONLY);
          }
        }
        ver.fingerprint=Build.FINGERPRINT;
      }
      checkDefaultBrowser();
      mExistingSystemPackages.clear();
      mPromoteSystemApps=false;
      ver.databaseVersion=Settings.CURRENT_DATABASE_VERSION;
      mSettings.writeLPr();
      if ((isFirstBoot() || isUpgrade() || VMRuntime.didPruneDalvikCache()) && !onlyCore) {
        long start=System.nanoTime();
        List<PackageParser.Package> coreApps=new ArrayList<>();
        for (        PackageParser.Package pkg : mPackages.values()) {
          if (pkg.coreApp) {
            coreApps.add(pkg);
          }
        }
        int[] stats=performDexOptUpgrade(coreApps,false,getCompilerFilterForReason(REASON_CORE_APP));
        final int elapsedTimeSeconds=(int)TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - start);
        MetricsLogger.histogram(mContext,"String_Node_Str",elapsedTimeSeconds);
        if (DEBUG_DEXOPT) {
          Slog.i(TAG,"String_Node_Str" + elapsedTimeSeconds + "String_Node_Str"+ stats[0]+ "String_Node_Str"+ stats[1]+ "String_Node_Str"+ stats[2]+ "String_Node_Str");
        }
      }
      EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_READY,SystemClock.uptimeMillis());
      if (!mOnlyCore) {
        mRequiredVerifierPackage=getRequiredButNotReallyRequiredVerifierLPr();
        mRequiredInstallerPackage=getRequiredInstallerLPr();
        mRequiredUninstallerPackage=getRequiredUninstallerLPr();
        mIntentFilterVerifierComponent=getIntentFilterVerifierComponentNameLPr();
        mIntentFilterVerifier=new IntentVerifierProxy(mContext,mIntentFilterVerifierComponent);
        mServicesSystemSharedLibraryPackageName=getRequiredSharedLibraryLPr(PackageManager.SYSTEM_SHARED_LIBRARY_SERVICES);
        mSharedSystemSharedLibraryPackageName=getRequiredSharedLibraryLPr(PackageManager.SYSTEM_SHARED_LIBRARY_SHARED);
      }
 else {
        mRequiredVerifierPackage=null;
        mRequiredInstallerPackage=null;
        mRequiredUninstallerPackage=null;
        mIntentFilterVerifierComponent=null;
        mIntentFilterVerifier=null;
        mServicesSystemSharedLibraryPackageName=null;
        mSharedSystemSharedLibraryPackageName=null;
      }
      mInstallerService=new PackageInstallerService(context,this);
      final ComponentName ephemeralResolverComponent=getEphemeralResolverLPr();
      final ComponentName ephemeralInstallerComponent=getEphemeralInstallerLPr();
      if (ephemeralInstallerComponent != null && ephemeralResolverComponent != null) {
        if (DEBUG_EPHEMERAL) {
          Slog.i(TAG,"String_Node_Str" + ephemeralResolverComponent + "String_Node_Str"+ ephemeralInstallerComponent);
        }
        mEphemeralResolverComponent=ephemeralResolverComponent;
        mEphemeralInstallerComponent=ephemeralInstallerComponent;
        setUpEphemeralInstallerActivityLP(mEphemeralInstallerComponent);
        mEphemeralResolverConnection=new EphemeralResolverConnection(mContext,mEphemeralResolverComponent);
      }
 else {
        if (DEBUG_EPHEMERAL) {
          final String missingComponent=(ephemeralResolverComponent == null) ? (ephemeralInstallerComponent == null) ? "String_Node_Str" : "String_Node_Str" : "String_Node_Str";
          Slog.i(TAG,"String_Node_Str" + missingComponent);
        }
        mEphemeralResolverComponent=null;
        mEphemeralInstallerComponent=null;
        mEphemeralResolverConnection=null;
      }
      mEphemeralApplicationRegistry=new EphemeralApplicationRegistry(this);
    }
  }
  Runtime.getRuntime().gc();
  mInstaller.setWarnIfHeld(mPackages);
  LocalServices.addService(PackageManagerInternal.class,new PackageManagerInternalImpl());
}