Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8f479cb authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 7744

* changes:
  Make Process.getFreeMemory() return a long instead of an int, to better work on the simulator now, and phones 2 years from now.
parents cf541ee1 0bca96bc
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -739,7 +739,7 @@ public class Process {
    public static final native void sendSignal(int pid, int signal);
    
    /** @hide */
    public static final native int getFreeMemory();
    public static final native long getFreeMemory();
    
    /** @hide */
    public static final native void readProcLines(String path,
+4 −4
Original line number Diff line number Diff line
@@ -368,7 +368,7 @@ static int pid_compare(const void* v1, const void* v2)
    return *((const jint*)v1) - *((const jint*)v2);
}

jint android_os_Process_getFreeMemory(JNIEnv* env, jobject clazz)
static jlong android_os_Process_getFreeMemory(JNIEnv* env, jobject clazz)
{
    int fd = open("/proc/meminfo", O_RDONLY);
    
@@ -388,7 +388,7 @@ jint android_os_Process_getFreeMemory(JNIEnv* env, jobject clazz)
    buffer[len] = 0;

    int numFound = 0;
    int mem = 0;
    jlong mem = 0;
    
    static const char* const sums[] = { "MemFree:", "Cached:", NULL };
    static const int sumsLen[] = { strlen("MemFree:"), strlen("Cached:"), NULL };
@@ -407,7 +407,7 @@ jint android_os_Process_getFreeMemory(JNIEnv* env, jobject clazz)
                    p++;
                    if (*p == 0) p--;
                }
                mem += atoi(num) * 1024;
                mem += atoll(num) * 1024;
                numFound++;
                break;
            }
@@ -857,7 +857,7 @@ static const JNINativeMethod methods[] = {
    {"setGid", "(I)I", (void*)android_os_Process_setGid},
    {"sendSignal", "(II)V", (void*)android_os_Process_sendSignal},
    {"supportsProcesses", "()Z", (void*)android_os_Process_supportsProcesses},
    {"getFreeMemory", "()I", (void*)android_os_Process_getFreeMemory},
    {"getFreeMemory", "()J", (void*)android_os_Process_getFreeMemory},
    {"readProcLines", "(Ljava/lang/String;[Ljava/lang/String;[J)V", (void*)android_os_Process_readProcLines},
    {"getPids", "(Ljava/lang/String;[I)[I", (void*)android_os_Process_getPids},
    {"readProcFile", "(Ljava/lang/String;[I[Ljava/lang/String;[J[F)Z", (void*)android_os_Process_readProcFile},