[MOD][HOWTO] Extended Power Menu (EPM)

Search This thread

kenet

Senior Member
Jun 15, 2010
355
528
Leon
www.androidmod.net
I already have it but the icons overlap

140dx0g.jpg


I'll see why it is

If I do not remove the airplane mode

-------------------------------

ya encontre el error

---------- Post added at 07:15 PM ---------- Previous post was at 06:19 PM ----------

I already have it working.

I'll upload the files tomorrow

5mwqq.jpg
 
Last edited:
  • Like
Reactions: bkores

bkores

Senior Member
Aug 12, 2016
812
614
Staten Island, NY
I already have it but the icons overlap



I'll see why it is

If I do not remove the airplane mode

-------------------------------

ya encontre el error

---------- Post added at 07:15 PM ---------- Previous post was at 06:19 PM ----------

I already have it working.

I'll upload the files tomorrow

Thanks @kenet. Would you also be able to create a download icon xml?
 

kenet

Senior Member
Jun 15, 2010
355
528
Leon
www.androidmod.net
I am having problems with the GlobalActions.smali

.line 269
iget-object v6, p0, Lcom/android/server/policy/GlobalActions;->contentView:Landroid/view/View;

const v9, 0x06060067

invoke-virtual {v6, v9}, Landroid/view/View;->findViewById(I)Landroid/view/View;

move-result-object v3

.line 270
.local v3, "recoveryAction":Landroid/view/View;
new-instance v6, Lcom/android/server/policy/GlobalActions$19;

invoke-direct {v6, p0}, Lcom/android/server/policy/GlobalActions$19;-><init>(Lcom/android/server/policy/GlobalActions;)V

invoke-virtual {v3, v6}, Landroid/view/View;->setOnClickListener(Landroid/view/View$OnClickListener;)V

iget-object v6, p0, Lcom/android/server/policy/GlobalActions;->contentView:Landroid/view/View;

const v9, 0x06060068

invoke-virtual {v6, v9}, Landroid/view/View;->findViewById(I)Landroid/view/View;

move-result-object v3

.line 270
.local v3, "edlAction":Landroid/view/View;
new-instance v6, Lcom/android/server/policy/GlobalActions$21;

invoke-direct {v6, p0}, Lcom/android/server/policy/GlobalActions$21;-><init>(Lcom/android/server/policy/GlobalActions;)V

invoke-virtual {v3, v6}, Landroid/view/View;->setOnClickListener(Landroid/view/View$OnClickListener;)V

iget-object v6, p0, Lcom/android/server/policy/GlobalActions;->contentView:Landroid/view/View;

const v9, 0x0606006d

invoke-virtual {v6, v9}, Landroid/view/View;->findViewById(I)Landroid/view/View;

move-result-object v3


.line 270
.local v3, "bootloaderAction":Landroid/view/View;
new-instance v6, Lcom/android/server/policy/GlobalActions$20;

invoke-direct {v6, p0}, Lcom/android/server/policy/GlobalActions$20;-><init>(Lcom/android/server/policy/GlobalActions;)V

invoke-virtual {v3, v6}, Landroid/view/View;->setOnClickListener(Landroid/view/View$OnClickListener;)V

.line 298
iget-object v6, p0, Lcom/android/server/policy/GlobalActions;->contentView:Landroid/view/View;

const v9, 0x606002b

invoke-virtual {v6, v9}, Landroid/view/View;->findViewById(I)Landroid/view/View;

move-result-object v6

check-cast v6, Landroid/widget/TextView;

iput-object v6, p0, Lcom/android/server/policy/GlobalActions;->mAirplanetext:Landroid/widget/TextView;

If I put it on top of the bootloader. Clicking on bootloader sends me to edl.

And if I pulse in edl it takes me to the bootloader.

If I put the code above the recovery, The same thing happens to me but with the recovery functiony.

Let me see if I can find it because it is.
 
Last edited:

jeboo

Recognized Developer
Apr 2, 2010
817
4,059
Ah nice, I wasn't aware. When I get some free time, I'll work on an Xposed version :)

Just a quick update, I finally had some time to start converting this mod to Xposed. I've finished with the dynamic layout generation, it was non-trivial to say the least. Hopefully that was the hardest part and I can finish the code hooks sometime soon :)
 

Attachments

  • Screenshot_2017-11-07-21-26-11.jpg
    Screenshot_2017-11-07-21-26-11.jpg
    162.2 KB · Views: 279

jionny

Senior Member
Aug 23, 2013
540
134
I tried this on lineage 14.1 and it didnt work I have A2017U, anyone have any suggestions
 

Choose an username...

Senior Member
Oct 16, 2016
2,673
926
I tried this on lineage 14.1 and it didnt work I have A2017U, anyone have any suggestions
What? You tried the OP method?

If you did, you're only partly to blame because it is not really specified. But this guide is for STOCK ROMs. Which is pretty evident anyways

If you want an advanced menu on Lineage you just have to go to the developer options and enable advanced power menu
 
  • Like
Reactions: jionny

Top Liked Posts

  • There are no posts matching your filters.
  • 23
    xp372e.jpg


    I figured this mod was long overdue, given that we're without Xposed on Nougat. Those who used to have the Galaxy S2/4 know how fond I am of this feature! This is a straightforward mod to add 2 buttons to the longpress power menu, specifically to reboot directly to recovery and bootloader. I'm not including a flashable zip as it won't run with stock kernel (modifies /system) and this is really intended for ROM devs to cook.

    I've attached the B19 files to this post.

    I will go through all the changes necessary to do the mod yourself for future bases. It will be assumed you have a basic environment (apktool/smali/baksmali) set up and some apk/jar modification experience. This is based on A2017U B19.

    1. Add the buttons to the longpress menu: /system/framework/framework-zte-res.apk

    - Decompile the apk and replace res/layout/global_dialog.xml with:
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout android:orientation="vertical" android:background="#b3000000" android:layout_width="fill_parent" android:layout_height="fill_parent"
      xmlns:android="http://schemas.android.com/apk/res/android">
        <TextView android:textSize="12.0sp" android:textColor="#8affffff" android:gravity="center" android:id="@id/longpress" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="24.0dip" android:text="@string/global_action_rboot_message" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" />
        <RelativeLayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="132.0dip" android:layout_marginStart="56.0dip" android:layout_alignParentStart="true">
            <LinearLayout android:gravity="center_horizontal" android:orientation="vertical" android:id="@id/airplanemode" android:layout_width="wrap_content" android:layout_height="wrap_content">
                <ImageButton android:id="@id/airplane" android:background="@drawable/circle1" android:clickable="false" android:layout_width="wrap_content" android:layout_height="wrap_content" android:tint="#ffffffff" android:alpha="0.9" android:paddingStart="19.0dip" android:paddingEnd="19.0dip" />
                <TextView android:textSize="12.0sp" android:textColor="@color/global_action_text" android:gravity="center" android:id="@id/text_airplane" android:paddingTop="10.0dip" android:layout_width="110.0dip" android:layout_height="wrap_content" android:maxLines="2" />
            </LinearLayout>
        </RelativeLayout>
        <RelativeLayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="132.0dip" android:layout_marginEnd="56.0dip" android:layout_alignParentEnd="true">
            <LinearLayout android:gravity="center_horizontal" android:orientation="vertical" android:id="@id/silent_mode" android:layout_width="wrap_content" android:layout_height="wrap_content">
                <ImageButton android:id="@id/silent" android:background="@drawable/circle1" android:clickable="false" android:layout_width="wrap_content" android:layout_height="wrap_content" android:tint="#ffffffff" android:alpha="0.9" android:paddingStart="19.0dip" android:paddingEnd="19.0dip" />
                <TextView android:textSize="12.0sp" android:textColor="@color/global_action_text" android:gravity="center" android:id="@id/text_silent" android:paddingTop="10.0dip" android:layout_width="110.0dip" android:layout_height="wrap_content" android:maxLines="2" />
            </LinearLayout>
        </RelativeLayout>
        <RelativeLayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="268.0dip" android:layout_marginStart="56.0dip" android:layout_alignParentStart="true">
            <LinearLayout android:gravity="center_horizontal" android:orientation="vertical" android:id="@id/reset_action" android:layout_width="wrap_content" android:layout_height="wrap_content">
                <ImageButton android:id="@id/reset" android:background="@drawable/circle1" android:clickable="false" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_lock_reboot" android:tint="#ffffffff" android:contentDescription="@string/global_action_reset" android:alpha="0.9" android:paddingStart="19.0dip" android:paddingEnd="19.0dip" />
                <TextView android:textSize="12.0sp" android:textColor="@color/global_action_text" android:gravity="center" android:id="@id/text_reset" android:paddingTop="10.0dip" android:layout_width="110.0dip" android:layout_height="wrap_content" android:text="@string/global_action_reset" android:maxLines="2" />
            </LinearLayout>
        </RelativeLayout>
        <RelativeLayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="268.0dip" android:layout_marginEnd="56.0dip" android:layout_alignParentEnd="true">
            <LinearLayout android:gravity="center_horizontal" android:orientation="vertical" android:id="@id/power_action" android:layout_width="wrap_content" android:layout_height="wrap_content">
                <ImageButton android:id="@id/power" android:background="@drawable/circle1" android:clickable="false" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_lock_power" android:tint="#ffffffff" android:contentDescription="@string/global_action_poweroff" android:alpha="0.9" android:paddingStart="19.0dip" android:paddingEnd="19.0dip" />
                <TextView android:textSize="12.0sp" android:textColor="@color/global_action_text" android:gravity="center" android:id="@id/text_power" android:paddingTop="10.0dip" android:layout_width="110.0dip" android:layout_height="wrap_content" android:text="@string/global_action_poweroff" android:maxLines="2" />
            </LinearLayout>
        </RelativeLayout>
        <RelativeLayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="404.0dip" android:layout_marginStart="56.0dip" android:layout_alignParentStart="true">
            <LinearLayout android:gravity="center_horizontal" android:orientation="vertical" android:id="@id/recovery_action" android:layout_width="wrap_content" android:layout_height="wrap_content">
                <ImageButton android:id="@id/recovery" android:background="@drawable/circle1" android:clickable="false" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_lock_power" android:tint="#ffffffff" android:contentDescription="@string/global_action_recovery" android:alpha="0.9" android:paddingStart="19.0dip" android:paddingEnd="19.0dip" />
                <TextView android:textSize="12.0sp" android:textColor="@color/global_action_text" android:gravity="center" android:id="@id/text_recovery" android:paddingTop="10.0dip" android:layout_width="110.0dip" android:layout_height="wrap_content" android:text="@string/global_action_recovery" android:maxLines="2" />
            </LinearLayout>
        </RelativeLayout>
        <RelativeLayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="404.0dip" android:layout_marginEnd="56.0dip" android:layout_alignParentEnd="true">
            <LinearLayout android:gravity="center_horizontal" android:orientation="vertical" android:id="@id/bootloader_action" android:layout_width="wrap_content" android:layout_height="wrap_content">
                <ImageButton android:id="@id/bootloader" android:background="@drawable/circle1" android:clickable="false" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_lock_power" android:tint="#ffffffff" android:contentDescription="@string/global_action_bootloader" android:alpha="0.9" android:paddingStart="19.0dip" android:paddingEnd="19.0dip" />
                <TextView android:textSize="12.0sp" android:textColor="@color/global_action_text" android:gravity="center" android:id="@id/text_bootloader" android:paddingTop="10.0dip" android:layout_width="110.0dip" android:layout_height="wrap_content" android:text="@string/global_action_bootloader" android:maxLines="2" />
            </LinearLayout>
        </RelativeLayout>
    </RelativeLayout>

    - For the landscape version, replace res/layout-land/global_dialog.xml with:

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout android:orientation="vertical" android:background="#b3000000" android:layout_width="fill_parent" android:layout_height="fill_parent"
      xmlns:android="http://schemas.android.com/apk/res/android">
        <TextView android:textSize="12.0sp" android:textColor="#8affffff" android:gravity="center" android:id="@id/longpress" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="24.0dip" android:text="@string/global_action_rboot_message" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" />
        <LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="86.0dip" android:layout_centerHorizontal="true">
            <LinearLayout android:gravity="center_horizontal" android:orientation="vertical" android:id="@id/airplanemode" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginEnd="14.0dip">
                <ImageButton android:id="@id/airplane" android:background="@drawable/circle1" android:clickable="false" android:layout_width="wrap_content" android:layout_height="wrap_content" android:tint="#ffffffff" android:alpha="0.9" android:paddingStart="19.0dip" android:paddingEnd="19.0dip" />
                <TextView android:textSize="12.0sp" android:textColor="@color/global_action_text" android:gravity="center" android:id="@id/text_airplane" android:paddingTop="10.0dip" android:layout_width="110.0dip" android:layout_height="wrap_content" android:maxLines="2" />
            </LinearLayout>
            <LinearLayout android:gravity="center_horizontal" android:orientation="vertical" android:id="@id/silent_mode" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="14.0dip">
                <ImageButton android:id="@id/silent" android:background="@drawable/circle1" android:clickable="false" android:layout_width="wrap_content" android:layout_height="wrap_content" android:tint="#ffffffff" android:alpha="0.9" android:paddingStart="19.0dip" android:paddingEnd="19.0dip" />
                <TextView android:textSize="12.0sp" android:textColor="@color/global_action_text" android:gravity="center" android:id="@id/text_silent" android:paddingTop="10.0dip" android:layout_width="110.0dip" android:layout_height="wrap_content" android:maxLines="2" />
            </LinearLayout>
    		<LinearLayout android:gravity="center_horizontal" android:orientation="vertical" android:id="@id/power_action" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="14.0dip">
                <ImageButton android:id="@id/power" android:background="@drawable/circle1" android:clickable="false" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_lock_power" android:tint="#ffffffff" android:contentDescription="@string/global_action_poweroff" android:alpha="0.9" android:paddingStart="19.0dip" android:paddingEnd="19.0dip" />
                <TextView android:textSize="12.0sp" android:textColor="@color/global_action_text" android:gravity="center" android:id="@id/text_power" android:paddingTop="10.0dip" android:layout_width="110.0dip" android:layout_height="wrap_content" android:text="@string/global_action_poweroff" android:maxLines="2" />
            </LinearLayout>
        </LinearLayout>
        <LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="224.0dip" android:layout_centerHorizontal="true">
            <LinearLayout android:gravity="center_horizontal" android:orientation="vertical" android:id="@id/reset_action" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginEnd="14.0dip">
                <ImageButton android:id="@id/reset" android:background="@drawable/circle1" android:clickable="false" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_lock_reboot" android:tint="#ffffffff" android:contentDescription="@string/global_action_reset" android:alpha="0.9" android:paddingStart="19.0dip" android:paddingEnd="19.0dip" />
                <TextView android:textSize="12.0sp" android:textColor="@color/global_action_text" android:gravity="center" android:id="@id/text_reset" android:paddingTop="10.0dip" android:layout_width="110.0dip" android:layout_height="wrap_content" android:text="@string/global_action_reset" android:maxLines="2" />
            </LinearLayout>
            <LinearLayout android:gravity="center_horizontal" android:orientation="vertical" android:id="@id/recovery_action" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="14.0dip">
                <ImageButton android:id="@id/recovery" android:background="@drawable/circle1" android:clickable="false" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_lock_power" android:tint="#ffffffff" android:contentDescription="@string/global_action_recovery" android:alpha="0.9" android:paddingStart="19.0dip" android:paddingEnd="19.0dip" />
                <TextView android:textSize="12.0sp" android:textColor="@color/global_action_text" android:gravity="center" android:id="@id/text_recovery" android:paddingTop="10.0dip" android:layout_width="110.0dip" android:layout_height="wrap_content" android:text="@string/global_action_recovery" android:maxLines="2" />
            </LinearLayout>
    		<LinearLayout android:gravity="center_horizontal" android:orientation="vertical" android:id="@id/bootloader_action" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="14.0dip">
                <ImageButton android:id="@id/bootloader" android:background="@drawable/circle1" android:clickable="false" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_lock_power" android:tint="#ffffffff" android:contentDescription="@string/global_action_bootloader" android:alpha="0.9" android:paddingStart="19.0dip" android:paddingEnd="19.0dip" />
                <TextView android:textSize="12.0sp" android:textColor="@color/global_action_text" android:gravity="center" android:id="@id/text_bootloader" android:paddingTop="10.0dip" android:layout_width="110.0dip" android:layout_height="wrap_content" android:text="@string/global_action_bootloader" android:maxLines="2" />
            </LinearLayout>
        </LinearLayout>
    </RelativeLayout>

    It should be mentioned I simply reused the power button graphic for the additional buttons. You can customize the buttons by generating vector xml and replacing ic_lock_recovery/bootloader.xml.
    (If you do generate nice icons, please post them!)

    2. Add the appropriate IDs/strings/xml to framework-zte-res.apk
    - add to res/values/ids.xml
    Code:
    	<item type="id" name="recovery_action">false</item>
            <item type="id" name="bootloader_action">false</item>
    	<item type="id" name="recovery" />
    	<item type="id" name="bootloader" />
    	<item type="id" name="text_recovery" />
            <item type="id" name="text_bootloader" />

    - add to res/values/strings.xml
    Code:
    	<string name="global_action_recovery">Recovery</string>
    	<string name="global_action_bootloader">Bootloader</string>

    - in res/drawable, copy ic_lock_power.xml to ic_lock_recovery.xml, ic_lock_bootloader.xml (comment at end of #1 applies here)

    3. Build framework-zte-res.apk using apktool, which is nice enough to assign all the new IDs needed. Now decompile the new apk and open res/values/public.xml to obtain two IDs
    used for step 4 smali changes:

    Code:
        <public type="id" name="recovery" id="[COLOR="Red"]0x06060067[/COLOR]" />
        <public type="id" name="bootloader" id="[COLOR="red"]0x06060068[/COLOR]" />

    You must save those two IDs somewhere for the next step. If you don't, you risk bootlooping or worse!

    4. Our target for the actual code changes is GlobalActions.smali in services.odex. Search for '.method private createDialogMF40' and find the following code:
    Code:
        new-instance v6, Lcom/android/server/policy/GlobalActions$7;
    
        invoke-direct {v6, p0}, Lcom/android/server/policy/GlobalActions$7;-><init>(Lcom/android/server/policy/GlobalActions;\V
    
        invoke-virtual {v3, v6}, Landroid/view/View;->setOnClickListener(Landroid/view/View$OnClickListener;)V
    Just after that last line will be our insertion point for the following code:
    Code:
    iget-object v6, p0, Lcom/android/server/policy/GlobalActions;->contentView:Landroid/view/View;
    
        const v9, [COLOR="red"]0x6060067[/COLOR]
    
        invoke-virtual {v6, v9}, Landroid/view/View;->findViewById(I)Landroid/view/View;
    
        move-result-object v3
    
        .line 270
        .local v3, "recoveryAction":Landroid/view/View;
        new-instance v6, Lcom/android/server/policy/GlobalActions$19;
    
        invoke-direct {v6, p0}, Lcom/android/server/policy/GlobalActions$19;-><init>(Lcom/android/server/policy/GlobalActions;)V
    
        invoke-virtual {v3, v6}, Landroid/view/View;->setOnClickListener(Landroid/view/View$OnClickListener;)V
    
    	iget-object v6, p0, Lcom/android/server/policy/GlobalActions;->contentView:Landroid/view/View;
    
        const v9, [COLOR="red"]0x6060068[/COLOR]
    
        invoke-virtual {v6, v9}, Landroid/view/View;->findViewById(I)Landroid/view/View;
    
        move-result-object v3
    
        .line 270
        .local v3, "bootloaderAction":Landroid/view/View;
        new-instance v6, Lcom/android/server/policy/GlobalActions$20;
    
        invoke-direct {v6, p0}, Lcom/android/server/policy/GlobalActions$20;-><init>(Lcom/android/server/policy/GlobalActions;)V
    
    invoke-virtual {v3, v6}, Landroid/view/View;->setOnClickListener(Landroid/view/View$OnClickListener;)V

    5. Now we have associated our new buttons with GlobalActions$19 & 20 above. To create these two files, used GlobalActions$7.smali (which is the reboot code) as a template. Be sure to change any $7 to $19 / $20 in the appropriate files. Our last modifications are simple one-liners to direct the reboot behavior.

    Find 'const/4 v3, 0x0' around line 69 and change to:

    GlobalActions$19.smali:
    Code:
    const-string/jumbo v3, "recovery"

    GlobalActions$20.smali:
    Code:
    const-string/jumbo v3, "bootloader"

    Compile your changes and update services.jar. You are now ready to flash the new framework-zte-res.apk and services.jar to /system/framework. Reboot and cross your fingers!

    Version History:
    1.0(3/26/17): Initial release
    1.1 (3/29/17): Moved portrait layout up 80 pixels to center vertically
    8
    Here is a flashable for peeps to flash in recovery. I can mirror if needed.
    4
    11cdw0n.jpg


    Create some xml with android studio.

    Here are attached if you want to use them
    2
    You wouldn't be happen to already have a zip readily available to share :) With that knowledge would you be willing to look at that edits needed to get 3minit battery mod working? I tried it but the standard edits do not work, someone had got it working but pulled down how he did it :(. Anyways great thread thanks for the info!

    EDIT