Android OS Forum banner
1 - 1 of 1 Posts

·
Premium Member
Joined
·
1,155 Posts
Discussion Starter · #1 ·
This was more or less the same method I used before, but this time for battery percentage.

Same procedure as before:
  1. decompile services.jar
  2. open com/android/server/status/StatusBarPolicy.smali
  3. do the edits below
  4. compile
  5. push in recovery/flash

first, make the system think we're dealing with text

find
Code:
    .line 524<br />
    const-string v3, "battery"<br />
<br />
    const v4, 0x10802ae<br />
<br />
    invoke-static {v3, v7, v4, v6, v6}, Lcom/android/server/status/IconData;->makeIcon(Ljava/lang/String;Ljava/lang/String;III)Lcom/android/server/status/IconData;<br />
<br />
    move-result-object v3<br />
<br />
    iput-object v3, p0, Lcom/android/server/status/StatusBarPolicy;->mBatteryData:Lcom/android/server/status/IconData;<br />
<br />
    .line 526<br />
    iget-object v3, p0, Lcom/android/server/status/StatusBarPolicy;->mBatteryData:Lcom/android/server/status/IconData;<br />
<br />
    invoke-virtual {p2, v3, v7}, Lcom/android/server/status/StatusBarService;->addIcon(Lcom/android/server/status/IconData;Lcom/android/server/status/NotificationData;)Landroid/os/IBinder;<br />
<br />
    move-result-object v3<br />
<br />
    iput-object v3, p0, Lcom/android/server/status/StatusBarPolicy;->mBatteryIcon:Landroid/os/IBinder;
and replace it with this

Code:
    const-string v3, "battery"<br />
<br />
    const-string v4, "?% "<br />
<br />
    invoke-static {v3, v4}, Lcom/android/server/status/IconData;->makeText(Ljava/lang/String;Ljava/lang/CharSequence;)Lcom/android/server/status/IconData;<br />
<br />
    move-result-object v3<br />
<br />
    iput-object v3, p0, Lcom/android/server/status/StatusBarPolicy;->mBatteryData:Lcom/android/server/status/IconData;<br />
<br />
    .line 9991<br />
    iget-object v3, p0, Lcom/android/server/status/StatusBarPolicy;->mBatteryData:Lcom/android/server/status/IconData;<br />
<br />
    invoke-virtual {p2, v3, v7}, Lcom/android/server/status/StatusBarService;->addIcon(Lcom/android/server/status/IconData;Lcom/android/server/status/NotificationData;)Landroid/os/IBinder;<br />
<br />
    move-result-object v3<br />
<br />
    iput-object v3, p0, Lcom/android/server/status/StatusBarPolicy;->mBatteryIcon:Landroid/os/IBinder;
next replace the updateBattery() method with this one

Code:
.method private final updateBatteryNum()V<br />
	.registers 10<br />
<br />
	.prologue<br />
	const-string v5, ""	<br />
	<br />
	:cond_1	<br />
	iget v1, p0, Lcom/android/server/status/StatusBarPolicy;->mBatteryLevel:I<br />
	<br />
	new-instance v5, Ljava/lang/StringBuilder;<br />
<br />
	invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V<br />
<br />
	invoke-virtual {v5, v1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;<br />
<br />
	move-result-object v5<br />
		<br />
	const-string v1, "%"<br />
	<br />
	invoke-virtual {v5, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;<br />
<br />
	move-result-object v5<br />
	<br />
	goto :goto_1<br />
	<br />
	if-nez v4, :cond_1<br />
	<br />
	:goto_1<br />
	.line 106<br />
	iget-object v2, p0, Lcom/android/server/status/StatusBarPolicy;->mBatteryTextData:Lcom/android/server/status/IconData;<br />
<br />
	.line 107<br />
	iput-object v5, v2, Lcom/android/server/status/IconData;->text:Ljava/lang/CharSequence;<br />
<br />
	.line 762<br />
	iget-object v5, p0, Lcom/android/server/status/StatusBarPolicy;->mService:Lcom/android/server/status/StatusBarService;<br />
<br />
	iget-object v6, p0, Lcom/android/server/status/StatusBarPolicy;->mBatteryTextIcon:Landroid/os/IBinder;<br />
<br />
	iget-object v7, p0, Lcom/android/server/status/StatusBarPolicy;->mBatteryTextData:Lcom/android/server/status/IconData;<br />
<br />
	const/4 v8, 0x0<br />
<br />
	invoke-virtual {v5, v6, v7, v8}, Lcom/android/server/status/StatusBarService;->updateIcon(Landroid/os/IBinder;Lcom/android/server/status/IconData;Lcom/android/server/status/NotificationData;)V<br />
	<br />
	return-void<br />
.end method
ok, now my method is a little different and it doesn't take any inputs, so we're gonna have to modify the call to it

find this:
Code:
.method static synthetic access$300(Lcom/android/server/status/StatusBarPolicy;Landroid/content/Intent;)V<br />
    .registers 2<br />
    .parameter "x0"<br />
    .parameter "x1"<br />
<br />
    .prologue<br />
    .line 111<br />
    invoke-direct {p0, p1}, Lcom/android/server/status/StatusBarPolicy;->updateBattery(Landroid/content/Intent;)V <br />
<br />
    return-void<br />
.end method
towards the bottom you'll see the call to the method, change that block of code to

Code:
.method static synthetic access$300(Lcom/android/server/status/StatusBarPolicy;Landroid/content/Intent;)V<br />
    .registers 2<br />
    .parameter "x0"<br />
    .parameter "x1"<br />
<br />
    .prologue<br />
    .line 111<br />
    invoke-direct {p0}, Lcom/android/server/status/StatusBarPolicy;->updateBattery()V <br />
<br />
    return-void<br />
.end method
done!

 
1 - 1 of 1 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top