Program: 198948
Project: 198948
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public void init(Context context,IWindowManager windowManager,WindowManagerFuncs windowManagerFuncs){
  mContext=context;
  mWindowManager=windowManager;
  mWindowManagerFuncs=windowManagerFuncs;
  mWindowManagerInternal=LocalServices.getService(WindowManagerInternal.class);
  mHandler=new PolicyHandler();
  mOrientationListener=new MyOrientationListener(mContext,mHandler);
  try {
    mOrientationListener.setCurrentRotation(windowManager.getRotation());
  }
 catch (  RemoteException ex) {
  }
  mSettingsObserver=new SettingsObserver(mHandler);
  mSettingsObserver.observe();
  mShortcutManager=new ShortcutManager(context,mHandler);
  mShortcutManager.observe();
  mUiMode=context.getResources().getInteger(com.android.internal.R.integer.config_defaultUiModeType);
  mHomeIntent=new Intent(Intent.ACTION_MAIN,null);
  mHomeIntent.addCategory(Intent.CATEGORY_HOME);
  mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
  mCarDockIntent=new Intent(Intent.ACTION_MAIN,null);
  mCarDockIntent.addCategory(Intent.CATEGORY_CAR_DOCK);
  mCarDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
  mDeskDockIntent=new Intent(Intent.ACTION_MAIN,null);
  mDeskDockIntent.addCategory(Intent.CATEGORY_DESK_DOCK);
  mDeskDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
  mPowerManager=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
  mBroadcastWakeLock=mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"String_Node_Str");
  mEnableShiftMenuBugReports="String_Node_Str".equals(SystemProperties.get("String_Node_Str"));
  mSupportAutoRotation=mContext.getResources().getBoolean(com.android.internal.R.bool.config_supportAutoRotation);
  mLidOpenRotation=readRotation(com.android.internal.R.integer.config_lidOpenRotation);
  mCarDockRotation=readRotation(com.android.internal.R.integer.config_carDockRotation);
  mDeskDockRotation=readRotation(com.android.internal.R.integer.config_deskDockRotation);
  mUndockedHdmiRotation=readRotation(com.android.internal.R.integer.config_undockedHdmiRotation);
  mCarDockEnablesAccelerometer=mContext.getResources().getBoolean(com.android.internal.R.bool.config_carDockEnablesAccelerometer);
  mDeskDockEnablesAccelerometer=mContext.getResources().getBoolean(com.android.internal.R.bool.config_deskDockEnablesAccelerometer);
  mLidKeyboardAccessibility=mContext.getResources().getInteger(com.android.internal.R.integer.config_lidKeyboardAccessibility);
  mLidNavigationAccessibility=mContext.getResources().getInteger(com.android.internal.R.integer.config_lidNavigationAccessibility);
  mLidControlsSleep=mContext.getResources().getBoolean(com.android.internal.R.bool.config_lidControlsSleep);
  mTranslucentDecorEnabled=mContext.getResources().getBoolean(com.android.internal.R.bool.config_enableTranslucentDecor);
  readConfigurationDependentBehaviors();
  IntentFilter filter=new IntentFilter();
  filter.addAction(UiModeManager.ACTION_ENTER_CAR_MODE);
  filter.addAction(UiModeManager.ACTION_EXIT_CAR_MODE);
  filter.addAction(UiModeManager.ACTION_ENTER_DESK_MODE);
  filter.addAction(UiModeManager.ACTION_EXIT_DESK_MODE);
  filter.addAction(Intent.ACTION_DOCK_EVENT);
  Intent intent=context.registerReceiver(mDockReceiver,filter);
  if (intent != null) {
    mDockMode=intent.getIntExtra(Intent.EXTRA_DOCK_STATE,Intent.EXTRA_DOCK_STATE_UNDOCKED);
  }
  filter=new IntentFilter();
  filter.addAction(Intent.ACTION_DREAMING_STARTED);
  filter.addAction(Intent.ACTION_DREAMING_STOPPED);
  context.registerReceiver(mDreamReceiver,filter);
  filter=new IntentFilter(Intent.ACTION_USER_SWITCHED);
  context.registerReceiver(mMultiuserReceiver,filter);
  mSystemGestures=new SystemGesturesPointerEventListener(context,new SystemGesturesPointerEventListener.Callbacks(){
    @Override public void onSwipeFromTop(){
      if (mStatusBar != null) {
        requestTransientBars(mStatusBar);
      }
    }
    @Override public void onSwipeFromBottom(){
      if (mNavigationBar != null && mNavigationBarOnBottom) {
        requestTransientBars(mNavigationBar);
      }
    }
    @Override public void onSwipeFromRight(){
      if (mNavigationBar != null && !mNavigationBarOnBottom) {
        requestTransientBars(mNavigationBar);
      }
    }
    @Override public void onDebug(){
    }
  }
);
  mImmersiveModeConfirmation=new ImmersiveModeConfirmation(mContext);
  mWindowManagerFuncs.registerPointerEventListener(mSystemGestures);
  mVibrator=(Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
  mLongPressVibePattern=getLongIntArray(mContext.getResources(),com.android.internal.R.array.config_longPressVibePattern);
  mVirtualKeyVibePattern=getLongIntArray(mContext.getResources(),com.android.internal.R.array.config_virtualKeyVibePattern);
  mKeyboardTapVibePattern=getLongIntArray(mContext.getResources(),com.android.internal.R.array.config_keyboardTapVibePattern);
  mSafeModeDisabledVibePattern=getLongIntArray(mContext.getResources(),com.android.internal.R.array.config_safeModeDisabledVibePattern);
  mSafeModeEnabledVibePattern=getLongIntArray(mContext.getResources(),com.android.internal.R.array.config_safeModeEnabledVibePattern);
  mScreenshotChordEnabled=mContext.getResources().getBoolean(com.android.internal.R.bool.config_enableScreenshotChord);
  mGlobalKeyManager=new GlobalKeyManager(mContext);
  initializeHdmiState();
  if (mPowerManager.isScreenOn()) {
    wakingUp(null);
  }
 else {
    goingToSleep(WindowManagerPolicy.OFF_BECAUSE_OF_USER);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public void init(Context context,IWindowManager windowManager,WindowManagerFuncs windowManagerFuncs){
  mContext=context;
  mWindowManager=windowManager;
  mWindowManagerFuncs=windowManagerFuncs;
  mWindowManagerInternal=LocalServices.getService(WindowManagerInternal.class);
  mHandler=new PolicyHandler();
  mOrientationListener=new MyOrientationListener(mContext,mHandler);
  try {
    mOrientationListener.setCurrentRotation(windowManager.getRotation());
  }
 catch (  RemoteException ex) {
  }
  mSettingsObserver=new SettingsObserver(mHandler);
  mSettingsObserver.observe();
  mShortcutManager=new ShortcutManager(context,mHandler);
  mShortcutManager.observe();
  mUiMode=context.getResources().getInteger(com.android.internal.R.integer.config_defaultUiModeType);
  mHomeIntent=new Intent(Intent.ACTION_MAIN,null);
  mHomeIntent.addCategory(Intent.CATEGORY_HOME);
  mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
  mCarDockIntent=new Intent(Intent.ACTION_MAIN,null);
  mCarDockIntent.addCategory(Intent.CATEGORY_CAR_DOCK);
  mCarDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
  mDeskDockIntent=new Intent(Intent.ACTION_MAIN,null);
  mDeskDockIntent.addCategory(Intent.CATEGORY_DESK_DOCK);
  mDeskDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
  mPowerManager=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
  mBroadcastWakeLock=mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"String_Node_Str");
  mEnableShiftMenuBugReports="String_Node_Str".equals(SystemProperties.get("String_Node_Str"));
  mSupportAutoRotation=mContext.getResources().getBoolean(com.android.internal.R.bool.config_supportAutoRotation);
  mLidOpenRotation=readRotation(com.android.internal.R.integer.config_lidOpenRotation);
  mCarDockRotation=readRotation(com.android.internal.R.integer.config_carDockRotation);
  mDeskDockRotation=readRotation(com.android.internal.R.integer.config_deskDockRotation);
  mUndockedHdmiRotation=readRotation(com.android.internal.R.integer.config_undockedHdmiRotation);
  mCarDockEnablesAccelerometer=mContext.getResources().getBoolean(com.android.internal.R.bool.config_carDockEnablesAccelerometer);
  mDeskDockEnablesAccelerometer=mContext.getResources().getBoolean(com.android.internal.R.bool.config_deskDockEnablesAccelerometer);
  mLidKeyboardAccessibility=mContext.getResources().getInteger(com.android.internal.R.integer.config_lidKeyboardAccessibility);
  mLidNavigationAccessibility=mContext.getResources().getInteger(com.android.internal.R.integer.config_lidNavigationAccessibility);
  mLidControlsSleep=mContext.getResources().getBoolean(com.android.internal.R.bool.config_lidControlsSleep);
  mTranslucentDecorEnabled=mContext.getResources().getBoolean(com.android.internal.R.bool.config_enableTranslucentDecor);
  readConfigurationDependentBehaviors();
  IntentFilter filter=new IntentFilter();
  filter.addAction(UiModeManager.ACTION_ENTER_CAR_MODE);
  filter.addAction(UiModeManager.ACTION_EXIT_CAR_MODE);
  filter.addAction(UiModeManager.ACTION_ENTER_DESK_MODE);
  filter.addAction(UiModeManager.ACTION_EXIT_DESK_MODE);
  filter.addAction(Intent.ACTION_DOCK_EVENT);
  Intent intent=context.registerReceiver(mDockReceiver,filter);
  if (intent != null) {
    mDockMode=intent.getIntExtra(Intent.EXTRA_DOCK_STATE,Intent.EXTRA_DOCK_STATE_UNDOCKED);
  }
  filter=new IntentFilter();
  filter.addAction(Intent.ACTION_DREAMING_STARTED);
  filter.addAction(Intent.ACTION_DREAMING_STOPPED);
  context.registerReceiver(mDreamReceiver,filter);
  filter=new IntentFilter(Intent.ACTION_USER_SWITCHED);
  context.registerReceiver(mMultiuserReceiver,filter);
  mSystemGestures=new SystemGesturesPointerEventListener(context,new SystemGesturesPointerEventListener.Callbacks(){
    @Override public void onSwipeFromTop(){
      if (mStatusBar != null) {
        requestTransientBars(mStatusBar);
      }
    }
    @Override public void onSwipeFromBottom(){
      if (mNavigationBar != null && mNavigationBarOnBottom) {
        requestTransientBars(mNavigationBar);
      }
    }
    @Override public void onSwipeFromRight(){
      if (mNavigationBar != null && !mNavigationBarOnBottom) {
        requestTransientBars(mNavigationBar);
      }
    }
    @Override public void onDebug(){
    }
  }
);
  mImmersiveModeConfirmation=new ImmersiveModeConfirmation(mContext);
  mWindowManagerFuncs.registerPointerEventListener(mSystemGestures);
  mVibrator=(Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
  mLongPressVibePattern=getLongIntArray(mContext.getResources(),com.android.internal.R.array.config_longPressVibePattern);
  mVirtualKeyVibePattern=getLongIntArray(mContext.getResources(),com.android.internal.R.array.config_virtualKeyVibePattern);
  mKeyboardTapVibePattern=getLongIntArray(mContext.getResources(),com.android.internal.R.array.config_keyboardTapVibePattern);
  mSafeModeDisabledVibePattern=getLongIntArray(mContext.getResources(),com.android.internal.R.array.config_safeModeDisabledVibePattern);
  mSafeModeEnabledVibePattern=getLongIntArray(mContext.getResources(),com.android.internal.R.array.config_safeModeEnabledVibePattern);
  mScreenshotChordEnabled=mContext.getResources().getBoolean(com.android.internal.R.bool.config_enableScreenshotChord);
  mGlobalKeyManager=new GlobalKeyManager(mContext);
  initializeHdmiState();
  if (mPowerManager.isInteractive()) {
    wakingUp(null);
  }
 else {
    goingToSleep(WindowManagerPolicy.OFF_BECAUSE_OF_USER);
  }
}