[Q] Change Lock Screen Timeout - Droid Eris Q&A, Help & Troubleshooting

I have CM7 installed... I know there are settings for screen timeout under display, and CM7 settings allow you to specify the delay for the screen to actually lock. But what about when the screen is locked, you turn it on to check the time and it shuts off after 5 secs. Can this be changed?

Edit: Here's a list of important posts so people don't have to read the entire thread...
Background Info
Step-by-step guide for windows
Allow .jar files to be seen in APK Manager
How-to deODEX android.policy.jar for ODEXed ROMs
How-to for linux/mac(will make a better guide once I finish porting the APK Manager tool from Windows)
Old Stuff:There's not a setting to change the lock screen timeout but I got to looking around and think I found where it can be changed. The stuff I found pointed to android.policy.jar which is located in /system/framework so I adb pulled it and then decoded it using apktool. Some smali files contain hex values of 0x1388 equals 5000 in decimal where 5000ms = 5s. So one of those should be what we want to change. I'm going to try figuring out which one to change, set it to 10s = 10000ms = 0x2710. If it works for me, I can describe how to do it yourself in better detail and/or post a modified android.policy.jar with the timeout you would like.

Edit: I started a thread about this in the Eris dev forum and removed the attached files from here. PM me or post in one of these two threads if you have questions or would like me to modify and send you a custom android.policy.jar
http://forum.xda-developers.com/showthread.php?t=1079844
I successfully increased the default 5s timeout when you wake the phone but don't unlock. If you want to test it out, download one of the attached zip files corresponding to the timeout you would like to have(10s or 30s). Extract android.policy.jar from the zip file and follow either the ADB or Root Explorer or Terminal Emulator instructions below.
If using ADB:
Code:
adb remount
adb shell
cd /system/framework
mv android.policy.jar android.policy.jar.bak
exit
adb push android.policy.jar /system/framework
adb shell
cd /system/framework
chown 0:0 android.policy.jar
chmod 644 android.policy.jar
#reboot to recovery#
#wipe both cache and dalvik-cache#
#reboot#
If using Root Explorer on phone:
mount system as r/w
rename original android.policy.jar in /system/framework to android.policy.jar.bak
move modified android.policy.jar to /system/framework
change owner: owner = 0 - root & group = 0 - root
change permissions: rw-r--r--
#reboot to recovery#
#wipe both cache and dalvik-cache#
#reboot#
Click to expand...
Click to collapse
If using Terminal Emulator on phone:
Code:
mount -o remount,rw /dev/block/mtdblock3 /system
mv /system/framework/android.policy.jar /system/framework/android.policy.jar.bak
mv /PATH/TO/NEW/android.policy.jar /system/framework
cd /system/framework
chown 0:0 android.policy.jar
chmod 644 android.policy.jar
#reboot to recovery#
#wipe both cache and dalvik-cache#
#reboot#
Later tonight or tomorrow I will post a how-to so anyone can make the necessary modifications themselves. That should allow for other devices/ROMs to modify theirs as well since it will be customized to their phone.
I've only tested this on my Eris running GSB v3.1 - Gingerbread 2.3.4 - CM 7.1.0 RC0. Be sure to make a NAND backup and a backup of android.policy.jar as I can't guarantee this will work for you. If you have problems or just want to switch back to the original 5s timeout, replace the modified android.policy.jar with the android.policy.jar backup, wipe cache & dalvik-cache, and reboot or restore from the NAND backup you created.

I'm really surprised no one has brought this idea up before..well glad I had a chance to give you something to dig into and explore some more. I haven't done any editing to system files like this before so I might be posting back with some questions. Thanks for the info..I'll let you know how it goes!

When I plug my phone in it doesnt seem to be going into debugging mode. I have that option checked for it to enable when USB is plugged in but the only icon showing is the USB icon.
I say this because when I run adb devices its not listing my device..also running adb shell it says error: device not found
I havent tried running the adb shell since I flashed to CM7..is there something I need to do differently with this ROM?

thetornado said:
When I plug my phone in it doesnt seem to be going into debugging mode. I have that option checked for it to enable when USB is plugged in but the only icon showing is the USB icon.
I say this because when I run adb devices its not listing my device..also running adb shell it says error: device not found
I havent tried running the adb shell since I flashed to CM7..is there something I need to do differently with this ROM?
Click to expand...
Click to collapse
The debugging notification will only show up if the option for "USB debugging notify" is also checked in Settings->Applications->Development. Not sure why it wouldn't be able to find your phone especially since it sounds like you had it working fine before. What version of adb do you have? I'm using v1.0.26 and never had any problem. You can check the version with the command "adb version". You could also try using adbWireless which would allow you to not have it hooked to your computer with the USB cable.

Scratch that last post..I got it working in ADB Shell
I downloaded the APK tool and moved the files to C:\Windows
Ran this successful: adb pull /system/framework/android.policy.jar
Problem with: apktool d android.policy.jar out - error saying it couldn't find apktool. I went to restart my phone to see if that was an issue and now its hung on the white android screen and wont boot up
Thoughts?

You didn't actually modify anything on the phone right? And didn't push anything to it either? If not, nothing would have changed and it shouldn't be having a problem booting. Try "adb reboot recovery", wipe cache & dalvik-cache then reboot. If you can't run adb commands...pull the battery, put it back in, power it on and hold volume up + power to get into recovery. If something was modified, use adb to revert the modded files back to the originals or restore with a NAND backup if you made one.
Edit: As for apktool not being found, it sounds like apktool is not in your PATH. The Windows folder should be part of your PATH by default. You could check your PATH variable by following these instructions and modify it if needed or you try moving the unpacked apktool files to the same location as the adb command which is most likely /PATH/TO/ANDROID_SDK/platform-tools OR /PATH/TO/ANDROID_SDK/tools

Sorry for the delay..got back to trying this mod. I got an error..
C:\Users\ME\apktool d android.policy.jar out
Unable to access jarfile C:\Windows\\apktool.jar
Did I put these 3 files in the wrong location?

I just saw your comment about putting these files into where adb.exe is located. I moved these files there..also checked my path and its set up for:
Variable: path
Value: C:\android-sdk\platform-tools
The error I got now is: Unable to access jarfile C:\android-sdk\platform-tools\\apktool.jar

I'm not all that familiar with how Windows handles things but something it should be able to find apktool.jar if it's the same directory as apktool.bat. What is the contents of apktool.bat? A workaround would be manually doing the .bat file's job and run "apktool" using this command instead:
Code:
"java -jar /LOCATION/OF/apktool.jar"
Typing that in a cmd window should give you the usage output for apktool. If that works, you could then use that format to decode and build apk/jar files.

I have everything in the folder: C:\android-sdk\platform-tools
Contents of 'apktool.bat':
@echo off
java -jar "%~dp0\apktool.jar" %1 %2 %3 %4 %5 %6 %7 %8 %9
I am getting this error:
C:\Users\ME>java -jar C:\android-sdk\platform-tools\apktool.jar
Unable to access jarfile C:\android-sdk\platform-tools\apktool.jar

Ok...two more things to try.
Add the location of the java commands to the PATH variable. Probably somewhere like C:\jdk1.6.0_##\bin OR C:\Program Files\Java\jdk1.6.0_##\bin. The PATH variable as a whole would now be something like this: C:\LOCATION\OF\jdk1.6.0_##\bin;C:\WINDOWS\system32;C:\WINDOWS
If that doesn't help: change directory(cd) to C:\android-sdk\platform-tools in the cmd prompt, then run "java -jar apktool.jar"
Sorry it's being such a PITA to just get apktool to run.

1. The location of my Java program is: C:\Program Files\Java - There are 3 folders in there: jdk1.6.0_25, jre1.6.0_22, jre6 - I currently have a user variable 'path' with the value 'C:\android-sdk\platform-tools' - should it be added after this? ..if so, could you explain from what I gave about java what I need to add?
2. Tried cd - same thing..Unable to access jarfile

What does the following command give as output?
Code:
echo %PATH%
I'd set your system environment variable PATH like so:
right-click my computer -> properties -> advanced system settings -> Environment Variables...
under system variables, select Path, and Edit...
add the following(without the quotes) to the end of what's already there: ";C:\Program Files\Java\jdk1.6.0_25\bin;C:\android-sdk\platform-tools;C:\android-sdk\tools"
Also, since you are running Windows...it might make things easier on you to use APK Manager. Here's the thread for it: http://forum.xda-developers.com/showthread.php?t=695701

Here is what I have from the echo %PATH%
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
I installed the APK manager..I have it up and running. So I pulled the 'android.policy.jar' - Now what do I do to edit this file?

With all the storms, a power outage, and being busy I'm just now able to get back to you. I'm going to try going through the process using APK Manager on a Windows desktop I have access to. Step-by-step instructions will be in the post below.

Step-by-Step for Windows
You will need the java jdk installed and ADB set up for this to work.
download APK Manager and extract it to you preferred location
this guide will use C:\apk_manager_4.9
run C:\apk_manager_4.9\Script.bat
select option 0 to adb pull
where = /system/framework/android.policy.jar
stored name = android.policy.jar
current project = y
select option 9 to decompile
minimize Script.bat window
use Notepad++(or your preferred editor) to open:
Code:
C:\apk_manager_4.9\projects\android.policy.jar\smali\com\android\internal\policy\KeyguardViewMediator.smali
find ".method public pokeWakelock()V" NOT ".method public pokeWakelock(I)V"
inside the method, find the two lines starting with "const/16 v#" followed by a hex value(0x####)
the second(0x1388=5000ms=5s) is the default timeout unless a hardware keyboard is open, in which case the first(0x2710=10000ms=10s) is used
the values are 16-bit signed integers so the highest either can be set is 0x7FFF=32767ms=32.767s (Your screen will not wake up if set higher)
use this dec->hex convertor to determine the hex equivalent of your desired ms timeout
modify the hex values to your liking, save the file, and close Notepad++
return to the Script.bat window
select option 11 to compile
system apk = y
additional files = n
select option 8 to adb push
where&name = /system/framework/android.policy.jar
select option 24 to quit
open a command prompt to run these commands:
Code:
adb shell chmod 644 /system/framework/android.policy.jar
adb reboot recovery
in recovery,wipe dalvik-cache & cache, then reboot
Done!

All GOOD! Thanks for your hard work on figuring all this out for windows..it really wasn't hard at all once I had the right set of instructions haha
The only thing I've noticed is that the "screen off animation" does not work now - I have checked and unchecked it and its still not working..its really no biggie but just thought I'd say in case you want to play around with this mod more.

thetornado said:
All GOOD! Thanks for your hard work on figuring all this out for windows..it really wasn't hard at all once I had the right set of instructions haha
The only thing I've noticed is that the "screen off animation" does not work now - I have checked and unchecked it and its still not working..its really no biggie but just thought I'd say in case you want to play around with this mod more.
Click to expand...
Click to collapse
I'm glad we finally got it figured out for you. I have the screen animation turned off on my Eris so I didn't notice this broke it. I'll look into it and see if I can figure anything out. The first thing that comes to mind is that the screen off animation could somehow be dependent on the AWAKE_INTERVAL_DEFAULT_MS variable. As I found when first looking at this mod, changing the variable won't actually affect the value wherever it is used since the package is already compiled. So if the animation does use that variable in some way, we'll need to find where that happens and change the value there.

Related

Change unknown caller picture

When a call comes in which is from an unknown nuumber or a contat that doesn't have a picture assigned to it you get a blue outline of a person, with a question mark in the middle by default. Is there way of changing this default image to something more interesting? Any ideas?
Thanks
Not too hard to do
I know its been awhile since you asked, but since I haven't found an answer anywhere else...
You need to open the (ROM).zip that you are using and edit an .apk and then use ADB to push it back to the phone.
I'm using Virtuous Unity 1.3.1. I've done it successfully on a few other ROMs too.
You'll need a graphics editor (I used MS Paint), Android SDK with adb, 7-Zip.
Here's how I did it...
As always, MAKE A BACKUP! Its not my fault if something goes wrong.
1 - Open the .zip copy of the ROM that you're using
2 - Extract a copy of /system/app/Phone.apk
3 - Open Phone.apk using 7-zip and copy the following files to your desktop (don't close the 7-Zip window):
-phone_default_270.png
-phone_default_300.png
-phone_default_incall_270.png
-phone_default_incall_300.png
4 - Find a picture that you want to use and resize it to 300x300 and 270x270. Save it as the above file names.
5 - Copy the 4 files back into the Phone.apk archive and exit 7-Zip
6 - Copy the new Phone.apk file into your adb directory (Android SDK, usually in the platform-tools folder)
7 - Connect your phone to your computer and ensure its in charge-only mode with USB debugging enabled
8 - Open a command prompt window, change to your adb directory, and run the following commands:
adb devices {to make sure the device is connected}
adb remount {sets it to read/write}
adb push Phone.apk /system/app/Phone.apk {replaces the Phone.apk file}
9 - Disconnect your device and reboot
10 - Enjoy!
-Kyle

( ADB Help ) how-to set ADB & Windows $Path

HOW-TO Fix **ADB is not recognized in the CMD**ā€‹
Navigate to & Left_Click on Start >
Right_Click on Computer >
Left_Click on Advance System Settings >
Left_Click on Environment Variables >
Left_Click on New ( User Variables ) >
Variables Name: ADB ( Or anything you want )
Variables Value: ;C:\SDK\tools ( Just like this, This is the Path of my adb.exe )
You must put a ; in front of ;C:\ ( adb Path goes here / Variables Value: )
That's it.. You now have set up adb to work Global via cmd prompt on win7
~Eugene
eugene373 said:
HOW-TO Fix **ADB is not recognized in the CMD**ā€‹
Navigate to & Left_Click on Start >
Right_Click on Computer >
Left_Click on Advance System Settings >
Left_Click on Environment Variables >
Left_Click on New ( User Variables ) >
Variables Name: ADB ( Or anything you want )
Variables Value: ;C:\SDK\tools ( Just like this, This is the Path of my adb.exe )
You must put a ; in front of ;C:\ ( adb Path goes here / Variables Value: )
That's it.. You now have set up adb to work Global via cmd prompt on win7
~Eugene
Click to expand...
Click to collapse
or you can just open up command prompt and cd^ (adb folder location)
thesparky007 said:
or you can just open up command prompt and cd^ (adb folder location)
Click to expand...
Click to collapse
or copy the exe and the needed dll's to system32
however when i type adb it better just work regardless of what folder I'm in...
If you are running .bat & a Noob it will never work.... Just follow the Directs posted in OP
Thanks OP for the tip.
This is the easiest way to start adb.
OK, so I don't know what I did wrong but I named the variable name to adb and then the variable value ;C:\Program Files (x86)\Android\android-sdk\platform-tools which is where my adb.exe is located. But if I open up a command prompt and do adb devices it says:
C:\Users\Tiffany>adb devices
'adb' is not recognized as an internal or external command,
operable program or batch file.
If I cd to that location adb works but I thought it would be cool to just open a command prompt and be able to use adb but it's not working for me. Any suggestions or do u see anything wrong?
Tiffany84 said:
OK, so I don't know what I did wrong but I named the variable name to adb and then the variable value ;C:\Program Files (x86)\Android\android-sdk\platform-tools which is where my adb.exe is located. But if I open up a command prompt and do adb devices it says:
C:\Users\Tiffany>adb devices
'adb' is not recognized as an internal or external command,
operable program or batch file.
If I cd to that location adb works but I thought it would be cool to just open a command prompt and be able to use adb but it's not working for me. Any suggestions or do u see anything wrong?
Click to expand...
Click to collapse
Tiffany, try this from a cmd prompt:
path = %path%;C:\Program Files (x86)\Android\android-sdk\platform-tools
then adb should work regardless of where you are in cmd
RyteSyde said:
Tiffany, try this from a cmd prompt:
path = %path%;C:\Program Files (x86)\Android\android-sdk\platform-tools
then adb should work regardless of where you are in cmd
Click to expand...
Click to collapse
AHH, You are awesome. That worked. So should I delete that variable that I added or just leave it there?
Edit: Ok. So it works when I add that path but if I close that prompt and then reopen and try to use adb with out adding that path again I get the error. So do I have to do that every time I open the command prompt?
Tiffany84 said:
AHH, You are awesome. That worked. So should I delete that variable that I added or just leave it there?
Edit: Ok. So it works when I add that path but if I close that prompt and then reopen and try to use adb with out adding that path again I get the error. So do I have to do that every time I open the command prompt?
Click to expand...
Click to collapse
No you shouldn't have to if you open the cmd window with admin rights and set the path=. Run cmd as administrator or use the posts above and edit the path variable and add a ; to the end of it and then the path to platform-tools
either way should work
and if you get that to stick you won't need the other variable you added before
RyteSyde said:
No you shouldn't have to if you open the cmd window with admin rights and set the path=. Run cmd as administrator or use the posts above and edit the path variable and add a ; to the end of it and then the path to platform-tools
either way should work
and if you get that to stick you won't need the other variable you added before
Click to expand...
Click to collapse
Ok, so I ran the cmd prompt as admin and it still won't stick. So your saying I need to add ; before C: and at the end of it? Sorry. Not the greatest with pc's. Thanks for trying to help though.
Tiffany84 said:
Ok, so I ran the cmd prompt as admin and it still won't stick. So your saying I need to add ; before C: and at the end of it? Sorry. Not the greatest with pc's. Thanks for trying to help though.
Click to expand...
Click to collapse
whatever is in your path variable, leave that and just add this to the end:
;C:\Program Files (x86)\Android\android-sdk\platform-tools
RyteSyde said:
whatever is in your path variable, leave that and just add this to the end:
;C:\Program Files (x86)\Android\android-sdk\platform-tools
Click to expand...
Click to collapse
I named it adb and then the blank spot for the value I just copied and pasted what u had and still nothing. I give up. I guess stuff isn't meant to be easy for me. Story of my life. Thank u so much for trying to help.
Tiffany84 said:
I named it adb and then the blank spot for the value I just copied and pasted what u had and still nothing. I give up. I guess stuff isn't meant to be easy for me. Story of my life. Thank u so much for trying to help.
Click to expand...
Click to collapse
I was referring to updating the system path. Where you created the variable, underneath that should be the "System variables" section. Scroll down in that the the variable "path" and double click it. Move the cursor to the end of the line entry and paste in the ;C:\...etc... line from above
RyteSyde said:
I was referring to updating the system path. Where you created the variable, underneath that should be the "System variables" section. Scroll down in that the the variable "path" and double click it. Move the cursor to the end of the line entry and paste in the ;C:\...etc... line from above
Click to expand...
Click to collapse
BAM!!!!!!!!!!!!!!!!!!!!! Thank u for not giving up on me even though I had. That did it. I"M giving u all my thanks for the day. Thank u again. I really appreciate it.
Tiffany84 said:
BAM!!!!!!!!!!!!!!!!!!!!! Thank u for not giving up on me even though I had. That did it. I"M giving u all my thanks for the day. Thank u again. I really appreciate it.
Click to expand...
Click to collapse
it's no root but glad I could help
RyteSyde said:
it's no root but glad I could help
Click to expand...
Click to collapse
Definitely not root but hey, still pretty cool.
Thread moved to General as not development, thanks for sharing though
I always wanted to know how to set adb so you can use it anywhere. Editing the path in the system variable worked for me. Thanks RyteSyde.
The right way to avoid weird issues.... [Noob Proof sorry in advance]
It actually works perfect if you just do the following:
1. Right Click My Computer -> Properties
2. On the left pane, Find and Click "Advanced system settings"
3. Under the "Advanced" Tab Find and Click "Environment Variables..."
4. In the box for "User variables for [your name here; e.g. David]" there will be a button that says "New..." Click it.
5. Now you have a box in front of you with two fields:
1. Variable name: entering path here is really safer and can help to avoid clogging up the environment namespaces (cluttering your ram/registry)
Code:
Path
2. Variable value: directory containing the adb.exe you want to use**; i.e.
Code:
C:\Android\sdk\platform-tools
**to find this with ease search for "adb.exe" or look for it in "...sdk\platform-tools\" or "sdk\tools".
**This is a version dependent thing for the Android SDK which folder its in.
6. Click OK on all the dialogs and exit the windows we opened here.
7. Hit the windows key + R and type cmd.exe; hit Enter
8. Type adb into the newly opened cmd window. hit Enter
9. If adb runs all is well. Your DONE. If not continue to step 10.
--If it work stop here!--
10. At this point we are going to select our entry from step 5. (in Environment variables...)and delete it. Otherwise windows has two pointers to our adb.exe.
11. Navigate in the "System variables" box and scroll down until you see Path in the Variable Column. Select it and Click "Edit..."
12. Click inside "Variable value:" go to the very end of this and drop a ";" no spaces. Enter the value from Step 5.2
13. Click OK/Apply on all dialogs and reboot your PC.
14. Repeat steps 7-9 and if all is well your done. If not you may need to redownload the AndroidSDK from here: http://developer.android.com/sdk/index.html then repeat this guide.
The reason for first trying to do this under "User" as opposed to "System" is if you need to track your changes to Path in case anything goes wrong as it can be a daunting task to go through the System version (its really full of stuff that needs to be there XD )
But don't take my word for it: My path
Code:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static
and my Windows is brand new Store-bought not OEM. It tends get get bigger the more stuff windows needs to globally keep track of that doesn't live in C:\Windows\
Hope this helped!
RyteSyde said:
whatever is in your path variable, leave that and just add this to the end:
;C:\Program Files (x86)\Android\android-sdk\platform-tools
Click to expand...
Click to collapse
I could really use some help I have a windows vista 32-bit
The first time I tried to set up adb I messed up bad and deleted my original environment variable path
so now I can't even do it because I need my original environment variable path then ;C:\Program Files (x86)\Android\android-sdk\platform-tools
I didn't create a system restore point so I am screwed is there anyway I can recover my original environment variable path?
Grandkai said:
I could really use some help I have a windows vista 32-bit
The first time I tried to set up adb I messed up bad and deleted my original environment variable path
so now I can't even do it because I need my original environment variable path then ;C:\Program Files (x86)\Android\android-sdk\platform-tools
I didn't create a system restore point so I am screwed is there anyway I can recover my original environment variable path?
Click to expand...
Click to collapse
http://forum.xda-developers.com/showthread.php?t=2317790
I would personally use this seeing it's one click go.

[Q] Some General Questions Regarding the editing of android.policy.jar

hello everyone
I have updated to kennethpenn's 4.5.91 Gingerbread Beta 4 (must say, it is truly a phenomally put together build !)
I have also noticed that many of the mods that i had applied to 1.8.3 have not been updated for 4.5.91, so i decided to make the changes myself.
Now, I have a pretty decent knowledge of Unix-based operating systems ( I have used Red Hat Linux, Ubuntu, SUSe Linux, OpenBSD, FreeBSD, Solaris, and now OS X) however, I would like to expand my knowledge to include Android.
The first one I attempted to do myself was the Wake on Volume Keys mod.
This is a very simple change to the android.policy.jar file, as you all well know.
For this, I used Windows XP, simply for the fact that I have 7zip and PeaZip installed on it. However, I can do all of this on OS X as well. The file archiver applications I have on OS X are:
1. The Unarchiver
2. Keka
I am going to list my method of applying this edit, and i would ask that someone with solid knowledge on this subject give me their feedback and guidance.
---------------------------------------------------------
My Method of editing android.policy.jar
---------------------------------------------------------
1. Using Root Explorer, I made a copy of /system/framework on my External SD Card
2. Mounting the Phone for USB Mass Storage on Windows XP that I have running in VirtualBox on my Macbook Pro, I moved the copy of the /system/framework directory to my Desktop
3. I downloaded smali-1.2.6.jar and baksmali-1.2.6.jar from code.google.com/p/smali/
4. I placed both of these .jar files in the copy of the framework-edited directory that I created on my Desktop
5. I renamed smali-1.2.6.jar to smali.jar and baksmali-1.2.6.jar to baksmali.jar for simplicity's sake
6. I moved the android.policy.jar file to /framework-edited directory on my Desktop
7. Using 7zip (I also have PeaZip, but for this, I used 7zip, if you think I should use PeaZip, please tell me) I extracted the files from android.policy.jar to end up with classes.dex and META-INF. I then moved classes.dex to /framework-edited so it is in the same directory as smali.jar and baksmali.jar
8. In Command Prompt, I entered:
Code:
cd C:\Documents and Settings\Owner\Desktop\framework-edited
in order to be working from the proper location where my files are located
9. Now, having Command Prompt working in the proper location, I entered the following commands:
Code:
java -jar baksmali.jar -o classout/ classes.dex
to create a new directory within /framework-edited called /framework-edited/classout
10. I then opened the /classout directory, and navigated to /classout/com/android/internal/policy/impl/ and opened the file KeyguardViewMediator.smali with Notepad
11. I used [Ctrl] + [F] to locate the line:
private isWakeKeyWhenKeyguardShowing(I)Zā€‹
12. I then looked at the lines DIRECTLY below the above line, and following the Original Post on how to manually apply this modification, I removed lines:
0x18
0x19ā€‹
13. Upon removing these lines, I simply did a File -> Save As -> KeyguardViewMediator.smali and saved the file to my desktop
14. I [Cut] + [Pasted] the edited KeyguardViewMediator.smali file back to /classout/com/android/internal/policy/impl/ and replaced the original KeyguardViewMediator.smali file
15. With the edited KeyguardViewMediator.smali file in place, I went back to Command Prompt and entered the following commands:
Code:
java -Xmx512M -jar smali.jar classout/ -o new-classes.dex
To create a new file called new-classes.dex
16. Changing the name of new-classes.dex to classes.dex, I took the original META-INF file, and my newly created classes.dex files, and, using 7zip, created a new android.policy.zip archive
17. I renamed my newly created android.policy.zip to android.policy.jar, and transferred it to my External SD Card
18. Using Root Explorer, I navigated to /system/framework on my phone, and renamed android.policy.jar to 1122android.policy.jar.bac and [Copy] + [Pasted] my edited android.policy.jar to /system/framework
19. I then immediately powered off my phone, and rebooted into CWM Recovery, and cleared my Dalvik Cache, then rebooted the phone normally through CWM Recovery.
At this point, to my knowledge, I had successfully edited my android.policy.jar file and had manually added the Wake on Volume Keys modification, however, once the phone was fully booted and showing my lockscreen, I unlocked the phone as normal by sliding the slider to the right. As soon as the phone unlocked, I saw pop-ups for processes that had failed and were terminated. I'm not sure what the exact message the pop-ups had, but it was the normal pop-up message you get when a process force-closes. My only option was to click "Ok" so I clicked it, only to have another force-close pop-up.
Apparently, every single process on the phone had force-closed, BUT, the phone was waking when I press a volume key while the screen was off. I had no choice but to pull the battery out.
I decided to reboot into CWM Recovery and "install .zip from SD Card", Nottach's 1% Battery Mod / No Carrier Mod Uninstall Script
I installed Nottach's uninstall script because I hoped that it had an unmodified copy of android.policy.zip in it.
After installing the uninstall script, and rebooting the phone once again, I got to the lock screen, unlocked the phone, and found everything to be in perfect working order, just as before I edited anything,
But the Wake on Volume Keys mod was still applied!
So now, my questions / requests to all of you are:
1. Explain to me what I missed or did wrong that resulted in the force-closure of every single process on the phone prior to installing Nottach's Uninstall script
and
2. Educate me on the proper process that you developers use to apply small modifications such as this one to the android.policy.jar file, or any other related file on the phone for that matter.
My plan is now to change the color of the text on my lock screen (Clock, Date, and possibly Carrier) following this [Guide]
Any and all feedback is welcomed and greatly appreciated, as you will be helping me learn the beginnings of modding and developing
bump . . . . .
Perhaps this may help
http://forum.xda-developers.com/showthread.php?p=18226553

[Q] Android reverts SystemUI.apk edits

Hi! I have a very odd problem: somehow my SystemUI.apk mods won't keep (i.e. after pushing, the XML edits are reversed to stock). I'm attempting to remove the brightness slider. It should be a simple edit to the tw_status_bar_expanded.xml: add the red code; many others have used this edit successfully (Verizon GS3, international GS3, etc.):
Code:
<LinearLayout android:orientation="vertical" android:id="@id/brightness_controller" [B][COLOR="Red"]android:visibility="gone"[/COLOR][/B] android:background="#ff000000" android:layout_width="fill_parent" android:layout_height="56.0dip">
However, it didn't work on my phone, even after three attempts. So, on a hunch, I edited something totally different:
Code:
android:background="ff000000"
to
Code:
android:background="00000000"
-- which should make the brightness bar transparent: that didn't work after pushing, either! Frustrated, I pulled the SystemUI.apk back and saw that...somehow...the XML had "reverted" back to stock, showing
Code:
[B]android:background="ff000000"[/B]
Here's my "flow," if anyone can diagnose this wacky issue:
1. Use Virtual Ten Studios (an IDE, integrated development environment) to pull SystemUI.apk (after installing framework-res.apk resources).
2. Create backup of SystemUI.apk
3. Edit XML in SystemUI.apk -> save -> recompile and zipalign.
4. Copy AndroidManifest.xml and META-INF folder from backup apk to modded apk.
5. Boot phone into recovery -> push modded SystemUI.apk to /system/app [states that it pushed correctly] (I do recovery because, as I just learned, you can't push to a phone that's on, if it has a secure kernel; adb remount or adb shell mount still yield permission denied, but recovery doesn't!).
6. Reboot.
I thought it was just a fluke, but I ran the experiment again, this time changing the color of the bar: ff000000 -> ff000001 (left is XML before pushing; right is XML after pulling): http://prntscr.com/qoqcx
Thought it could be a permissions issue, but I ran adb shell -> chmod 644 /system/app/SystemUI.apk from recovery. Still doesn't work! I pulled the just-modded pushed APK and, boom, there it lies with none of my edits. :/
Any thoughts out there?
There's got to be a reason... My phone can't be a demon. Right?
For what it's worth, I've successfully flashed a SystemUI.apk as a flashable zip, so my phone isn't immune. There's just something wrong with my process....
A friendly bump because of subforum change!

[GUIDE] Modifying apk/jar files on the Axon 7

So I decided to write up a little guide on how to modify apk and jar files on the Axon 7 for those of you who do not know how and would like to make some modifications such as the ones in my guides.
Prerequisites
A Windows/Linux/Mac computer
A rooted device with TWRP Recovery
USB cable
ADB installed and USB debugging enabled
Java JDK: http://www.oracle.com/technetwork/java/javase/downloads/index.html
APKTool: https://ibotpeaches.github.io/Apktool/install/ (Follow all the instructions)
Baksmali: https://bitbucket.org/JesusFreke/smali/downloads/baksmali-2.2.0.jar
7-Zip or another archive manager
1. Install the frameworks to your computer
Open a command window in your working directory and connect your device to your computer with the USB-C cable.
Pull the framework files with
Code:
adb pull /system/framework/framework-res.apk
adb pull /system/framework/framework-zte-res.apk
Install them
Code:
apktool if framework-res.apk
apktool if framework-zte-res.apk
Depending on which ROM you are on you may need to install other frameworks. The above is for the stock ROM.
2. Decompile the apk/jar file.
Pull the apk/jar you want to decompile with
Code:
adb pull path_to_apk_or_jar
Here are paths for some commonly modified apk/jars:
SystemUI: /system/priv-app/SystemUI_ZTE/SystemUI_ZTE.apk
Settings: /system/priv-app/Settings_ZTE/Settings_ZTE.apk
services.jar: /system/framework/services.jar
Decompile the apk with
Code:
apktool d <apk/jar>
If you did everything correctly, a folder should now exist with the name of your apk/jar.
3. Decompile the .odex file
You can skip this step if your apk/jar does not have an .odex associated with it or you only need to modify res and not smali.
Pull the odex file
Code:
adb pull path_to_odex
For example if you want to pull the odex file for SystemUI you would do
Code:
adb pull /system/priv-app/SystemUI_ZTE/oat/arm64/SystemUI_ZTE.odex
Create a folder called "smali" in the directory of your decompiled apk/jar. Then go back to your working directory.
Pull all boot oat files from your device with
Code:
adb pull /system/framework/arm64
Move all the oat files inside the arm64 folder on your PC to your working directory.
Using baksmali, decompile the odex file to smali
Code:
java -jar baksmali.jar deodex -a <api> filename.odex
where api is 23 for Android 6.0, 24 for Android 7.0, and 25 for Android 7.1
A new folder should now be created called "out". Cut and paste the files and folders inside this folder into the "smali" folder you created earlier.
4. Make your modifications.
5. Recompile the apk/jar
From the working directory (not the directory of the decompiled apk/jar) Recompile the apk/jar with
Code:
apktool b name_of_folder
where name_of_folder is the name of the directory of the decompiled apk/jar.
The complied apk/jar should now exist in the "dist" folder in the directory of the decompiled apk/jar.
6. Sign the apk.
Using 7-zip or another archive manager, copy the res folder, resources.arsc file, and the classes.dex file (if you modified smali in steps 3 and 4) from the NEW apk to the ORIGINAL apk.
7. Replace the apk/jar on your device.
Reboot your device into TWRP recovery with
Code:
adb reboot recovery
For user apps: Make sure data is mounted in TWRP's mount menu. If you have encryption turned on you must enter your password otherwise data will not be mounted!
For system apps and framework files: Make sure system is mounted in TWRP's mount menu. Uncheck "Mount system read-only" if it is checked.
Push the ORIGINAL apk/jar to the correct directory on your device
Code:
adb push <apk/jar> path_to_apk_or_jar
Set correct permissions on the apk/jar
Code:
adb shell chmod 0644 path_to_apk_or_jar
If you did step 3, use TWRP's file manager in Advanced<File Manager to navigate to the apk/jar file's directory and delete the existing .oat or .odex file associated with it.
You did it
No go
Hi,
Tried it with the SystemUI_ZTE.apk (and odex) from the 2017G B08 ROM. I ended up with a folder named SystemUI_ZTE. I created a smali folder in that folder and moved the android, com and cn folders (that I got using the "java -jar oat2dex.jar smali SystemUI_ZTE.odex" command) to that smali folder. But when I try the apktool b command I get the following error:
Code:
C:\Users\Blub\ZTE>apktool b SystemUI_ZTE
I: Using Apktool 2.3.0
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
SystemUI_ZTE\smali\android\support\v17\leanback\app\BackgroundManager.smali[102,4] iput-wide-volatile is an odexed instruction. You cannot reassemble a disassembled odex file unless it has been deodexed.
Exception in thread "main" brut.androlib.AndrolibException: Could not smali file: android/support/v17/leanback/app/BackgroundManager.smali
at brut.androlib.src.SmaliBuilder.buildFile(SmaliBuilder.java:75)
at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:59)
at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:36)
at brut.androlib.Androlib.buildSourcesSmali(Androlib.java:412)
at brut.androlib.Androlib.buildSources(Androlib.java:343)
at brut.androlib.Androlib.build(Androlib.java:299)
at brut.androlib.Androlib.build(Androlib.java:270)
at brut.apktool.Main.cmdBuild(Main.java:224)
at brut.apktool.Main.main(Main.java:75)
Any idea what I am doing wrong?
TIA,
Cheers,
/Cacti
le_cactus said:
Hi,
Tried it with the SystemUI_ZTE.apk (and odex) from the 2017G B08 ROM. I ended up with a folder named SystemUI_ZTE. I created a smali folder in that folder and moved the android, com and cn folders (that I got using the "java -jar oat2dex.jar smali SystemUI_ZTE.odex" command) to that smali folder. But when I try the apktool b command I get the following error:
Any idea what I am doing wrong?
TIA,
Cheers,
/Cacti
Click to expand...
Click to collapse
I updated the OP with a different tool for the odex file. Try it now.
Hi,
Thanks,but "java -jar baksmali-2.2.0.jar -a 25 -x SystemUI_ZTE.odex -d %CD%" gives me this error
Code:
Exception in thread "main" com.beust.jcommander.MissingCommandException: Expected a command, got -a
at com.beust.jcommander.JCommander.parseValues(JCommander.java:725)
at com.beust.jcommander.JCommander.parse(JCommander.java:304)
at com.beust.jcommander.JCommander.parse(JCommander.java:287)
at org.jf.baksmali.Main.main(Main.java:90)
Cheers,
/Cacti
le_cactus said:
Hi,
Thanks,but "java -jar baksmali-2.2.0.jar -a 25 -x SystemUI_ZTE.odex -d %CD%" gives me this error
Cheers,
/Cacti
Click to expand...
Click to collapse
Try it without any arguments: "java -jar baksmali-2.2.0.jar SystemUI_ZTE.odex"
Hi,
The command "java -jar baksmali.jar deodex -a 25 SystemUI_ZTE.odex"gives me
Code:
Error occurred while loading class path files. Aborting.
org.jf.dexlib2.analysis.ClassPathResolver$ResolveException: Error while loading oat file boot.oat
at org.jf.dexlib2.analysis.ClassPathResolver.loadEntry(ClassPathResolver.java:250)
at org.jf.dexlib2.analysis.ClassPathResolver.loadLocalClassPathEntry(ClassPathResolver.java:179)
at org.jf.dexlib2.analysis.ClassPathResolver.loadLocalOrDeviceBootClassPathEntry(ClassPathResolver.java:191)
at org.jf.dexlib2.analysis.ClassPathResolver.<init>(ClassPathResolver.java:120)
at org.jf.dexlib2.analysis.ClassPathResolver.<init>(ClassPathResolver.java:105)
at org.jf.baksmali.AnalysisArguments.loadClassPathForDexFile(AnalysisArguments.java:129)
at org.jf.baksmali.AnalysisArguments.loadClassPathForDexFile(AnalysisArguments.java:86)
at org.jf.baksmali.DisassembleCommand.getOptions(DisassembleCommand.java:203)
at org.jf.baksmali.DeodexCommand.getOptions(DeodexCommand.java:71)
at org.jf.baksmali.DisassembleCommand.run(DisassembleCommand.java:177)
at org.jf.baksmali.Main.main(Main.java:102)
Caused by: org.jf.dexlib2.analysis.ClassPathResolver$NotFoundException: Cannot find dependency boot-core-libart.oat in null
at org.jf.dexlib2.analysis.ClassPathResolver.loadOatDependencies(ClassPathResolver.java:270)
at org.jf.dexlib2.analysis.ClassPathResolver.loadEntry(ClassPathResolver.java:248)
... 10 more
Cheers,
/Cacti
le_cactus said:
Hi,
The command "java -jar baksmali.jar deodex -a 25 SystemUI_ZTE.odex"gives me
Cheers,
/Cacti
Click to expand...
Click to collapse
pull boot-core-libart.oat from /system/framework/arm64/boot-core-libart.oat and try again
Muchas gracias
Hi,
Had to pull all the .oat files from the /system/framework/arm64/ folder, only then I didn't get an error any more using the command "java -jar baksmali.jar deodex -a 25 SystemUI_ZTE.odex". The "command "java -jar baksmali.jar -a 25 -x SystemUI_ZTE.odex -d %CD%" still gave an error, you might wanna change that in the OP.
Now apktool b SystemUI_ZTE didn't give me any errors anymore. Executed the other steps, and bingo! Everthing seems to work. And byy replacing the charging.ogg, my device charges silently.
Thanks from my wife as she now doesn't wake up when I go to bed (and connect the charger). Many thanks for your patience and your excelent guide! I guess I'll bemodding some more APK's now
Cheers,
/Cacti
le_cactus said:
Hi,
Had to pull all the .oat files from the /system/framework/arm64/ folder, only then I didn't get an error any more using the command "java -jar baksmali.jar deodex -a 25 SystemUI_ZTE.odex". The "command "java -jar baksmali.jar -a 25 -x SystemUI_ZTE.odex -d %CD%" still gave an error, you might wanna change that in the OP.
Now apktool b SystemUI_ZTE didn't give me any errors anymore. Executed the other steps, and bingo! Everthing seems to work. And byy replacing the charging.ogg, my device charges silently.
Thanks from my wife as she now doesn't wake up when I go to bed (and connect the charger). Many thanks for your patience and your excelent guide! I guess I'll bemodding some more APK's now
Cheers,
/Cacti
Click to expand...
Click to collapse
Great! I'll add that to the OP! Thanks for helping me out!
Updated the OP with a new signing method that should fix boot hang issues with some apks (aka Settings_ZTE)
bkores said:
Updated the OP with a new signing method that should fix boot hang issues with some apks (aka Settings_ZTE)
Click to expand...
Click to collapse
IMO it was just the same as your previous method (under 5.)was saying : move META-INF ( and manifest but not necessary imo) from original apk into the new apk (in dist folder).
Now you're saying : put res, resources and classes from new apk into new apk...that's just the same, no ? Only more files to move imo.
Since res, resources and classes are indeed changing by compile, wouldn't it be better by just saying : put META-INF from original apk into new apk, like you first wrote in OP ? Easier no ?
ALSO : under 6. you say : Open a command window in the "dist" folder and push the ORIGINAL apk/jar to the correct directory on your device
Shouldn't that be : push ORIGINAL (since you copied files under 5 from NEW(in "dist") to ORIGINAL(in working folder) ) FROM WORKING FOLDER ? Since there is no original apk in DIST folder, only our new apk. Imo you make things a bit confusing here, no ? :cyclops:
raystef66 said:
IMO it was just the same as your previous method (under 5.)was saying : move META-INF ( and manifest but not necessary imo) from original apk into the new apk (in dist folder).
Now you're saying : put res, resources and classes from new apk into new apk...that's just the same, no ? Only more files to move imo.
Since res, resources and classes are indeed changing by compile, wouldn't it be better by just saying : put META-INF from original apk into new apk, like you first wrote in OP ? Easier no ?
ALSO : under 6. you say : Open a command window in the "dist" folder and push the ORIGINAL apk/jar to the correct directory on your device
Shouldn't that be : push ORIGINAL (since you copied files under 5 from NEW(in "dist") to ORIGINAL(in working folder) ) FROM WORKING FOLDER ? Since there is no original apk in DIST folder, only our new apk. Imo you make things a bit confusing here, no ? :cyclops:
Click to expand...
Click to collapse
Fixed!
bkores said:
Fixed!
Click to expand...
Click to collapse
Thnx Mate ! Appreciate all your work :good:
i have some problem with framework.jar, it doesn't have classes.dex in jar but it also doesn't have odex file in /system/framework/oat/arm64 (also arm). Because of it i can't decompile it using smali/baksmali tool. I want to make more volume steps mode like VolumeSteps+ but without Xposed. Hope someone can help.

Categories

Resources