Friday, July 8, 2016

Theming mediatek-res.apk

I have been interested in theming an MTK 6592 mediatek phone (Infinix Hot Note x551) I have owned for quite a while.

I reached a point where I needed to decompile and recompile the mediatek-res.apk framework resource app.

I was using apktool version 2.1.1 and later on 2.2.0-a4270d-SNAPSHOT

I wanted to get rid of this notification item, every time you opened the Dialer, Contacts or Mms application. I found it annoying - asking every time to choose a default simcard, when I clearly wanted and is able to choose a line on calls, or outgoing SMSs.
Quote:

Sorry, cant post image links yet!!
After a few weeks of on-of/trial and error research, I realized that these could be accomplished by editing the mediatek-res.apk located in /system/framework/mediatek-res.

It decompiled ok, but could not compile after editing(again, trial-error).

These were the compilation errors I was getting: A tonne of errors concerning all the resources and their Id's:
HTML Code:

W: /home/*****/Desktop/mtk/mediatek-res/res/layout/account_five.xml:6: error: Error: No resource found that matches the given name (at 'id' with value '@id/account_five_img').
I read up on this error and one post here on XDA (didnt save the link, sorry) and also over at github, said to edit the apktool.yml file and include the framework ID for the mediatek-res.apk (already installed via 'apktool if mediatek-res.apk'). Its framework ID was 8. So I added it.
HTML Code:

usesFramework:
  ids:
  - 1

to
HTML Code:

usesFramework:
  ids:
  - 1
  - 8

On compilation, a ton of these new errors came up:

HTML Code:

W: /home/*****/Desktop/mtk/mediatek-res/res/values/styles.xml:3: error: Resource entry style/ImageSwitch is already defined in package com.mediatek.
Looked around furrther for quite sometime couldnt get a solution to this new errors. I continued on my trial and error ways and discovered that If edited the apktoo.yml file
HTML Code:

sharedLibrary: false
to
HTML Code:

sharedLibrary: true
and removed the mediatek-res framework ID from apktool.yml file, the errors were reduced to TWO!!

HTML Code:

W: /home/*****/Desktop/mtk/mediatek-res/res/values/public.xml:914: error: Public symbol ^attr-private/factor declared here is not defined.
HTML Code:

W: /home/*****/Desktop/mtk/mediatek-res/res/values/public.xml:915: error: Public symbol ^attr-private/scale declared here is not defined.
On investigating the error, I found out that indeed the two resources( ^attr-private/scale & ^attr-private/factor) were not defined in Ids.xml located in /res/values. I added the two to the bottom of the file,

HTML Code:

<item type="^attr-private" name="factor">false</item>
<item type="^attr-private" name="scale">false</item>

Also I renamed the file ^attr-privates.xml to ^attr-private.xml

On compilation, NO ERRORS!! and the app when pushed to system has no errors and all modification are reflected.

Because I am not very well versed with apktool and its inner workings, I don't know why this errors came up. I know this is a work-around, but for now it will have to do.

If this post saves you a few hours/days/weeks of research, hit thanks!!


from xda-developers http://ift.tt/29zDxXp
via IFTTT

No comments:

Post a Comment