android 修改开关机铃声

1,boot铃声,在surfaceflinger.cpp中readyToRun():
/*
     *  We're now ready to accept clients...
     */

    // start boot animation
    property_set("ctl.start", "bootanim");
    {
        char value[PROPERTY_VALUE_MAX];
        int ivalue = 0;

        property_get("persist.sys.profile.silent", value, "0");
        if (atoi(value)== 0){
            LOGI("start:persist.sys.profile.silent is soundable");
            property_set("ctl.start","startupsound");
        }
        else {
            LOGI("start:persist.sys.profile.silent is silent");
        }
    }

2,shutdown 动画加在ShutdownThread.java中的beginShutdownSequence()方法的

synchronized (sIsStartedGuard) {
            if (sIsStarted) {
                Log.d(TAG, "Request to shutdown already running, returning.");
                return;
            }
            sIsStarted = true;
        }
后面
代码如下
android.os.SystemProperties.set("ctl.start","shutdownanim");
  //chenxiang add to fix the shutdown sound
      android.media.AudioManager mAudioManager = (android.media.AudioManager)context.getSystemService(context.AUDIO_SERVICE);
      int ringerMode = mAudioManager.getRingerMode();
      Log.i(TAG,"ringerMode:" + ringerMode);
  if(ringerMode==android.media.AudioManager.RINGER_MODE_SILENT || ringerMode == android.media.AudioManager.RINGER_MODE_VIBRATE){

  }else{
  android.os.SystemProperties.set("ctl.start","shutdownsound");
  }

猜你喜欢

转载自ericchan2012.iteye.com/blog/1701118
今日推荐