[MOD][GUIDE][JB 4.1.2][MULTI-THREAD/NATIVE] Lockscreen Blur Effect/MULTITHREAD

Search This thread

BOOTMGR

Senior Member
Aug 3, 2010
728
3,395
anoobdevsdiary.blogspot.in
Thanks for your reply.

I have only .png

No .jpg

Do u have any blurred image mate?
Am on mobile. .can't use gimp to create one:D

Edit:

Its working. .
su9arehe.jpg


Sent from my GT-I9100 using Tapatalk 2

The reason is that you need to enable lockscreen wallpaper which is done automatically when you set it up via SecGallery. This mod requires that you did it before because we'll need Lockscreen wallpaper enabled & lockscreen_wallpaper.png & lockscreen_wallpaper.jpg because blurred image is written to it ( i'm a bad coder, forget to add code to create it if it doesn't exist :p).
If it is not present there then there'll be bootloop or black wallpaper.


This was my third attempt for setting this up in my phone and as expected it did not work... As I told before that I don't use Samsung's Gallery app, all I did was change the path of the lockscreen image.. which is "/data/data/com.sec.android.app.wallpaperchooser/files/lockscreen_Wallpaper.jpg" for me.. so I used that... I've attached my both log file and my android.policy.jar below...

You'll require stock gallery app to enable lockscreen wallpaper. Path to lockscreen wallpaper is defined in settings storage database with id lockscreen_wallper_path.It is the path from where wallpaper is loaded & which you must use in my mod.Additionally you'll need to enable lockscreen wallpaper by changing value of lockscreen_wallpaper to 1 in same database which secgallery does automatically.
Which gallery are you using?
Are you able to change lockscreen wallpaper using that gallery?

About the log, as i edited first post, you'll need to enable lockscreen wallpaper first as mentioned above or set wallpaper through secgallery once or simply copy any valid png file to /data/data/com.sec.android.gallery3d/lockscreen_wallpaper.png


Ok thanks!

So I've managed to copy entire framework folder to computer, deodex, and decompile the android.policy.jar file. However, whilst navigating to the com\android\internal\policy\impl\sec folder, I noticed I don't have a \sec folder... is this due to me having a different phone (thus different code files) than you? I also checked the \impl folder for the wallpaperwidget.smali file and cannot find one... also due to the naming for my similar wallpaperwidget.smali file being different?

Thanks for all the help! :)

---------- Post added at 01:17 AM ---------- Previous post was at 01:12 AM ----------




Thanks, but the second link (to the .jpg file) isn't working.

This mod is samsung specific...:(
 
Last edited:

Sami Kabir

Senior Member
Oct 3, 2012
2,233
1,410
@BOOTMGR

I don't use SecGallery.apk.. I use the Gallery and Camera app (Gallery2.apk) from CM 10.1.. and yes I can't use it to set lock screen wallpapers.. that's why I use the stock wallpaper choosing app (SecWallpaperChooser.apk)

I guess I'll have to use Samsung's laggy Gallery app to use this mod then...

Sent from my GT-I9070
 

Geddd

Senior Member
Nov 5, 2013
239
24
@OP, Thank you so much bro. It works now, sorry for the late feed back..
just a little bit confusion :(
I have lockscreen_wallpaper.png and jpg (both transparent) in data/data/sec.android.sec...
here how it looks

do you think it's really working now?
 
Last edited:

bamzzz

Senior Member
I have create toggle for enable/disable this, but blur effect can't disable after set locksreen wallpaper with SecWallpaperChooser, if set locksreen wallpaper with SecGallery this working.. i think this called "lockscreen_wallpaper_path",, can anyone help me..! thank's.. :D

Sorry my bad english
 

Vivek_Neel

Inactive Recognized Contributor / Themer
Dec 23, 2012
10,372
23,696
31
Chennai
@OP, Thank you so much bro. It works now, sorry for the late feed back..
just a little bit confusion :(
I have lockscreen_wallpaper.png and jpg (both transparent) in data/data/sec.android.sec...
here how it looks

do you think it's really working now?

Permission set to rw r r for both images?

Sent from my GT-I9100 using Tapatalk 2
 

gerryS2

Senior Member
Apr 3, 2013
93
86
Avellino
Thanks @BOOTMGR for this effect, I have try to insert a smali to activate this effect with checkbox on the "fly" and it was a success :)
I would like to share the code that I inserted with you.
First search this line in WallpaperWidget:
Code:
invoke-direct {p0}, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->BlurImage()V
Under this line insert this code:
Code:
iget-object v0, p0, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->mContext:Landroid/content/Context;

    invoke-virtual {v0}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v0

    const-string v1, "blur_checkbox"

    invoke-static {v0, v1, v2}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

    move-result v0

    if-ne v0, v2, :cond_2
	
    .line 63
    invoke-virtual {p0}, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->updateWallpaper()V

    goto :goto_0
	
	:cond_2
    invoke-direct {p0}, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->setLockScreenWallpaper()V

    goto :goto_0
.end method
I hope I have been of help :)
 

BOOTMGR

Senior Member
Aug 3, 2010
728
3,395
anoobdevsdiary.blogspot.in
Thanks @BOOTMGR for this effect, I have try to insert a smali to activate this effect with checkbox on the "fly" and it was a success :)
I would like to share the code that I inserted with you.
First search this line in WallpaperWidget:
Code:
invoke-direct {p0}, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->BlurImage()V
Under this line insert this code:
Code:
iget-object v0, p0, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->mContext:Landroid/content/Context;

    invoke-virtual {v0}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v0

    const-string v1, "blur_checkbox"

    invoke-static {v0, v1, v2}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

    move-result v0

    if-ne v0, v2, :cond_2
	
    .line 63
    invoke-virtual {p0}, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->updateWallpaper()V

    goto :goto_0
	
	:cond_2
    invoke-direct {p0}, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->setLockScreenWallpaper()V

    goto :goto_0
.end method
I hope I have been of help :)

Lockscreen constructor is called every time you press power key/ lock key so changes are on the fly. But it is better to avoid much toggles based on database because read/write to database is expensive operation. For better toggle you also need switch to System.Loadlibrary method in constructor so that RAM usage stays normal when it is not enabled. Look in my ROM for better toggle.
 
  • Like
Reactions: phenomarc

phenomarc

Senior Member
Nov 17, 2011
219
119
OnePlus 8T
I have succesfully ported this to a SGS2 4.1.2 ROM, but it doesn't work with ripple lock because the png/jpg is called lockscreen_wallpaper_ripple, not lockscreen_wallpaper. There's a way to fix it?
Thanks in advance.
 

lacoursiere18

Senior Member
Jan 9, 2013
4,183
7,001
LbTs
I have succesfully ported this to a SGS2 4.1.2 ROM, but it doesn't work with ripple lock because the png/jpg is called lockscreen_wallpaper_ripple, not lockscreen_wallpaper. There's a way to fix it?
Thanks in advance.

You could rename every instance its called..so in the smali where it says
Code:
const-string v1, lockscreen_wallpaper
change it to
Code:
const-string v1, lockscreen_wallpaper_ripple
And everywhere else its called

Sent from my SCH-I605 using xda app-developers app
 
  • Like
Reactions: phenomarc

phenomarc

Senior Member
Nov 17, 2011
219
119
OnePlus 8T
You could rename every instance its called..so in the smali where it says
Code:
const-string v1, lockscreen_wallpaper
change it to
Code:
const-string v1, lockscreen_wallpaper_ripple
And everywhere else its called

Sent from my SCH-I605 using xda app-developers app

I suppose to, but then the other locks won't work. I have Optimus, acer, bb,aosp and TW lock, and it works in all except ripple.

Enviado desde mi GT-I9100 mediante Tapatalk
 

lacoursiere18

Senior Member
Jan 9, 2013
4,183
7,001
LbTs
I suppose to, but then the other locks won't work. I have Optimus, acer, bb,aosp and TW lock, and it works in all except ripple.

Enviado desde mi GT-I9100 mediante Tapatalk

Ah then you would have to add some code for those to be called as well.. Maybe some more things as well..? though. . Why do you want blur on those?

Sent from my SCH-I605 using xda app-developers app
 

phenomarc

Senior Member
Nov 17, 2011
219
119
OnePlus 8T
Ah then you would have to add some code for those to be called as well.. Maybe some more things as well..? though. . Why do you want blur on those?

Sent from my SCH-I605 using xda app-developers app

The blur effect works in all except the ripple. Don't worry, it's not important while it works in stock.
Thanks for all.

Enviado desde mi GT-I9100 mediante Tapatalk
 

Top Liked Posts

  • There are no posts matching your filters.
  • 30

    Lockscreen Blur Effect

    EDIT : Updated guide with Native function. Now it is ~60% faster

    I wanna share this mod with you which i made for my HarshJelly ROM. Before starting guide let's see what it does. Actually idea came from GravityBox Module.

    What it does : It'll simply blur the background activity which you left before locking device (something like iOS 7's notification bar). Here are some caps to make it more clear.

    El8XY4n.png
    VzqNEWK.png
    Nqblokb.png
    zq9LbIf.png


    Yeah this mod is compatible with all Lockscreens (AOSP, Sammy's circle lockscreen, pattern etc). I tested this mod on my SGSA running stock TW 4.1.2. Since all TW roms are almost same, it should work on all TW 4.1.2 ROMs.

    Before starting tutorial, let me clear one thing that i won't respond to posts without full log. If you found any difficulty, feel free to ask me but please keep in mind above sentence.

    What is required?
    • android.policy.jar
    • Apktool
    • Notepad++

    So, let's begin...

    • Decompile android.policy.jar
    • Navigate to : com\android\internal\policy\impl\sec
    • Download attached file, extract it and put WallpaperWidget$1.smali to above folder.
    • In the same folder, open WallpaperWidget.smali
    • before #instance field add following code
      Code:
      # static fields
      .field static mutex_acquired:Z
    • Search for .field private mEnhancedWallpaper:Lcom/android/internal/policy/impl/sec/EnhancedWallpaperWidget; and add this below it
      Code:
      .field private mHandler:Landroid/os/Handler;
    • Search for iput-boolean v2, p0, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->mIsLiveWallpaper:Z and add this below
      Code:
      new-instance v0, Landroid/os/Handler;
      
          invoke-direct {v0}, Landroid/os/Handler;-><init>()V
      
          iput-object v0, p0, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->mHandler:Landroid/os/Handler;
    • after # direct methods add following code
      Code:
      .method static constructor <clinit>()V
          .locals 1
      
          const-string v0, "harsh"
      
          invoke-static {v0}, Ljava/lang/System;->loadLibrary(Ljava/lang/String;)V
      
          const/4 v0, 0x1
      
          sput-boolean v0, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->mutex_acquired:Z
      
          return-void
      .end method
    • Now search for .method public constructor <init>(Landroid/content/Context;Landroid/content/res/Configuration;)V and replace whole method with following :
      Code:
      .method public constructor <init>(Landroid/content/Context;Landroid/content/res/Configuration;)V
          .locals 5
      
          const/4 v4, 0x0
      
          const/4 v3, -0x1
      
          const/4 v2, 0x1
      
          invoke-direct {p0, p1}, Landroid/widget/FrameLayout;-><init>(Landroid/content/Context;)V
      
          const-string v0, "WallpaperWidget"
      
          iput-object v0, p0, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->TAG:Ljava/lang/String;
      
          iput-boolean v2, p0, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->mIsLiveWallpaper:Z
      
          new-instance v0, Landroid/os/Handler;
      
          invoke-direct {v0}, Landroid/os/Handler;-><init>()V
      
          iput-object v0, p0, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->mHandler:Landroid/os/Handler;
      
          const/4 v0, 0x0
      
          iput-object v0, p0, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->mLockScreenWallpaperImage:Landroid/widget/ImageView;
      
          const-string v0, "/data/data/com.sec.android.gallery3d/lockscreen_wallpaper.jpg"
      
          iput-object v0, p0, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->PORTRAIT_WALLPAPER_IMAGE_PATH:Ljava/lang/String;
      
          iput-object p1, p0, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->mContext:Landroid/content/Context;
      
          invoke-virtual {p1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;
      
          move-result-object v0
      
          const-string v1, "lockscreen_wallpaper"
      
          invoke-static {v0, v1, v2}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
      
          move-result v0
      
          if-ne v0, v2, :cond_0
      
          iput-boolean v4, p0, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->mIsLiveWallpaper:Z
      
          :cond_0
          iget-boolean v0, p0, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->mIsLiveWallpaper:Z
      
          if-eqz v0, :cond_1
      
          :goto_0
          return-void
      
          :cond_1
          new-instance v0, Landroid/widget/ImageView;
      
          invoke-direct {v0, p1}, Landroid/widget/ImageView;-><init>(Landroid/content/Context;)V
      
          iput-object v0, p0, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->mLockScreenWallpaperImage:Landroid/widget/ImageView;
      
          iget-object v0, p0, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->mLockScreenWallpaperImage:Landroid/widget/ImageView;
      
          sget-object v1, Landroid/widget/ImageView$ScaleType;->CENTER_CROP:Landroid/widget/ImageView$ScaleType;
      
          invoke-virtual {v0, v1}, Landroid/widget/ImageView;->setScaleType(Landroid/widget/ImageView$ScaleType;)V
      
          iget-object v0, p0, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->mLockScreenWallpaperImage:Landroid/widget/ImageView;
      
          invoke-virtual {p0, v0, v3, v3}, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->addView(Landroid/view/View;II)V
      	
          invoke-direct {p0}, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->BlurImage()V
      
          goto :goto_0
      .end method
      
      .method private BlurImage()V
          .locals 2
      
          new-instance v0, Ljava/lang/Thread;
      
          new-instance v1, Lcom/android/internal/policy/impl/sec/WallpaperWidget$1;
      
          invoke-direct {v1, p0}, Lcom/android/internal/policy/impl/sec/WallpaperWidget$1;-><init>(Lcom/android/internal/policy/impl/sec/WallpaperWidget;)V
      
          invoke-direct {v0, v1}, Ljava/lang/Thread;-><init>(Ljava/lang/Runnable;)V
      
          invoke-virtual {v0}, Ljava/lang/Thread;->start()V
      
          return-void
      .end method
      
      .method static synthetic access$0(Lcom/android/internal/policy/impl/sec/WallpaperWidget;Landroid/graphics/Bitmap;Landroid/graphics/Bitmap;I)V
          .locals 0
      
          invoke-direct {p0, p1, p2, p3}, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->blurImage(Landroid/graphics/Bitmap;Landroid/graphics/Bitmap;I)V
      
          return-void
      .end method
      
      .method static synthetic access$1(Lcom/android/internal/policy/impl/sec/WallpaperWidget;)Landroid/os/Handler;
          .locals 1
      
          iget-object v0, p0, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->mHandler:Landroid/os/Handler;
      
          return-object v0
      .end method
      
      .method private native blurImage(Landroid/graphics/Bitmap;Landroid/graphics/Bitmap;I)V
      .end method
    • Now search for # virtual methods and add this code after it
      Code:
      .method public updateWallpaper()V
          .locals 3
      
          const-string v1, "/data/data/com.sec.android.gallery3d/lockscreen_wallpaper.jpg"
      
          iput-object v1, p0, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->mWallpaperPath:Ljava/lang/String;
      
          new-instance v0, Landroid/graphics/drawable/BitmapDrawable;
      
          invoke-virtual {p0}, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->getResources()Landroid/content/res/Resources;
      
          move-result-object v1
      
          iget-object v2, p0, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->mWallpaperPath:Ljava/lang/String;
      
          invoke-direct {v0, v1, v2}, Landroid/graphics/drawable/BitmapDrawable;-><init>(Landroid/content/res/Resources;Ljava/lang/String;)V
      
          iget-object v1, p0, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->mLockScreenWallpaperImage:Landroid/widget/ImageView;
      
          invoke-virtual {v1, v0}, Landroid/widget/ImageView;->setImageDrawable(Landroid/graphics/drawable/Drawable;)V
      
          return-void
      .end method
    • Follow xperiacle's guide for TRANSPARENT STATUSBAR on lockscreen http://xdaforums.com/showthread.php?t=2384892 (this is required, don't worry, it won't make it transparent)
    • From the extracted files, push libharsh.so to /system/lib/libharsh.so and chmod it to 644 (rw-r--r--)
    • Make sure that /data/data/com.sec.android.gallery3d/lockscreen_wallpaper.png & /data/data/com.sec.android.gallery3d/lockscreen_wallpaper.jpg file exists before you reboot your device. If it doesn't then put any valid png file there with name lockscreen_wallpaper.png/lockscreen_wallpaper.jpg and chmod it to 777
    • We're done :highfive: compile it and push it to device :good:
    • To add toggle for it, read here

    What we're doing here?
    Basically we are taking screenshot when device is getting locked and then we apply blur effect and sets it as wallpaper.
    I know there are many way's to do it but i've preferred hacking WallpaperWidget's constructor. You can go for another way if you want.
    Another thing to tell is that it depend on you device that how much time it'll require to do this process. On my device it nearly take 2 seconds (it depends on background). Multithreading can also be used. Read second post for more info and other tweaks., By default we're using Multi threading :p

    13
    Tips, Tricks & FAQs

    Bugs & Remedies :
    • If multithreading is not enabled & device is woke up suddenly after locking then sometimes device stays unlocked for a moment --> Enabled multithreading or don't wake up device soon after locking it
      [*] When mutithreading is enabled & device is suddenly woke up (soon after locking), it shows older image --> Disable mutithreading or don't wake up device soon after locking it
    All bug are solved..:p


    As this tutorial is written for 4.1.2 (API 16), we don't have native image processing support (which came in API 17).This is the reason why it takes long time to blur image. As told above, i' trying to implement native method for blurring image anybody interested in it can help me.


    Tweaks :
    • Blur Radius : (Value in Hex)
      Code:
      .local v4, out:Landroid/graphics/Bitmap;
          const/16 v5, [COLOR="Red"]0x19[/COLOR]
      (lower radius --> better performance)
    • JPEG Quility: (Value in Hex)
      Code:
      .local v1, bytes:Ljava/io/ByteArrayOutputStream;
          sget-object v5, Landroid/graphics/Bitmap$CompressFormat;->JPEG:Landroid/graphics/Bitmap$CompressFormat;
      
          const/16 v6, [COLOR="red"]0x64[/COLOR]
      Lower Quality --> better performance, weird colors

    Changelog:
    • 26th May 2014 --> Solved bug with delay while locking, Uses Multi Threading by default
    • xth February 2014 --> Native function Implementation (x > 6 :p)
    • 6th February 2014 --> Initial Release
    7
    Updated thread with new implementation. Now we are using Native function to blur image which is ~60% faster than previous implementation. Follow tutorial again if you've already done so.




    when i use this, can i still use normal wallpapers if i want? or does that need a toggle or something like that?

    +1

    @BOOTMGR, Please make a short tutorial (if possible) for setting up a Toggle to switch it on or off from the Settings app :good:

    Adding toggle in secsetting is easy but only reason behind not providing it is that some people would have enabled AOSP lockscreen in that case method will be slightly different. But you can follow this tutorial to add toggle for it using build.prop



    How to add Toggle :

    • Follow main tutorial
    • Inside WallpaperWidget.smali, search for invoke-direct {p0}, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->BlurImage()V and add following code above it
      Code:
      const-string v0, "ro.harsh.blurlockscreen"
      
          invoke-static {v0, v2}, Landroid/os/SystemProperties;->getBoolean(Ljava/lang/String;Z)Z
      
          move-result v0
      
          if-eqz v0, :cond_2
    • Search below for .end method (2 - 3 lines down) and add this below it
      Code:
      :cond_2
          invoke-direct {p0}, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->setLockScreenWallpaper()V
      
          goto :goto_0
    • That's all. Compile it.
    Now you can toggle its state by adding ro.harsh.blurlockscreen=true or ro.harsh.blurlockscreen=false
    You can also type in terminal setprop ro.harsh.blurlockscreen true/false to toggle state on the fly.
    3
    Thanks @BOOTMGR for this effect, I have try to insert a smali to activate this effect with checkbox on the "fly" and it was a success :)
    I would like to share the code that I inserted with you.
    First search this line in WallpaperWidget:
    Code:
    invoke-direct {p0}, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->BlurImage()V
    Under this line insert this code:
    Code:
    iget-object v0, p0, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->mContext:Landroid/content/Context;
    
        invoke-virtual {v0}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;
    
        move-result-object v0
    
        const-string v1, "blur_checkbox"
    
        invoke-static {v0, v1, v2}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
    
        move-result v0
    
        if-ne v0, v2, :cond_2
    	
        .line 63
        invoke-virtual {p0}, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->updateWallpaper()V
    
        goto :goto_0
    	
    	:cond_2
        invoke-direct {p0}, Lcom/android/internal/policy/impl/sec/WallpaperWidget;->setLockScreenWallpaper()V
    
        goto :goto_0
    .end method
    I hope I have been of help :)
    3
    Upgrading Android OS...
    Opening apllications...


    I'm getting this again and again after I reboot my device, I think the files aren't compatible with my 4.1.2 TW deodexed.. :(
    but this mod looks so cool, I want this :)

    It should be. Check again that & make sure you did everything properly. Did you pushed libharsh.so to /system/lib and changed its permission?


    Seems interesting, great work! :) btw is this tut possible for CM11 roms? I would like to try compiling this on our CM11 builds :)

    You can do it easily by Xposed. Gravitybox doesnot suppot this on 4.1.2 because of unavailable API

    Is there anyway to make this into an xposed module?

    Making this available through xposed is very easy. I make module later when i'll be free.