FORUMS

HTC Delivering Ads Straight to Sense Home

HTC’s 2015 has been a year marked by a desperate search for revenue.The HTC One M9 … more

Galaxy S6 & Edge get €100 Price Cut—New Models Incoming

Samsung has dropped the price of both the Galaxy S6 and S6 Edge by … more

How To Port Fully Featured Sony Xperia Z4 Camera

Xperia Z4’s hardware may not impress, but its software is definitely … more

Experimental TWRP Available For Moto G 2015

XDA Senior Member squid2 has posted experimental builds of TWRP for the Moto G … more

[GUIDE][CM9-11] Add partition info in Settings.apk

724 posts
Thanks Meter: 1,437
 
Post Reply Subscribe to Thread Email Thread
Assalamualaikum
Hello guys, i want to share a simple guide with you

WHAT IS IT?
it's a guide to make a partition info in the Settings.apk
Source:

SCREENSHOT




Ok, let's start working on it

WHATS NEEDED?
- Brain
- A cup of coffe
- Use Apktool v 2.0.0 beta 9
- Settings.apk
- Attachment file

1. Decompile your Settings.apk

2. Download and extrack Attachment file and place it in the right place

3. Go to the ~\Settings\res\values\strings.xml
Add this code below before </resources>
Code:
    <string name="partition_info_title">Partition info</string>
    <string name="partition_info_system">/system</string>
    <string name="partition_info_data">/data</string>
    <string name="partition_info_cache">/cache</string>
    <string name="partition_info_sdcard">/sdcard (FAT)</string>
    <string name="partition_info_sdext">/sd-ext (EXT)</string>
    <string name="partition_info_used_of">/</string>
    <string name="nol">Unavailable</string>
</resources>
3. Go to the ~\Settings\res\xml\settings_headers.xml
Add this code below wherever you want inside settings_headers.xml
Code:
    <header android:icon="@drawable/partition_info" android:title="@string/partition_info_title">
        <intent android:targetPackage="com.android.settings" android:action="com.android.action.MAIN" android:targetClass="com.android.settings.ktech.PartitionInfo" />
    </header>
4. Compile your Settings.apk and decompile again

5. Go to ~\Settings\AndroidManifest.xml
Code:
        <activity android:label="@string/partition_info_title" android:name=".ktech.PartitionInfo">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.VOICE_LAUNCH"/>
            </intent-filter>
        </activity>
6. Go to the ~\Settings\smali\com\android\settings\ktech\Partit ionInfo.smali
Find & replace this code below with your public id

Code:
Line 110	0x7f080403	public type="string" name="partition_info_used_of"
Line 189	0x7f050043	public type="xml" name="partition_info"
7. Recompile Settings.apk then Sign it
8. Push it in your phone
Attached Files
File Type: zip [PARTITION INFO]Settings.zip - [Click for QR Code] (6.0 KB, 226 views)
Last edited by K_TECH; 19th October 2014 at 07:42 PM.
The Following 7 Users Say Thank You to K_TECH For This Useful Post: [ View ]
 
 
22nd October 2014, 07:48 PM |#2  
G.M.L's Avatar
Senior Member
Flag Thessaloniki
Thanks Meter: 173
 
More
hi i have one problem i make all the steps and im getting fc of settings when im pushing ''partition info'' and then i see that after decompile (the second decompile) the partition_info is in pyblic type drawable and not in pyblic type xml im trying 5 times but nothing (sorry for my bad english)
23rd October 2014, 01:55 AM |#3  
K_TECH's Avatar
OP Recognized Contributor
Flag Sidoarjo
Thanks Meter: 1,437
 
More
Quote:
Originally Posted by G.M.L

hi i have one problem i make all the steps and im getting fc of settings when im pushing ''partition info'' and then i see that after decompile (the second decompile) the partition_info is in pyblic type drawable and not in pyblic type xml im trying 5 times but nothing (sorry for my bad english)

Post your log here
23rd October 2014, 04:25 AM |#4  
G.M.L's Avatar
Senior Member
Flag Thessaloniki
Thanks Meter: 173
 
More
Here is it
Attached Files
File Type: txt log.txt - [Click for QR Code] (2.4 KB, 27 views)
25th October 2014, 07:48 AM |#5  
G.M.L's Avatar
Senior Member
Flag Thessaloniki
Thanks Meter: 173
 
More
OK I made it I changed the icon name in drawable-hdpi and after decomplile (the second time) in public the names are correct thanks k_tech!!!!!!

G.M.L.
25th October 2014, 06:11 PM |#6  
K_TECH's Avatar
OP Recognized Contributor
Flag Sidoarjo
Thanks Meter: 1,437
 
More
Quote:
Originally Posted by G.M.L

OK I made it I changed the icon name in drawable-hdpi and after decomplile (the second time) in public the names are correct thanks k_tech!!!!!!

G.M.L.

Ok, good job
The Following 2 Users Say Thank You to K_TECH For This Useful Post: [ View ]
13th November 2014, 05:52 PM |#7  
Senior Member
Flag Kiev
Thanks Meter: 30
 
More
Thx sir, its work on my LG P713 (4.1.2)
22nd November 2014, 01:24 PM |#8  
D2Y aka E's Avatar
Senior Member
Flag muara wahau (borneo)
Thanks Meter: 74
 
More
Thx sir...
4th January 2015, 07:22 PM |#9  
Senior Member
Flag Pune
Thanks Meter: 23
 
More
step6 is little confusing....could u plz be in detail.
4th January 2015, 08:19 PM |#10  
G.M.L's Avatar
Senior Member
Flag Thessaloniki
Thanks Meter: 173
 
More
Quote:
Originally Posted by rrajesh011

step6 is little confusing....could u plz be in detail.

Open smali/com/android/settings/k_tech/partitioninfo.smali and leave it open
Open value/public.xml and find
type=string name=partition_info_used_of id=this number copy and paste to partition info.smali in line 1100
And
type=xml name=partition_info id=this number copy and paste in partition info.Smali in line 1890
Compile and its ready!!!

G.M.L.
The Following User Says Thank You to G.M.L For This Useful Post: [ View ]
5th January 2015, 08:56 AM |#11  
Senior Member
Flag Pune
Thanks Meter: 23
 
More
Quote:
Originally Posted by G.M.L

Open smali/com/android/settings/k_tech/partitioninfo.smali and leave it open
Open value/public.xml and find
type=string name=partition_info_used_of id=this number copy and paste to partition info.smali in line 1100
And
type=xml name=partition_info id=this number copy and paste in partition info.Smali in line 1890
Compile and its ready!!!

G.M.L.

this is my partitioninfo.smali i didnot find line 189. i found line 110 but where to add public id.
Code:
.class public Lcom/android/settings/ktech/PartitionInfo;
.super Landroid/preference/PreferenceActivity;
.source "PartitionInfo.java"


# instance fields
.field private extfsIsMounted:Z

.field private mCachePartSize:Landroid/preference/Preference;

.field private mDataPartSize:Landroid/preference/Preference;

.field private mSDCardPartEXTSize:Landroid/preference/Preference;

.field private mSDCardPartFATSize:Landroid/preference/Preference;

.field private mSystemPartSize:Landroid/preference/Preference;


# direct methods
.method public constructor <init>()V
    .locals 1

    .prologue
    .line 45
    invoke-direct {p0}, Landroid/preference/PreferenceActivity;-><init>()V

    .line 60
    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/android/settings/ktech/PartitionInfo;->extfsIsMounted:Z

    return-void
.end method

.method private ObtainFSPartSize(Ljava/lang/String;)Ljava/lang/String;
    .locals 11
    .param p1, "PartitionPath"    # Ljava/lang/String;

    .prologue
    .line 103
    new-instance v4, Ljava/io/File;

    invoke-direct {v4, p1}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 104
    .local v4, "extraPath":Ljava/io/File;
    new-instance v5, Landroid/os/StatFs;

    invoke-virtual {v4}, Ljava/io/File;->getPath()Ljava/lang/String;

    move-result-object v7

    invoke-direct {v5, v7}, Landroid/os/StatFs;-><init>(Ljava/lang/String;)V

    .line 105
    .local v5, "extraStat":Landroid/os/StatFs;
    invoke-virtual {v5}, Landroid/os/StatFs;->getBlockSize()I

    move-result v7

    int-to-long v0, v7

    .line 106
    .local v0, "eBlockSize":J
    invoke-virtual {v5}, Landroid/os/StatFs;->getBlockCount()I

    move-result v7

    int-to-long v2, v7

    .line 107
    .local v2, "eTotalBlocks":J
    mul-long v7, v2, v0

    invoke-virtual {v5}, Landroid/os/StatFs;->getAvailableBlocks()I

    move-result v9

    int-to-long v9, v9

    mul-long/2addr v9, v0

    sub-long/2addr v7, v9

    invoke-static {p0, v7, v8}, Landroid/text/format/Formatter;->formatFileSize(Landroid/content/Context;J)Ljava/lang/String;

    move-result-object v6

    .line 108
    .local v6, "retstr":Ljava/lang/String;
    new-instance v7, Ljava/lang/StringBuilder;

    invoke-direct {v7}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v7, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    const-string v8, "  "

    invoke-virtual {v7, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    invoke-virtual {p0}, Lcom/android/settings/ktech/PartitionInfo;->getResources()Landroid/content/res/Resources;

    move-result-object v8

    const v9, 0x7f080403

    invoke-virtual {v8, v9}, Landroid/content/res/Resources;->getString(I)Ljava/lang/String;

    move-result-object v8

    invoke-virtual {v7, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    const-string v8, "  "

    invoke-virtual {v7, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    invoke-virtual {v7}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v6

    .line 109
    new-instance v7, Ljava/lang/StringBuilder;

    invoke-direct {v7}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v7, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    mul-long v8, v2, v0

    invoke-static {p0, v8, v9}, Landroid/text/format/Formatter;->formatFileSize(Landroid/content/Context;J)Ljava/lang/String;

    move-result-object v8

    invoke-virtual {v7, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    invoke-virtual {v7}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v6

    .line 110
    return-object v6
.end method


# virtual methods
.method public fileExists(Ljava/lang/String;)Z
    .locals 2
    .param p1, "filename"    # Ljava/lang/String;

    .prologue
    .line 114
    new-instance v0, Ljava/io/File;

    invoke-direct {v0, p1}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 115
    .local v0, "f":Ljava/io/File;
    invoke-virtual {v0}, Ljava/io/File;->exists()Z

    move-result v1

    return v1
.end method

.method protected onCreate(Landroid/os/Bundle;)V
    .locals 5
    .param p1, "icicle"    # Landroid/os/Bundle;

    .prologue
    const/4 v4, 0x1

    .line 64
    invoke-super {p0, p1}, Landroid/preference/PreferenceActivity;->onCreate(Landroid/os/Bundle;)V

    .line 66
    const v2, 0x7f050043

    invoke-virtual {p0, v2}, Lcom/android/settings/ktech/PartitionInfo;->addPreferencesFromResource(I)V

    .line 68
    invoke-virtual {p0}, Lcom/android/settings/ktech/PartitionInfo;->getPreferenceScreen()Landroid/preference/PreferenceScreen;

    move-result-object v1

    .line 70
    .local v1, "prefSet":Landroid/preference/PreferenceScreen;
    const-string v2, "system_part_info"

    invoke-virtual {v1, v2}, Landroid/preference/PreferenceScreen;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

    move-result-object v2

    iput-object v2, p0, Lcom/android/settings/ktech/PartitionInfo;->mSystemPartSize:Landroid/preference/Preference;

    .line 71
    const-string v2, "data_part_info"

    invoke-virtual {v1, v2}, Landroid/preference/PreferenceScreen;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

    move-result-object v2

    iput-object v2, p0, Lcom/android/settings/ktech/PartitionInfo;->mDataPartSize:Landroid/preference/Preference;

    .line 72
    const-string v2, "cache_part_info"

    invoke-virtual {v1, v2}, Landroid/preference/PreferenceScreen;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

    move-result-object v2

    iput-object v2, p0, Lcom/android/settings/ktech/PartitionInfo;->mCachePartSize:Landroid/preference/Preference;

    .line 73
    const-string v2, "sdcard_part_info_fat"

    invoke-virtual {v1, v2}, Landroid/preference/PreferenceScreen;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

    move-result-object v2

    iput-object v2, p0, Lcom/android/settings/ktech/PartitionInfo;->mSDCardPartFATSize:Landroid/preference/Preference;

    .line 74
    const-string v2, "sdcard_part_info_ext"

    invoke-virtual {v1, v2}, Landroid/preference/PreferenceScreen;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

    move-result-object v2

    iput-object v2, p0, Lcom/android/settings/ktech/PartitionInfo;->mSDCardPartEXTSize:Landroid/preference/Preference;

    .line 76
    const-string v2, "/dev/block/mmcblk0p2"

    invoke-virtual {p0, v2}, Lcom/android/settings/ktech/PartitionInfo;->fileExists(Ljava/lang/String;)Z

    move-result v2

    if-ne v2, v4, :cond_0

    .line 77
    const-string v2, "PartitionInfo"

    const-string v3, "sd: ext partition mounted"

    invoke-static {v2, v3}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 78
    iput-boolean v4, p0, Lcom/android/settings/ktech/PartitionInfo;->extfsIsMounted:Z

    .line 84
    :goto_0
    :try_start_0
    iget-object v2, p0, Lcom/android/settings/ktech/PartitionInfo;->mSystemPartSize:Landroid/preference/Preference;

    const-string v3, "/system"

    invoke-direct {p0, v3}, Lcom/android/settings/ktech/PartitionInfo;->ObtainFSPartSize(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Landroid/preference/Preference;->setSummary(Ljava/lang/CharSequence;)V

    .line 85
    iget-object v2, p0, Lcom/android/settings/ktech/PartitionInfo;->mDataPartSize:Landroid/preference/Preference;

    const-string v3, "/data"

    invoke-direct {p0, v3}, Lcom/android/settings/ktech/PartitionInfo;->ObtainFSPartSize(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Landroid/preference/Preference;->setSummary(Ljava/lang/CharSequence;)V

    .line 86
    iget-object v2, p0, Lcom/android/settings/ktech/PartitionInfo;->mCachePartSize:Landroid/preference/Preference;

    const-string v3, "/cache"

    invoke-direct {p0, v3}, Lcom/android/settings/ktech/PartitionInfo;->ObtainFSPartSize(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Landroid/preference/Preference;->setSummary(Ljava/lang/CharSequence;)V

    .line 87
    iget-object v2, p0, Lcom/android/settings/ktech/PartitionInfo;->mSDCardPartFATSize:Landroid/preference/Preference;

    const-string v3, "/sdcard"

    invoke-direct {p0, v3}, Lcom/android/settings/ktech/PartitionInfo;->ObtainFSPartSize(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Landroid/preference/Preference;->setSummary(Ljava/lang/CharSequence;)V

    .line 89
    iget-boolean v2, p0, Lcom/android/settings/ktech/PartitionInfo;->extfsIsMounted:Z

    if-ne v2, v4, :cond_1

    .line 90
    iget-object v2, p0, Lcom/android/settings/ktech/PartitionInfo;->mSDCardPartEXTSize:Landroid/preference/Preference;

    const-string v3, "/external_sd"

    invoke-direct {p0, v3}, Lcom/android/settings/ktech/PartitionInfo;->ObtainFSPartSize(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Landroid/preference/Preference;->setSummary(Ljava/lang/CharSequence;)V
    :try_end_0
    .catch Ljava/lang/IllegalArgumentException; {:try_start_0 .. :try_end_0} :catch_0

    .line 99
    :goto_1
    return-void

    .line 80
    :cond_0
    const-string v2, "PartitionInfo"

    const-string v3, "sd: ext partition not mounted"

    invoke-static {v2, v3}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_0

    .line 92
    :cond_1
    :try_start_1
    iget-object v2, p0, Lcom/android/settings/ktech/PartitionInfo;->mSDCardPartEXTSize:Landroid/preference/Preference;

    const/4 v3, 0x0

    invoke-virtual {v2, v3}, Landroid/preference/Preference;->setEnabled(Z)V
    :try_end_1
    .catch Ljava/lang/IllegalArgumentException; {:try_start_1 .. :try_end_1} :catch_0

    goto :goto_1

    .line 95
    :catch_0
    move-exception v0

    .line 96
    .local v0, "e":Ljava/lang/IllegalArgumentException;
    invoke-virtual {v0}, Ljava/lang/IllegalArgumentException;->printStackTrace()V

    goto :goto_1
.end method

Read More
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes