-
Notifications
You must be signed in to change notification settings - Fork 25
/
NSProcessInfoUtils.java
37 lines (31 loc) · 1.21 KB
/
NSProcessInfoUtils.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package ca.weblite.objc;
/**
* Created by IntelliJ IDEA.
* User: remicartier (remi.cartier@gmail.com)
* Date: 2014-08-06
* Time: 8:13 PM
*/
public class NSProcessInfoUtils {
private final static long NSActivityUserInitiated = (0x00FFFFFFL | (1L << 20));
/**
* To ensure Mac OS X doesn't slow down your app because of App Nap, call this method
* @param reason the reason for allowing the app to work at full speed
* @return the activity id as a Proxy object
*/
public static Proxy beginActivityWithOptions(String reason) {
Client c = Client.getInstance();
Proxy processInfo = c.sendProxy("NSProcessInfo", "processInfo");
return processInfo.sendProxy("beginActivityWithOptions:reason:", NSActivityUserInitiated, reason);
}
/**
* When the activity is finished, to re-enable app napping call this method
* @param activity previously returned by beginActivityWithOptions()
*/
public static void endActivity(Proxy activity) {
if (activity != null) {
Client c = Client.getInstance();
Proxy processInfo = c.sendProxy("NSProcessInfo", "processInfo");
processInfo.send("endActivity:", activity);
}
}
}