Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[MOD][GUIDE][GB] WIFI & BT ON/OFF Switches on Settings ***HOT***

OP Sniper Killer

5th August 2013, 01:30 PM   |  #1  
Sniper Killer's Avatar
OP Recognized Contributor
Flag Tirana, Albania
Thanks Meter: 3,012
 
1,269 posts
Join Date:Joined: Dec 2012
More
Hey dudes!
Ace-I Team is back with a new guide.
One of the most advanced ICS Features now comes on Gingerbread! Admit it, Everyone has been attracted by this feature! That's why : THIS IS THE MOST WANTED GUIDE FOR GINGERBREAD DEVICES EVER!!


Wifi and bluetooth ON/OFF Switches on Settings!

Quote:

Requirements :
-APK Multi Tool
-Notepad++
-Sources on the attachments
-High Smali & xml knowledge
-Brain
-Patience

Let's go!


Quote:

PART I


1. Decompile Settings.apk

2. Extract the sources. Copy switch_holo_dark.xml from sources and paste it on drawable folder.

3. Copy the PNGs from the sources and paste them on drawable-mdpi folder.

4. Copy icon_checkbox_preference.xml from the sources and paste it on layout folder.

5. Go to res/values/styles.xml.
Paste this text on the end of the file before

Code:
<style name="Switch">
        <item name="android:checkboxStyle">@style/Widget.CompoundButton.CheckBox.Holo.Dark</item>
    </style>
    <style name="Widget.CompoundButton.CheckBox.Holo.Dark" parent="@android:style/Widget.CompoundButton.CheckBox">
        <item name="android:button">@drawable/switch_holo_dark</item>
    </style>
6. Go to res/values/public.xml
Paste this text on the end of he file before
Code:
<public type="layout" name="icon_checkbox_preference" id="0x7f03005a" />
</resources>
7. Go to xml/Settings.xml
Replace this :



With this :
Code:
<com.android.settings.IconCheckBoxPreference android:title="WIFI" android:key="toggle_wifi" settings:icon="@drawable/ic_settings_wireless" />
    <com.android.settings.IconCheckBoxPreference android:title="Bluetooth" android:key="toggle_bluetooth" settings:icon="@drawable/ic_settings_bluetooth2" />
After editing it will look like this :



8. Recompile Settings.

Quote:

PART II

1. Decompile Settings.apk again

2. Go to smali/com/android/settings

3. Copy icon_checkbox_preference.smali from the source on the that folder.

4. Open R$Styleable

Quote:

- Find :

Code:
# static fields
.field public static final BatteryHistoryChart:[I
Below that paste :
Code:
.field public static final IconPreference:[I
.field public static final IconPreference_icon:I

Quote:

- Find :

Code:
    const v1, 0x7f010001

    aput v1, v0, v2
Below that paste :
Code:
    sput-object v0, Lcom/android/settings/R$styleable;->IconPreference:[I

    .line 6450
    new-array v0, v3, [I

    const v1, 0x7f010001

    aput v1, v0, v2
After the edit it will look like this :
Code:
    const v1, 0x7f010001

    aput v1, v0, v2

    sput-object v0, Lcom/android/settings/R$styleable;->IconPreference:[I

    .line 6450
    new-array v0, v3, [I

    const v1, 0x7f010001

    aput v1, v0, v2

    sput-object v0, Lcom/android/settings/R$styleable;->IconPreferenceScreen:[I

5. Open Settings.smali

Quote:

Quote:

Below # instance fields paste this text :

Code:
.field private mBtEnabler:Lcom/android/settings/bluetooth/BluetoothEnabler;

.field private mWifiEnabler:Lcom/android/settings/wifi/WifiEnabler;
2 Lines Above # instance fields paste this text :

Code:
# static fields
.field private static final KEY_TOGGLE_BLUETOOTH:Ljava/lang/String; = "toggle_bluetooth"

.field private static final KEY_TOGGLE_WIFI:Ljava/lang/String; = "toggle_wifi"
After edition it will look like this :

Code:
# static fields
.field private static final KEY_TOGGLE_BLUETOOTH:Ljava/lang/String; = "toggle_bluetooth"

.field private static final KEY_TOGGLE_WIFI:Ljava/lang/String; = "toggle_wifi"


# instance fields

.field private mBtEnabler:Lcom/android/settings/bluetooth/BluetoothEnabler;

.field private mWifiEnabler:Lcom/android/settings/wifi/WifiEnabler;

.field private mIntentReceiver:Landroid/content/BroadcastReceiver
;

- Find :
Code:
invoke-virtual {p0, v4}, Lcom/android/settings/Settings;->addPreferencesFromResource(I)V
- Below that paste this text :
Code:
    const-string v0, "toggle_wifi"

    invoke-virtual {p0, v0}, Lcom/android/settings/Settings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

    move-result-object v0

    check-cast v0, Landroid/preference/CheckBoxPreference;

    new-instance v1, Lcom/android/settings/wifi/WifiEnabler;

    invoke-direct {v1, p0, v0}, Lcom/android/settings/wifi/WifiEnabler;->(Landroid/content/Context;Landroid/preference/CheckBoxPreference;)V

    iput-object v1, p0, Lcom/android/settings/Settings;->mWifiEnabler:Lcom/android/settings/wifi/WifiEnabler;

    const-string v0, "toggle_bluetooth"

    invoke-virtual {p0, v0}, Lcom/android/settings/Settings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

    move-result-object v0

    check-cast v0, Landroid/preference/CheckBoxPreference;

    new-instance v1, Lcom/android/settings/bluetooth/BluetoothEnabler;

    invoke-direct {v1, p0, v0}, Lcom/android/settings/bluetooth/BluetoothEnabler;->(Landroid/content/Context;Landroid/preference/CheckBoxPreference;)V

    iput-object v1, p0, Lcom/android/settings/Settings;->mBtEnabler:Lcom/android/settings/bluetooth/BluetoothEnabler;
- Find :
Code:
.method protected onPause()V
- Replace the whole method with this method :

Code:
.method protected onPause()V
    .locals 1

    invoke-super {p0}, Landroid/preference/PreferenceActivity;->onPause()V

    iget-object v0, p0, Lcom/android/settings/Settings;->mWifiEnabler:Lcom/android/settings/wifi/WifiEnabler;

    invoke-virtual {v0}, Lcom/android/settings/wifi/WifiEnabler;->pause()V

    iget-object v0, p0, Lcom/android/settings/Settings;->mBtEnabler:Lcom/android/settings/bluetooth/BluetoothEnabler;

    invoke-virtual {v0}, Lcom/android/settings/bluetooth/BluetoothEnabler;->pause()V

    iget-object v0, p0, Lcom/android/settings/Settings;->mIntentReceiver:Landroid/content/BroadcastReceiver;

    invoke-virtual {p0, v0}, Lcom/android/settings/Settings;->unregisterReceiver(Landroid/content/BroadcastReceiver;)V

    .line 78
    return-void
.end method
- Find :
Code:
   .line 65
    invoke-super {p0}, Landroid/preference/PreferenceActivity;->onResume()V
- Below that paste this text :
Code:
    iget-object v1, p0, Lcom/android/settings/Settings;->mWifiEnabler:Lcom/android/settings/wifi/WifiEnabler;

    invoke-virtual {v1}, Lcom/android/settings/wifi/WifiEnabler;->resume()V

    iget-object v1, p0, Lcom/android/settings/Settings;->mBtEnabler:Lcom/android/settings/bluetooth/BluetoothEnabler;

    invoke-virtual {v1}, Lcom/android/settings/bluetooth/BluetoothEnabler;->resume()V

8. Follow Part III by iamareebjamal

Attached Thumbnails
Click image for larger version

Name:	Unchanged.jpg
Views:	1391
Size:	12.1 KB
ID:	2166486  
Last edited by Sniper Killer; 29th October 2013 at 11:27 PM.
The Following 37 Users Say Thank You to Sniper Killer For This Useful Post: [ View ]
5th August 2013, 01:33 PM   |  #2  
iamareebjamal's Avatar
Recognized Contributor / Themer
Flag Batcave
Thanks Meter: 4,778
 
3,630 posts
Join Date:Joined: Aug 2012
More
Part III : Adding switched and disabling signature check
Adding Buttons in Settings.apk by custom style and Disabling Signature Verification


Quote:

If you were successful in accomplishing the above procedure. Be happy, but not too much because the key part is left, and that is - Adding those custom ICS Buttons in Settings by overriding the default GB tickview. Or else, you will get checkboxes instead of Switches. You don't wanna do that? Do you?

Enough talking let's roll

Quote:

Part III (a)

1. Open AndroidManifest.xml located in decompiled Settings.apk

2. Find this:

Code:
<activity android:label="@string/settings_label_launcher" android:name="Settings"
3. Modify it like this:

Code:
<activity android:theme="@style/Switch" android:label="@string/settings_label_launcher" android:name="Settings"
It means you have to add android:theme="@style/Switch" between <activity and android:label="@string/settings_label_launcher"

4. Save the file.

5. Now, as you have edited the AndroidManifest.xml . Android system won't accept your app and refuse to load it as its signature should be changed.

So, sign the recompile the apk and sign it

6. But again, there's one little problem. Android doesn't load system apps with modified signatures for stability of OS, so your app will disappear from app drawer and if you try to open it from any other source, it will say "App isn't installed"

So?

So, sign ALL system apps and framework apps with same key

...OR...

Follow the workaround in (b) part




You may have accomplished the above thing but still something needs to be done to complete the procedure. Believe me, it's the last thing
Android System doesn't accept the apks that are signed by default. So we, here, will render that option obsolete by editing some files.

Let's start


Quote:

Part III (b)

1. Pull services.jar from /system/framework/

2. Extract it's classes.dex and decompile it via my ROM Tolls

3. Go to com/android/server/PackageManagerService.smali

4. Open it and search for

Code:
.method checkSignaturesLP([Landroid/content/pm/Signature;[Landroid/content/pm/Signature;)I
5. Look below it, you should see something like this

Code:
    .prologue
    .line 1936

    if-nez p1, :cond_1
6. Add this below .line 1936

Code:
    const/4 v6, 0x0
    return v6
Finally, it should look like this:

Code:
.method checkSignaturesLP([Landroid/content/pm/Signature;[Landroid/content/pm/Signature;)I
    .locals 7
    .parameter "s1"
    .parameter "s2"

    .prologue
    .line 1936
    const/4 v6, 0x0

    return v6

    if-nez p1, :cond_1
7. Save the file and recompile classes.dex and then add it to services.jar

8. Now push services.jar and Settings.apk in their respective places and reboot the phone so that signature check changes are affected

9. Enjoy



Last edited by iamareebjamal; 5th August 2013 at 03:55 PM.
The Following 28 Users Say Thank You to iamareebjamal For This Useful Post: [ View ]
5th August 2013, 01:33 PM   |  #3  
Sniper Killer's Avatar
OP Recognized Contributor
Flag Tirana, Albania
Thanks Meter: 3,012
 
1,269 posts
Join Date:Joined: Dec 2012
More
Sources
The source : http://www.mediafire.com/download.php?bvcj2fa8r1lv0h7

PNG source only :

- SGS3 : Adding ASAP
-JellyBean/Holo : Adding ASAP

F.A.Q

Quote:

Q: SGS3 Switches are small even if the image is large enough?

Solution :

Quote:

1. Go to Res/layout/icon_check box_preference.xml
2. Find android:layout_width="68.0 px"
3. Change it to "85.0 px"
4. Find android:layout_height="20.0px"
5. Change it to "40.0 px"

Actually changing those pixels will not resize the switch pngs. It will make height's and width's available space larger, therefore switches can be strechted easily on their original size.

Quote:

Q: On Part II, when editing .method onPause()V, should I delete only the title "method on pause()V" or from method on pause to .end method?

Solution :

You must replace whole method. Delete the on pause()V method then place the code I have written on the same place.

Last edited by Sniper Killer; 19th August 2013 at 09:04 PM.
The Following 15 Users Say Thank You to Sniper Killer For This Useful Post: [ View ]
5th August 2013, 01:34 PM   |  #4  
iamareebjamal's Avatar
Recognized Contributor / Themer
Flag Batcave
Thanks Meter: 4,778
 
3,630 posts
Join Date:Joined: Aug 2012
More
Screenshots:


SGS3



Jelly Bean












Credits:



Quote:

Biggest biggest thanks and full credits to b16h22 for making this awesome mod and his open source heart to share it with us and guiding us through on how to accomplish it and giving us permissions to make this thread
loSconosciuto for Signature Verification Disabling Guide

Quote:

Sniper Killer for starting this initiative
iamareebjamal for fixing the AndroidManifest to display the switches in Settings and applying idea of signature verification

Ace-i Team for bringing this to you
Last edited by iamareebjamal; 5th August 2013 at 04:29 PM.
The Following 18 Users Say Thank You to iamareebjamal For This Useful Post: [ View ]
5th August 2013, 02:59 PM   |  #5  
brijeshep's Avatar
Recognized Contributor
Flag ►KERALA◄
Thanks Meter: 2,217
 
722 posts
Join Date:Joined: Aug 2012
More
Angry
More UI Changes for Ace-i... Thanks @Sniper Killer
.....
Give a screenshot of those Wifi & BT ON/OFF Switches on Settings in the OP...
Last edited by brijeshep; 5th August 2013 at 03:14 PM.
The Following 3 Users Say Thank You to brijeshep For This Useful Post: [ View ]
5th August 2013, 03:05 PM   |  #6  
iamareebjamal's Avatar
Recognized Contributor / Themer
Flag Batcave
Thanks Meter: 4,778
 
3,630 posts
Join Date:Joined: Aug 2012
More
Quote:
Originally Posted by brijeshep

More UI Changes for Ace-i... Thanks @Sniper Killer
.....
Give a screenshot of those Wifi & BT ON/OFF Switches on Settings in the OP...

Y u only Thank him

Wait till the guide is complete
The Following 7 Users Say Thank You to iamareebjamal For This Useful Post: [ View ]
5th August 2013, 03:18 PM   |  #7  
Sniper Killer's Avatar
OP Recognized Contributor
Flag Tirana, Albania
Thanks Meter: 3,012
 
1,269 posts
Join Date:Joined: Dec 2012
More
Quote:
Originally Posted by brijeshep

More UI Changes for Ace-i... Thanks @Sniper Killer
.....
Give a screenshot of those Wifi & BT ON/OFF Switches on Settings in the OP...

SS on the OP.
And btw, thank areeb too as he found the fix of the image. Follow the tut later. I will upload the sources when areeb will complete editing his post.
5th August 2013, 03:28 PM   |  #8  
misha1996's Avatar
Senior Member
Flag Voskresensk
Thanks Meter: 172
 
383 posts
Join Date:Joined: Jan 2013
More
Cant wait

Sent from my GT-S5830i using xda premium
5th August 2013, 03:44 PM   |  #9  
Powerhouse's Avatar
Senior Member
Thanks Meter: 1,991
 
796 posts
Join Date:Joined: Mar 2013
This is what i am talking about ...wooohoo

All the devs from ace-i section Rockz
The Following 2 Users Say Thank You to Powerhouse For This Useful Post: [ View ]
5th August 2013, 05:18 PM   |  #10  
Hitesh2626's Avatar
Recognized Contributor
Flag ☆◢Mumbai◣☆
Thanks Meter: 1,429
 
1,813 posts
Join Date:Joined: Feb 2013
More
Nice team work .
Last edited by Hitesh2626; 7th December 2013 at 12:31 PM.

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

Advanced Search
Display Modes