外部调用关机API时,会发送类似于下面的intent:
Intent newIntent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);
newIntent.putExtra(Intent.EXTRA_KEY_CONFIRM,false);
startActivity(newIntent);
而响应的地方,是一个无界面的activity,其类是framework下面的com.android.server.ShutdownActivity.
其配置的xml如下所示:
<activity android:name="com.android.server.ShutdownActivity" android:permission="android.permission.SHUTDOWN" android:configChanges="orientation|keyboardHidden|navigation|mcc|mnc|locale|touchscreen|fontScale|keyboard" android:excludeFromRecents="true"> <intent-filter> <action android:name="android.intent.action.ACTION_REQUEST_SHUTDOWN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity>