Android M Power Button - AOSP

220 views
Skip to first unread message

Vivekanand Elango

unread,
May 12, 2016, 10:38:20 AM5/12/16
to android-porting
Hi,

I'm trying to modify AOSP for my firmware. I want to intercept PowerButton long press to add another option in the dialog box.

I tried adding another item to the " dialog box list " in GlobalActions.java, but on building it I get "Cannot find symbol Error".



Could somebody tell me what I'm doing wrong. All I want to do is add <Action>another item to the dialog list.

Daniel Doron

unread,
May 31, 2016, 10:50:16 AM5/31/16
to android-porting
Can you show a code diff? 
Does ic_flash_on_black exist? I did not find it in the base/core/res/res so I guess you added it yourself...(did you make update-api to reflect it in current.txt & system-current.txt?)
I looked at the code and I would: 

Create a new class in GlobalActions: 

private final class MyPowerAction extends SinglePressAction implements LongPressAction {
        private MyPowerAction() {
            super(com.android.internal.R.drawable.ic_flash_on_black,
                R.string.global_action_mypower_off);
        }

        @Override
        public boolean onLongPress() {
            // Do your thing here....you could also extend WindowManagerFuncs to add your function and do it from there...
            return true;
        }

       @Override
        public boolean showDuringKeyguard() {
            return true;
        }

        @Override
        public boolean showBeforeProvisioning() {
            return true;
        }

       @Override
        public void onPress() {
        }
}

in GlobalActionsDialog createDialog() ..... add your new class : 

if (GLOBAL_ACTION_KEY_POWER.equals(actionKey)) {
                mItems.add(new PowerAction());
                mItems.add(new MyPowerAction());

.....

I could be wrong....but I hope it helps....

Daniel. 
Reply all
Reply to author
Forward
0 new messages