[Galaxy Note 3 Android Development] Kamy:
Enable Torch Toggle in Settings

Integrate In Settings

edit 1: Smali's are updated to cover all TW devices thanks [MENTION=1042140]tdunham[/MENTION] :good:

edit 2: Smali's are updated for Android MM compatibilty thanks [MENTION=1042140]tdunham[/MENTION] [MENTION=4507636]edzamber[/MENTION] :good:

Decompile Settings

Download attached torch_materials.zip and paste them accordingly

Go to values folder open arrays.xml and check whether following arrays are availble if not add them

<string-array name="torchlight_timeout_entries">
<item>15 seconds</item>
<item>30 seconds</item>
<item>1 minute</item>
<item>2 minutes</item>
<item>10 minutes</item>
</string-array>
<string-array name="torchlight_timeout_values">
<item>15000</item>
<item>30000</item>
<item>60000</item>
<item>120000</item>
<item>600000</item>
</string-array>

Go to values folder open plurals.xml and check whether you have following plurals if not add them

</plurals>
<plurals name="torchlight_timeout_minutes">
<item quantity="other">%d minutes</item>
<item quantity="one">1 minute</item>
</plurals>
<plurals name="torchlight_timeout_seconds">
<item quantity="other">%d seconds</item>
<item quantity="one">1 second</item>
</plurals>

Go to values folder open strings.xml and check whether you have following strings if not add them

<string name="torchlight_settings">Torch light</string>
<string name="torchlight_settings_title">Torch light</string>
<string name="torchlight_summary">Turn on the torch light by pressing and holding the volume up key while the screen is off.</string>
<string name="torchlight_timeout_title">Torch light time-out</string>
<string name="torchlight_timeout_summary">After %1$s</string>

Go to xml folder, open device_headers.xml and add following line in red

[COLOR="Red"] </header>
<header android:icon="@drawable/ic_settings_torchlight" android:id="@id/torchlight_settings" android:title="@string/torchlight_settings" android:fragment="com.android.settings.torchlight.TorchlightSettings" />[/COLOR]
<header android:icon="@drawable/ic_settings_powersaving" android:id="@id/power_saving_mode" android:title="@string/power_saving_mode_title" android:fragment="com.android.settings.powersavingmode.MenuPowerSavingModeSettings" />

add red line below in display_settings_2013.xml.

<CheckBoxPreference android:title="@string/intelligent_sleep_title" android:key="smartscreen_stay" android:summary="@string/intelligent_sleep_summary" />
[COLOR="Red"]<PreferenceScreen android:title="Torchlight" android:key="[COLOR="red"]torchlight[/COLOR]" android:fragment="com.android.settings.torchlight.TorchlightSettings" />[/COLOR]
<CheckBoxPreference android:title="@string/smart_pause_title" android:key="smartscreen_pause" android:summary="@string/smart_pause_summary" />

Now it's time to create ids, so recompile and rename settings as settings_new to avoid confusion

Now decompile settings_new

Go to TorchlightSettings.smali

Open public.xml too and check what I noted beside every id, match ids accordingly

Recompile and profit >

Integrate in ROM Control

(MM)

<SwitchPreference
android:title="Torchlight"
android:key="[COLOR="Red"]torchlight_enable[/COLOR]"
android:summary="Turn on the torch light by pressing and holding the volume up key while the screen is off" android:defaultValue="0" />
<com.[COLOR="Red"]aryamod[/COLOR].romcontrol.prefs.MyListPreference
android:entries="@array/torchlight_timeout_entries"
android:title="@string/torchlight_timeout_title"
android:key="torchlight_timeout"
android:dependency="torchlight_enable"
android:entryValues="@array/torchlight_timeout_values" />

Add Auto Start Management

This mod would let you choose to prevent/allow selected apps of running on system startup.

Download attached zip and drop those files in your settings.

Now go to values open ids.xml and add following

<item type="id" name="autostarts_settings">false</item>
<item type="id" name="appName">false</item>
<item type="id" name="aryamod">false</item>

open strings.xml and add following:

<string name="autostarts_title">Autostarts</string>
<string name="autostarts_allowed">Has allowed</string>
<string name="autostarts_prohibited">Has prohibited</string>
<string name="autostarts_allow_progress_msg">Being restored boot, please wait...</string>
<string name="autostarts_prohibit_progress_msg">Prohibit boot, please wait...</string>
<string name="autostarts_empty_msg">No installation boot applications</string>
<string name="autostarts_optimize_empty_msg">No optimize the startup items</string>
<string name="autostarts_optimize_btn_title">Optimize the startup items</string>
<string name="autostarts_all_btn_title">Automatically Start All Applications</string>

You also need to add a header for it, which can be added anywhere in settings depending on your preference, I added in DEVICE tab like below:

Add line below in display_headers.xml.

<header android:icon="@drawable/ic_settings_autostarts" android:id="@id/aryamod" android:title="@string/autostarts_title" android:fragment="com.android.settings.autostarts.LewaManageAutostarts" />

Now it's time to produce ID, so recompile modified settings and decompile it again, go to autostart smali materials and check those IDs which I noted (starting with #<public type="...) in those smali, there might be several to check and match with your produced IDs.

How to enable UPSM for Note 3

In this guide we would mod service.jar and secsettings.apk, firstly download UPSM.zip and put EmergencyLauncher, EmergencyModeService and EmergencyProvider in app folder in attached zip.

service.jar

decompile service.jar and go to services\com\android\server

open SystemServer.smali and search for

.method static final startEmergencyModeService(Landroid/content/Context;)V

and change the entire method with following:

.method static final startEmergencyModeService(Landroid/content/Context;)V
.registers 6

:try_start_0
invoke-static {p0}, Lcom/sec/android/emergencymode/EmergencyManager;->getInstance(Landroid/content/Context;)Lcom/sec/android/emergencymode/EmergencyManager;

move-result-object v1

invoke-virtual {v1}, Lcom/sec/android/emergencymode/EmergencyManager;->readyEmergencyMode()V
:try_end_7
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_7} :catch_8

:goto_7
return-void

:catch_8
move-exception v0

const-string v2, "SystemServer"

new-instance v3, Ljava/lang/StringBuilder;

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

const-string v4, "Starting emergency service failed: "

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

move-result-object v3

invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

move-result-object v3

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

move-result-object v3

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

goto :goto_7
.end method

OK now UPSM is enabled but there is a issue that after disabling it some widgets would be removed from the home screen so we need to correct the service

go to services\com\android\server\appwidget

open AppWidgetServiceImpl.smali and search for following method

.method private deleteProviderLocked(Lcom/android/server/appwidget/AppWidgetServiceImpl$Provider;)V

Now change the entire method the one in zip attached

same smali search for

.method private queryIntentReceivers(Landroid/content/Intent;I)Ljava/util/List;

change the entire method the one in zip attached

Search for this method

.method private readProfileStateFromFileLocked(Ljava/io/FileInputStream;ILjava/util/List;)I

change the entire method the one in zip attached

SecSettings.apk

Next we need to enable and access UPSM launcher that depends on you whether you have your own rom customizer or would like to add it in settings, I couldn't find proper smali to enable it as stock but I tired adding it in settings as following

decompile secsettings and add this in id.xml

<item type="id" name="aryamod">false</item>

open display_headers.xml and add UPSM header everywhere you would like to be shown like this:

<header android:icon="@drawable/ic_settings_powersaving" android:id="@id/aryamod" android:title="@string/powersaving_ultra" android:key="ultra_powersaving" android:fragment="com.android.settings.powersavingmode.PowerSavingModeUltra" />