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

Search This thread

Toni5830

Senior Member
Jul 30, 2012
603
439
Somewhere over the Rainbow
Hi, I want to modify a android.policy.jar file, because I would like to do the "new" lockscreen.
I copy .jar file to apktool folder and open the file with (7zip, winRAR) and no classes.dex file.

This is why?:confused:

I attached a screenshot and android.policy.jar file.

Thanks in advanced. Sorry for my English.;)

you must deoedex your firmware before..
search a deodexed zip of your firmware version
 

nokiae668

Member
Jun 14, 2013
12
0
34
Hi, I only make a toggle on lockscreen.

I added a some lines in top:

.class public
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

Lcom/android/internal/policy/impl/sec/WallpaperWidget;

And added 2-3 lines a bottom.

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

goto :goto_0


I follow this guide.;)
This is good?
 

emmantot

Member
Sep 30, 2014
20
2
Hi, will this work on a stock rom? How about a blur pull-down menu? I'm using galaxy star stock deodexed rom
 
Last edited:

Sami Kabir

Senior Member
Oct 3, 2012
2,233
1,410
Hi, will this work on a stock rom? How about a blur pull-down menu? I'm using galaxy star stock deodexed rom

Yes, it is specifically made for stock 4.1.2 firmware based ROMs only. And about blurry pull down menu, I don't know how you can get that, but I do know how to make it semi or completely transparent (screenshot). You'll have to edit tw_status_bar_expanded.xml in (SystemUI.apk/res/layout).

Look for:
HTML:
android:id="@id/notification_panel" android:background="@drawable/notification_panel_bg"

Replace @drawable/notification_panel_bg with #xx000000. Now change "xx" to either 00 (for 100% transparency), 3f (for 75% transparency), 7f (for 50% transparency) or bf (for 25% transparency).

For more info, checkout this thread: http://xdaforums.com/showthread.php?t=2203166
 
  • Like
Reactions: emmantot

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.