---
title: "android 修改开关机铃声"
author: "ericchan2012"
date: "2012-10-18T16:52:54Z"
tags: []
categories: ["移动开发"]
slug: "android"
draft: false
lastmod: "2012-10-18T16:52:54Z"
id: 1701118
url: "https://ericchan2012.iteye.com/blog/1701118"
---

1，boot铃声，在surfaceflinger.cpp中readyToRun():
/*
     *  We're now ready to accept clients...
     */

    // start boot animation
    property_set("ctl.start", "bootanim");
    {
        char value;
        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");
	  }