// Path: src/com/painless/glclock/Globals.java
// public class Globals {
// 
// 	public static float compassRotation = 0;
// 
// 	public static int cpuUsage = 0;
// 	public static int cpuUsageAngle = 0;
// 
// 	public static int battery = 0;
// 	public static int batteryCount = 0;
// 
// 	public static int ramUsage = 0;
// }


import android.os.Handler;
import com.painless.glclock.Globals;
import java.io.RandomAccessFile;
package com.painless.glclock.service;




public final class RamService implements Runnable, RService {

	private static final long REFRESH_RATE = 15000;	// 15 seconds.

	private final Handler updateHandler;

	private boolean running = false;

	public RamService() {
		updateHandler = new Handler();
	}

	@Override
	public void run() {
		try {
			final RandomAccessFile reader = new RandomAccessFile("/proc/meminfo", "r");
			long memFree = 0, memTotal = 0;

			int readCount = 0, foundCount = 0;
			String line;
			// read maximum 10 lines and find 3 items.
			while (readCount < 10 && foundCount < 3) {
				line = reader.readLine().toLowerCase();
				if (line.startsWith("memtotal")) {
					memTotal = readMemInfo(line);
					foundCount++;
				} else if (line.startsWith("memfree") || line.startsWith("cached")) {
					memFree += readMemInfo(line);
					foundCount++;
				}
				readCount++;
			}
			reader.close();

			final long percent = 100 - (memFree * 100 / memTotal);
// Path: src/com/painless/glclock/Globals.java
// public class Globals {
// 
// 	public static float compassRotation = 0;
// 
// 	public static int cpuUsage = 0;
// 	public static int cpuUsageAngle = 0;
// 
// 	public static int battery = 0;
// 	public static int batteryCount = 0;
// 
// 	public static int ramUsage = 0;
// }


// Path: src/com/painless/glclock/service/RamService.java
import android.os.Handler;
import com.painless.glclock.Globals;
import java.io.RandomAccessFile;

package com.painless.glclock.service;




public final class RamService implements Runnable, RService {

	private static final long REFRESH_RATE = 15000;	// 15 seconds.

	private final Handler updateHandler;

	private boolean running = false;

	public RamService() {
		updateHandler = new Handler();
	}

	@Override
	public void run() {
		try {
			final RandomAccessFile reader = new RandomAccessFile("/proc/meminfo", "r");
			long memFree = 0, memTotal = 0;

			int readCount = 0, foundCount = 0;
			String line;
			// read maximum 10 lines and find 3 items.
			while (readCount < 10 && foundCount < 3) {
				line = reader.readLine().toLowerCase();
				if (line.startsWith("memtotal")) {
					memTotal = readMemInfo(line);
					foundCount++;
				} else if (line.startsWith("memfree") || line.startsWith("cached")) {
					memFree += readMemInfo(line);
					foundCount++;
				}
				readCount++;
			}
			reader.close();

			final long percent = 100 - (memFree * 100 / memTotal);
			Globals.ramUsage = (int) percent;