Program: 194793
Project: 194793
Buggy source:
private ContextImpl(ContextImpl container,ActivityThread mainThread,LoadedApk packageInfo,IBinder activityToken,UserHandle user,boolean restricted,Display display,Configuration overrideConfiguration,int createDisplayWithId){
  mOuterContext=this;
  mMainThread=mainThread;
  mActivityToken=activityToken;
  mRestricted=restricted;
  if (user == null) {
    user=Process.myUserHandle();
  }
  mUser=user;
  mPackageInfo=packageInfo;
  mResourcesManager=ResourcesManager.getInstance();
  final int displayId=(createDisplayWithId != Display.INVALID_DISPLAY) ? createDisplayWithId : getDisplayId();
  CompatibilityInfo compatInfo=null;
  if (container != null) {
    compatInfo=container.getDisplayAdjustments(displayId).getCompatibilityInfo();
  }
  if (compatInfo == null) {
    compatInfo=(displayId == Display.DEFAULT_DISPLAY) ? packageInfo.getCompatibilityInfo() : CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO;
  }
  mDisplayAdjustments.setCompatibilityInfo(compatInfo);
  mDisplayAdjustments.setConfiguration(overrideConfiguration);
  mDisplay=(createDisplayWithId == Display.INVALID_DISPLAY) ? display : ResourcesManager.getInstance().getAdjustedDisplay(displayId,mDisplayAdjustments);
  Resources resources=packageInfo.getResources(mainThread);
  if (resources != null) {
    if (displayId != Display.DEFAULT_DISPLAY || overrideConfiguration != null || (compatInfo != null && compatInfo.applicationScale != resources.getCompatibilityInfo().applicationScale)) {
      resources=mResourcesManager.getTopLevelResources(packageInfo.getResDir(),packageInfo.getSplitResDirs(),packageInfo.getOverlayDirs(),packageInfo.getApplicationInfo().sharedLibraryFiles,displayId,overrideConfiguration,compatInfo);
    }
  }
  mResources=resources;
  if (container != null) {
    mBasePackageName=container.mBasePackageName;
    mOpPackageName=container.mOpPackageName;
  }
 else {
    mBasePackageName=packageInfo.mPackageName;
    ApplicationInfo ainfo=packageInfo.getApplicationInfo();
    if (ainfo.uid == Process.SYSTEM_UID && ainfo.uid != Process.myUid()) {
      mOpPackageName=ActivityThread.currentPackageName();
    }
 else {
      mOpPackageName=mBasePackageName;
    }
  }
  mContentResolver=new ApplicationContentResolver(this,mainThread,user);
}

Fixed version (ground truth):
private ContextImpl(ContextImpl container,ActivityThread mainThread,LoadedApk packageInfo,IBinder activityToken,UserHandle user,boolean restricted,Display display,Configuration overrideConfiguration,int createDisplayWithId){
  mOuterContext=this;
  mMainThread=mainThread;
  mActivityToken=activityToken;
  mRestricted=restricted;
  if (user == null) {
    user=Process.myUserHandle();
  }
  mUser=user;
  mPackageInfo=packageInfo;
  mResourcesManager=ResourcesManager.getInstance();
  final int displayId=(createDisplayWithId != Display.INVALID_DISPLAY) ? createDisplayWithId : (display != null) ? display.getDisplayId() : Display.DEFAULT_DISPLAY;
  CompatibilityInfo compatInfo=null;
  if (container != null) {
    compatInfo=container.getDisplayAdjustments(displayId).getCompatibilityInfo();
  }
  if (compatInfo == null) {
    compatInfo=(displayId == Display.DEFAULT_DISPLAY) ? packageInfo.getCompatibilityInfo() : CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO;
  }
  mDisplayAdjustments.setCompatibilityInfo(compatInfo);
  mDisplayAdjustments.setConfiguration(overrideConfiguration);
  mDisplay=(createDisplayWithId == Display.INVALID_DISPLAY) ? display : ResourcesManager.getInstance().getAdjustedDisplay(displayId,mDisplayAdjustments);
  Resources resources=packageInfo.getResources(mainThread);
  if (resources != null) {
    if (displayId != Display.DEFAULT_DISPLAY || overrideConfiguration != null || (compatInfo != null && compatInfo.applicationScale != resources.getCompatibilityInfo().applicationScale)) {
      resources=mResourcesManager.getTopLevelResources(packageInfo.getResDir(),packageInfo.getSplitResDirs(),packageInfo.getOverlayDirs(),packageInfo.getApplicationInfo().sharedLibraryFiles,displayId,overrideConfiguration,compatInfo);
    }
  }
  mResources=resources;
  if (container != null) {
    mBasePackageName=container.mBasePackageName;
    mOpPackageName=container.mOpPackageName;
  }
 else {
    mBasePackageName=packageInfo.mPackageName;
    ApplicationInfo ainfo=packageInfo.getApplicationInfo();
    if (ainfo.uid == Process.SYSTEM_UID && ainfo.uid != Process.myUid()) {
      mOpPackageName=ActivityThread.currentPackageName();
    }
 else {
      mOpPackageName=mBasePackageName;
    }
  }
  mContentResolver=new ApplicationContentResolver(this,mainThread,user);
}