让Android不播放关机动画,而是显示一个关机进度条的方法

修改文件:
frameworks/base/core/java/com/android/internal/app/ShutdownThread.java
synchronized (mEnableAnimatingSync) {  
        if(!mEnableAnimating){
            sInstance.mPowerManager.setBacklightBrightness(Power.BRIGHTNESS_DIM);
        } else {
        	//add by bcf,将播放动画的BOOLEAN值设置为假,就不播放动画了,而是显示一个进度条+正在关机的字样
        	mShutOffAnimation=false;  
         //add end
          if (mShutOffAnimation) {
                boolean isRotaionEnabled = false;   
                try {
                    isRotaionEnabled = Settings.System.getInt(sInstance.mContext.getContentResolver(), 
                            Settings.System.ACCELEROMETER_ROTATION, 1) != 0;
                    if (isRotaionEnabled) {
                        Settings.System.putInt(sInstance.mContext.getContentResolver(),
                                Settings.System.ACCELEROMETER_ROTATION, 0);
                        Settings.System.putInt(sInstance.mContext.getContentResolver(), 
                                Settings.System.ACCELEROMETER_ROTATION_RESTORE, 1);
                    }
                } catch (NullPointerException ex) {
                    Log.e(TAG, "check Rotation: sInstance.mContext object is null when get Rotation");
                  
                }           
                beginAnimationTime = SystemClock.elapsedRealtime() + MIN_SHUTDOWN_ANIMATION_PLAY_TIME;
                 // +MediaTek 2012-02-25 Disable key dispatch
                try {
                    final IWindowManager wm = IWindowManager.Stub.asInterface(
                            ServiceManager.getService(Context.WINDOW_SERVICE));
                    wm.setEventDispatching(false);
                } catch (RemoteException e) {}
                // -MediaTek 2012-02-25 Disable key dispatch                              
                startBootAnimation();
            } else {
                pd = new ProgressDialog(context); 
                pd.setTitle(context.getText(com.android.internal.R.string.power_off));
                pd.setMessage(context.getText(com.android.internal.R.string.shutdown_progress));
                pd.setIndeterminate(true);
                pd.setCancelable(false);
                pd.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);

                /* To fix video+UI+blur flick issue */
                pd.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

                pd.show();
            }
            /* set screen brightness off after shutdownThread start */
            sInstance.mHandler.postDelayed(mDelayDim, screen_turn_off_time); 
        }
   } 

你可能感兴趣的:(android)