Displaying System Status like Memory, CPU Etc..

Put your problem here if it does not fit any of the other categories.

Displaying System Status like Memory, CPU Etc..

Postby techlogik » Wed Jun 23, 2010 10:29 pm

I've done some apktool decompiling of the emulator Settings.apk for 2.1, and the code looks like a foreign language to me...

Pretty new to Java...and this looks nothing like Java to me...haha..

I'm trying to access in an application and display cpu speed, cpu history, memory usage etc..

Having trouble making sense of the debug files code or resources to call form the android library to display info as such.

I'm lost with the following code....example, this is from the BatteryHistory.java it created...I see CPU mentioned and some class declaration of some sort...I'm clueless on this obviously. Particularly how things are declared which aren't standard Java that I know if they are declarations of the Java type...hah

Any guidance appreciated to get me heading/reading in the right direction to learn some stuff would be great.

Thanks


BatteryHistory.java

package com.android.settings.battery_history; class BatteryHistory {/*

.class public Lcom/android/settings/battery_history/BatteryHistory;
.super Landroid/app/Activity;
.source "BatteryHistory.java"

# interfaces
.implements Landroid/view/View$OnClickListener;
.implements Landroid/widget/AdapterView$OnItemSelectedListener;


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
value = {
Lcom/android/settings/battery_history/BatteryHistory$MiscUsage;,
Lcom/android/settings/battery_history/BatteryHistory$WakelockUsage;,
Lcom/android/settings/battery_history/BatteryHistory$SensorUsage;,
Lcom/android/settings/battery_history/BatteryHistory$NetworkUsage;,
Lcom/android/settings/battery_history/BatteryHistory$CpuUsage;,
Lcom/android/settings/battery_history/BatteryHistory$Graphable;
}
.end annotation


# instance fields
.field mBatteryInfo:Lcom/android/internal/app/IBatteryStats;

.field private mButtons:[Lcom/android/settings/battery_history/GraphableButton;

.field private mCpuUsage:Ljava/util/List;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/List",
"<",
"Lcom/android/settings/battery_history/BatteryHistory$CpuUsage;",
">;"
}
.end annotation
.end field

# static fields
.field private static final CPU_USAGE:I = 0x0

.field private static final CURRENT:I = 0x1


blah..blah..it goes on and on....
techlogik
Junior Developer
Junior Developer
 
Posts: 10
Joined: Tue Jun 22, 2010 6:40 pm

Top

Re: Displaying System Status like Memory, CPU Etc..

Postby anarche » Thu Jun 24, 2010 12:49 am

Download the source code...
anarche
Master Developer
Master Developer
 
Posts: 369
Joined: Sun Apr 11, 2010 5:21 am

Re: Displaying System Status like Memory, CPU Etc..

Postby techlogik » Thu Jun 24, 2010 3:12 pm

anarche wrote:Download the source code...



Haha...oh...duh...how easy is that?!?! I forget being around Windows development for so long you can easily get the source code!!!

Does somebody have a .zip for windows already make up for Eclipse somewhere to download? It's a mess and need to sort it out on linux first to get it..pain.

Thanks
techlogik
Junior Developer
Junior Developer
 
Posts: 10
Joined: Tue Jun 22, 2010 6:40 pm

Re: Displaying System Status like Memory, CPU Etc..

Postby anarche » Fri Jun 25, 2010 5:47 am

*chuckles* no unfortunately I don't.

Why don't you pull it for Linux and compile through cygwin?
anarche
Master Developer
Master Developer
 
Posts: 369
Joined: Sun Apr 11, 2010 5:21 am

Re: Displaying System Status like Memory, CPU Etc..

Postby techlogik » Sat Jun 26, 2010 2:54 am

anarche wrote:*chuckles* no unfortunately I don't.

Why don't you pull it for Linux and compile through cygwin?



Well, I got the source. I ended up setting up a vmware ubuntu and am running/developing on that now and have the source.

Unfortunately, I have searched high/low, even on google source, and can't find any classes that specifically make calls for current memory in use, all types of memory, or cpu speed etc...

The standard sources I don't see where they exist. I know I can do a linux command from bash like /proc/stat and what not, maybe make it loop and sample it or something....don't know. Running in circles on this one.
techlogik
Junior Developer
Junior Developer
 
Posts: 10
Joined: Tue Jun 22, 2010 6:40 pm

Re: Displaying System Status like Memory, CPU Etc..

Postby anarche » Tue Jun 29, 2010 5:52 am

My god!

I'm thinking that - since the kernel code is written/compiled C/C++, that there are no java source classes for them?

Did you get the C/C++ libs for the kernel?
anarche
Master Developer
Master Developer
 
Posts: 369
Joined: Sun Apr 11, 2010 5:21 am

Top

Re: Displaying System Status like Memory, CPU Etc..

Postby techlogik » Sat Jul 03, 2010 2:33 am

anarche wrote:My god!

I'm thinking that - since the kernel code is written/compiled C/C++, that there are no java source classes for them?

Did you get the C/C++ libs for the kernel?



Yes, and the more I research it, it seems maybe some guys are doing JNI to run C code in Java apps etc..to do that.

There are really useless, or nonexistent Java stuff in the Android API for this type of hardware inquires to return information. And of course, the peopel that know don't like to share their knowledge it seems.
techlogik
Junior Developer
Junior Developer
 
Posts: 10
Joined: Tue Jun 22, 2010 6:40 pm

Re: Displaying System Status like Memory, CPU Etc..

Postby anarche » Sat Jul 03, 2010 2:38 am

Quite frankly I don't want this information shared with the general public.

How much damage could be done to mobiles with this api...

while (cpu.getSpeed() > 0) { cpu.setSpeed(cpu.getSpeed() * 10)); }

ouch!
anarche
Master Developer
Master Developer
 
Posts: 369
Joined: Sun Apr 11, 2010 5:21 am

Re: Displaying System Status like Memory, CPU Etc..

Postby techlogik » Sat Jul 03, 2010 4:04 pm

anarche wrote:Quite frankly I don't want this information shared with the general public.

How much damage could be done to mobiles with this api...

while (cpu.getSpeed() > 0) { cpu.setSpeed(cpu.getSpeed() * 10)); }

ouch!



There is no harm is returning hardware information to a user...it is done all the time, I just don't know the best way to handle this.

Next, hang out at xda-developers much? The C code is there for the kernel overclocking, along with overlcocked kernels and Roms.

I run a Desire Rom on my Nexus One....I need the excellent Exchange support.

I'm probably going to have to do this backwards and do it from the Kernel side, using C and some code that is out there already and use JNI to implement it in Java. Seems like the only way to return the current CPU speed and update it on the screen along with memory etc...I've searched high/low in the source Android APIU and github....there are a few memory call Java class files out there, and some straing cpu stuff that makes no sense and doesn't seem implemented.

I'm going to get the Kernel source next and start going through that.

Thx
techlogik
Junior Developer
Junior Developer
 
Posts: 10
Joined: Tue Jun 22, 2010 6:40 pm

Re: Displaying System Status like Memory, CPU Etc..

Postby anarche » Sun Jul 04, 2010 4:09 am

Yeah, used responsibly these are fine. Used irresponsibly on your own phone (for overclocking and stuff) - fine.

Any setters are obviously a security threat, particular for a user that doesn't read their permissions when installing an apk. And getters (x = IMEI.read(); y=new Intent(this, Action.SEND); y.setIntExtra(x)) can be used maliciously.

That's why I'd prefer they aren't in the API.
anarche
Master Developer
Master Developer
 
Posts: 369
Joined: Sun Apr 11, 2010 5:21 am

Re: Displaying System Status like Memory, CPU Etc..

Postby techlogik » Tue Jul 06, 2010 2:12 am

anarche wrote:Yeah, used responsibly these are fine. Used irresponsibly on your own phone (for overclocking and stuff) - fine.

Any setters are obviously a security threat, particular for a user that doesn't read their permissions when installing an apk. And getters (x = IMEI.read(); y=new Intent(this, Action.SEND); y.setIntExtra(x)) can be used maliciously.

That's why I'd prefer they aren't in the API.



I'm referring to basic APIs in every operating system, like memory available, utilized, threads, processor utilization and so forth.

The Kernel can be overclocked, that is the open source nature of Linux as well as Windows to those that want.

There is no security risk is querying system information that is in every other task manager and operating system.
techlogik
Junior Developer
Junior Developer
 
Posts: 10
Joined: Tue Jun 22, 2010 6:40 pm

Re: Displaying System Status like Memory, CPU Etc..

Postby anarche » Tue Jul 06, 2010 2:22 am

Really? And nobody's ever written a rootkit for linux?

I still hold that - in the standard API (for non-rooted phones) - I'm very glad that setters for the system is not available. Its my opinion, it may be a little paranoid and I'm ok with that ;p

Now pass me my tinfoil hat!
anarche
Master Developer
Master Developer
 
Posts: 369
Joined: Sun Apr 11, 2010 5:21 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 13 guests