Post Reply

I'd like to decrease dialer vibration and I need help with that..

OP S0bes

27th August 2014, 03:45 PM   |  #1  
S0bes's Avatar
OP Senior Member
Flag Tomsk
Thanks Meter: 326
 
319 posts
Join Date:Joined: Jan 2012
Donate to Me
More
I'm completely noob.
Here are the sources
http://grepcode.com/file/repository....mHapticPattern

Code:
public void init(Context context, boolean enabled) {
     mEnabled = enabled;
       if (enabled) 
          {
          mVibrator = new SystemVibrator(context);
          mHapticPattern = new long[] {0, DURATION, 2 * DURATION, 3 * DURATION};
          mSystemSettings = new Settings.System();
          mContentResolver = context.getContentResolver();
        }
    }
I need to change mHapticPattern array to adjust vibration duration on dialpad.
So, I can use that

Code:
findAndHookMethod("com.android.phone.common.HapticFeedback", lpparam.classLoader, "init", new XC_MethodHook() 
	    {
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
            	// BUT I don't know what I have to write here to get it working :(
// I know that this method will be called after init method and I don't know how I can change mHapticPattern array :(
            
            }
    });
Or I think I can also change value of Duration
Quote:

private static final long DURATION = 10;

But anyway I do not know how...
I will be glad if anyone will try to help me...
The Following 2 Users Say Thank You to S0bes For This Useful Post: [ View ]
30th August 2014, 02:32 PM   |  #2  
GermainZ's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Thanks Meter: 6,743
 
5,694 posts
Join Date:Joined: Aug 2012
Donate to Me
More
Changing DURATION directly will have no effect. This is because the compiler replaces final static variables with their values (so "10" will be directly used instead of "DURATION").

What you could do is replace the init(Context context, boolean enabled) method entirely. Check out the development tutorial (and other wiki pages) for some hints on where to get started.
The Following User Says Thank You to GermainZ For This Useful Post: [ View ]
8th September 2014, 09:39 AM   |  #3  
S0bes's Avatar
OP Senior Member
Flag Tomsk
Thanks Meter: 326
 
319 posts
Join Date:Joined: Jan 2012
Donate to Me
More
Quote:
Originally Posted by GermainZ

Changing DURATION directly will have no effect. This is because the compiler replaces final static variables with their values (so "10" will be directly used instead of "DURATION").

What you could do is replace the init(Context context, boolean enabled) method entirely. Check out the development tutorial (and other wiki pages) for some hints on where to get started.

Thank you for your answer. But I did not see it till now. That's why my respond is so late.
I had one experience with replacing entire method. But it was just a boolean method. I used this example http://forum.xda-developers.com/show...60&postcount=4

And also I've tried to replace whole init method but I have a problem with that string:
Code:
mVibrator = new SystemVibrator(context);
I did
import android.os.SystemVibrator;
but this "android.os.SystemVibrator;" is highlighted with red in eclipse
It says "The import android.os.SystemVibrator cannot be resolved" but the file exists...
I have a code but because of that error I can't test it
Attached Files
File Type: txt code.txt - [Click for QR Code] (3.3 KB, 1 views)
8th September 2014, 10:20 AM   |  #4  
GermainZ's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Thanks Meter: 6,743
 
5,694 posts
Join Date:Joined: Aug 2012
Donate to Me
More
Quote:
Originally Posted by S0bes

It says "The import android.os.SystemVibrator cannot be resolved" but the file exists...

It's possible it's not in the SDK. Use XposedHelpers.findClass(...) to get the SystemVibrator class, then XposedHelpers.newInstance(...) to create a new instance.
The Following User Says Thank You to GermainZ For This Useful Post: [ View ]
28th September 2014, 09:50 AM   |  #5  
S0bes's Avatar
OP Senior Member
Flag Tomsk
Thanks Meter: 326
 
319 posts
Join Date:Joined: Jan 2012
Donate to Me
More
@GermainZ please help me. This is the last thing I want to implement. Dialpad vibration is heavy and I think it's not good for vibro inside my phone.
This is what I try but Vibration is gone after that:
PHP Code:
package com.s0bes.fmspeaker;

import android.content.Context;
import android.os.Vibrator;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import static de.robv.android.xposed.XposedHelpers.findClass;
import static de.robv.android.xposed.XposedHelpers.newInstance;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
import android.content.ContentResolver;
import android.provider.Settings;
//import android.os.SystemVibrator;

public class bool1 {
    static 
Context context;
    private static 
Vibrator mVibrator ;    
    private static 
Settings.System mSystemSettings;
    private static 
ContentResolver mContentResolver;
    private static 
long[] mHapticPattern;
    public static 
void InitResources(final LoadPackageParam lpparamthrows Throwable {  
        
        
         if (
lpparam.packageName.equals("com.android.dialer")) { 
             
             
XposedHelpers.findAndHookMethod("com.android.phone.common.HapticFeedback"lpparam.classLoader,
                     
"init"Context.class, boolean.class, new XC_MethodHook() {

                 @
Override protected void beforeHookedMethod(final MethodHookParam paramthrows Throwable {
                                 
XposedBridge.log("HOOOKED init" );
                                 
//context=(Context) param.args[0];
                 
}
             });
                          
             
             
XposedHelpers.findAndHookMethod("com.android.phone.common.HapticFeedback"lpparam.classLoader"init"Context.class, boolean.class, new XC_MethodReplacement() {
                             
                 @
Override
                
protected Object replaceHookedMethod(MethodHookParam paramthrows Throwable {
                    
context=(Contextparam.args[0];
                    
                    
XposedBridge.log("REPLACED init. Enabled="+param.args[1] );
                    
                    Class 
Myclass findClass("android.os.SystemVibrator"lpparam.classLoader);
                    
Object mVibrator newInstance(Myclasscontext); 
                    
                    
                     
mHapticPattern = new long[] {0101010};    
                     
mSystemSettings = new Settings.System();
                     
mContentResolver context.getContentResolver();
                    
                     return 
true;
                    }
                });
                              
                      
         }                
     }
                 


EDIT:
Yeehoooo. I got this working
Your post http://forum.xda-developers.com/show...41&postcount=8 very helped me.
Instead replace init method I replaced vibrate();
PHP Code:
XposedHelpers.findAndHookMethod("com.android.phone.common.HapticFeedback"lpparam.classLoader"vibrate", new XC_MethodReplacement() {
                             
                 @
Override
                
protected Object replaceHookedMethod(MethodHookParam paramthrows Throwable {
                                    
                    Class 
Myclass findClass("android.os.SystemVibrator"lpparam.classLoader);
                    
Object mVibrator newInstance(Myclasscontext); 
                    
                     
mHapticPattern = new long[] {0101010};    
                     ((
VibratormVibrator).vibrate(mHapticPattern, -1);
                                         
                     return 
true;
                    }
                });
                              
                      
         } 
Last edited by S0bes; 28th September 2014 at 10:00 AM.
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Xposed General by ThreadRank