Search code examples
androidandroid-source

Modify Poweroff dialog in AOSP (menu that when holding power key appears)


How I can modify the dialog which is shown when the user holds the power key?

I want the user to just be able to reboot his device and not to poweroff.

Where is related setting resides in AOSP?

Thanks


Solution

  • Here is a nice article about shutdown in android.

    According to above article we should take a look at this file :

    "frameworks/base/services/core/java/com/android/server/policy/GlobalActions.java"

    Consider these lines in the file:

             String[] defaultActions = mContext.getResources().getStringArray(
                     com.android.internal.R.array.config_globalActionsList);
    

    So we should modify config_globalActionsList. Here is the relevant grep results:

        $ grep -rnIi . -e 'config_globalActionsList' --exclude-dir=out/
        ./base/core/res/res/values/config.xml:2210:    <string-array translatable="false" name="config_globalActionsList">
        ./base/core/res/res/values-watch/config.xml:25:    <string-array translatable="false" name="config_globalActionsList">
        ./base/core/res/res/values/symbols.xml:1157:  <java-symbol type="array" name="config_globalActionsList" />
        ./base/services/core/java/com/android/server/policy/GlobalActions.java:271:                com.android.internal.R.array.config_globalActionsList);
    

    The first entry is relevant. New array is like this (I have remove shutdown):

    <string-array translatable="false" name="config_globalActionsList">
        <item>restart</item>
        <item>bugreport</item>
        <item>users</item>
    </string-array>