Skip to content

Commit de66e67

Browse files
Xavier DucrohetAndroid (Google) Code Review
authored andcommitted
Merge "Add some new native deletage to layoutlib." into jb-mr1-dev
2 parents 035ce2c + 5eb51de commit de66e67

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
*/
3232
public class SystemClock_Delegate {
3333
private static long sBootTime = System.currentTimeMillis();
34+
private static long sBootTimeNano = System.nanoTime();
3435

3536
@LayoutlibDelegate
3637
/*package*/ static boolean setCurrentTimeMillis(long millis) {
@@ -59,6 +60,16 @@ public class SystemClock_Delegate {
5960
return System.currentTimeMillis() - sBootTime;
6061
}
6162

63+
/**
64+
* Returns nanoseconds since boot, including time spent in sleep.
65+
*
66+
* @return elapsed nanoseconds since boot.
67+
*/
68+
@LayoutlibDelegate
69+
/*package*/ static long elapsedRealtimeNano() {
70+
return System.nanoTime() - sBootTimeNano;
71+
}
72+
6273
/**
6374
* Returns milliseconds running in the current thread.
6475
*

tools/layoutlib/bridge/src/android/util/FloatMath_Delegate.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,42 @@ private FloatMath_Delegate() {}
9191
/*package*/ static float sqrt(float value) {
9292
return (float)Math.sqrt(value);
9393
}
94+
95+
/**
96+
* Returns the closest float approximation of the raising "e" to the power
97+
* of the argument.
98+
*
99+
* @param value to compute the exponential of
100+
* @return the exponential of value
101+
*/
102+
@LayoutlibDelegate
103+
/*package*/ static float exp(float value) {
104+
return (float)Math.exp(value);
105+
}
106+
107+
/**
108+
* Returns the closest float approximation of the result of raising {@code
109+
* x} to the power of {@code y}.
110+
*
111+
* @param x the base of the operation.
112+
* @param y the exponent of the operation.
113+
* @return {@code x} to the power of {@code y}.
114+
*/
115+
@LayoutlibDelegate
116+
/*package*/ static float pow(float x, float y) {
117+
return (float)Math.pow(x, y);
118+
}
119+
120+
/**
121+
* Returns {@code sqrt(}<i>{@code x}</i><sup>{@code 2}</sup>{@code +} <i>
122+
* {@code y}</i><sup>{@code 2}</sup>{@code )}.
123+
*
124+
* @param x a float number
125+
* @param y a float number
126+
* @return the hypotenuse
127+
*/
128+
@LayoutlibDelegate
129+
/*package*/ static float hypot(float x, float y) {
130+
return (float)Math.sqrt(x*x + y*y);
131+
}
94132
}

0 commit comments

Comments
 (0)