forked from rs-sr/E-Ink-Launcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add front light controlling function for JDRead1
- Loading branch information
Showing
6 changed files
with
406 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
app/src/main/java/cn/modificator/launcher/jdreadutil/DeviceControl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package cn.modificator.launcher.jdreadutil; | ||
|
||
import android.content.Context; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
public class DeviceControl { | ||
|
||
private Class<?> classForName; | ||
private Method getFrontLightValueMethod; | ||
private Method setFrontLightValueMethod; | ||
private Method getFrontLightConfigValueMethod; | ||
private Method setFrontLightConfigValueMethod; | ||
|
||
public DeviceControl(){ | ||
classForName = ReflectUtil.classForName("android.onyx.hardware.DeviceController"); | ||
getFrontLightValueMethod = ReflectUtil.getMethodSafely(classForName, "getFrontLightValue", Context.class); | ||
getFrontLightConfigValueMethod = ReflectUtil.getMethodSafely(classForName, "getFrontLightConfigValue", Context.class); | ||
setFrontLightValueMethod = ReflectUtil.getMethodSafely(classForName, "setFrontLightValue", Context.class, Integer.TYPE); | ||
setFrontLightConfigValueMethod = ReflectUtil.getMethodSafely(classForName, "setFrontLightConfigValue", Context.class, Integer.TYPE);; | ||
} | ||
|
||
|
||
public int getFrontLightValue(Context context) | ||
{ | ||
return (Integer) invokeMethod(context,getFrontLightValueMethod, context); | ||
} | ||
public void setFrontLightValue(Context context,int v) | ||
{ | ||
invokeMethod(context, setFrontLightValueMethod, new Object[]{context, v}); | ||
} | ||
public int getFrontLightConfigValue(Context context) | ||
{ | ||
return (Integer) invokeMethod(context,getFrontLightValueMethod, context); | ||
} | ||
public void setFrontLightConfigValue(Context context,int v) | ||
{ | ||
invokeMethod(context, setFrontLightConfigValueMethod, new Object[]{context, v}); | ||
} | ||
|
||
|
||
private Object invokeMethod(Context context, Method method, Object... objArr) { | ||
if (method == null) { | ||
return null; | ||
} | ||
return ReflectUtil.invokeMethodSafely(method, null, objArr); | ||
} | ||
|
||
|
||
} |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/cn/modificator/launcher/jdreadutil/RefValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package cn.modificator.launcher.jdreadutil; | ||
|
||
public class RefValue<T> { | ||
private T a = null; | ||
|
||
public RefValue() { | ||
} | ||
|
||
public RefValue(T t) { | ||
this.a = t; | ||
} | ||
|
||
public T getValue() { | ||
return this.a; | ||
} | ||
|
||
public void setValue(T t) { | ||
this.a = t; | ||
} | ||
} |
Oops, something went wrong.