[Oppo Find 5] paperWastage:
smali sucks :D .... it's hard to apply patches for smali. these guys manage to auto-patch smali code, but usually the target is roughly the same (~android AOSP/AOKP/CM10.1 base with the same code)... if I have time, I'll take a look to see how they organize the smali patcher

you need to understand assembly (smali opcodes), know how to read it, and how java code relates to it

maybe a small tutorial would help: the flash check disabler code . Not sure how you modified the code, but here's how my thought process went

after decompiling to source code, you'll figure out how to solve the problem: have this function return false all the time

you want the function to return false (i.e. flash IS NOT forbidden)

I decide to target that (if i>=15) check (it checks if you have at least 15% battery left)

com/android/camera/Camera.java

private boolean isForbidFlash()
{
boolean flag = true;
File file = new File("/sys/class/power_supply/battery/capacity");
if(!file.exists())
return false;
FileReader filereader;
int i;
char c;
filereader = new FileReader(file);
char ac[] = new char[3];
filereader.read(ac);
i = Integer.valueOf(String.valueOf(ac).substring(0, 2)).intValue();
if(ac[0] != '1' || ac[1] != '0')
break MISSING_BLOCK_LABEL_98;
c = ac[2];
if(c == '0')
i = 100;
try
{
filereader.close();
}
catch(Exception exception1)
{
try
{
exception1.printStackTrace();
}
catch(Exception exception)
{
exception.printStackTrace();
Log.e("OppoCamera", (new StringBuilder()).append("isForbidFlash: e = ").append(exception).toString());
return false;
}
}
[B]if(i >= 15)[/B]
flag = false;
return flag;
}

smali code equivalent of the function above

.method private isForbidFlash()Z
.registers 9

.prologue
const/16 v7, 0x30

const/4 v0, 0x1

const/4 v1, 0x0

.line 4942
:try_start_4
new-instance v2, Ljava/io/File;

const-string v3, "/sys/class/power_supply/battery/capacity"

invoke-direct {v2, v3}, Ljava/io/File;-><init>(Ljava/lang/String;)V

.line 4943
invoke-virtual {v2}, Ljava/io/File;->exists()Z

move-result v3

if-nez v3, :cond_12

.line 4969
:goto_11
return v1

.line 4946
:cond_12
new-instance v3, Ljava/io/FileReader;

invoke-direct {v3, v2}, Ljava/io/FileReader;-><init>(Ljava/io/File;)V

.line 4947
const/4 v2, 0x3

new-array v4, v2, [C

.line 4948
invoke-virtual {v3, v4}, Ljava/io/FileReader;->read([C)I

.line 4950
invoke-static {v4}, Ljava/lang/String;->valueOf([C)Ljava/lang/String;

move-result-object v2

.line 4951
const/4 v5, 0x0

const/4 v6, 0x2

invoke-virtual {v2, v5, v6}, Ljava/lang/String;->substring(II)Ljava/lang/String;

move-result-object v2

invoke-static {v2}, Ljava/lang/Integer;->valueOf(Ljava/lang/String;)Ljava/lang/Integer;

move-result-object v2

invoke-virtual {v2}, Ljava/lang/Integer;->intValue()I

move-result v2

.line 4952
const/4 v5, 0x0

aget-char v5, v4, v5

const/16 v6, 0x31

if-ne v5, v6, :cond_42

const/4 v5, 0x1

aget-char v5, v4, v5

if-ne v5, v7, :cond_42

const/4 v5, 0x2

aget-char v4, v4, v5
:try_end_3e
.catch Ljava/lang/Exception; {:try_start_4 .. :try_end_3e} :catch_50

if-ne v4, v7, :cond_42

.line 4953
const/16 v2, 0x64

.line 4956
:cond_42
:try_start_42
invoke-virtual {v3}, Ljava/io/FileReader;->close()V
:try_end_45
.catch Ljava/lang/Exception; {:try_start_42 .. :try_end_45} :catch_4b

.line 4961
:goto_45
const/16 v3, 0xf

if-ge v2, v3, :cond_6d

:goto_49
move v1, v0

goto :goto_11

.line 4957
:catch_4b
move-exception v3

.line 4959
:try_start_4c
invoke-virtual {v3}, Ljava/lang/Exception;->printStackTrace()V
:try_end_4f
.catch Ljava/lang/Exception; {:try_start_4c .. :try_end_4f} :catch_50

goto :goto_45

.line 4963
:catch_50
move-exception v0

.line 4965
invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V

.line 4966
const-string v2, "OppoCamera"

new-instance v3, Ljava/lang/StringBuilder;

invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

const-string v4, "isForbidFlash: e = "

invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

move-result-object v3

invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

move-result-object v0

invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

move-result-object v0

invoke-static {v2, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

goto :goto_11

:cond_6d
move v0, v1

.line 4961
goto :goto_49
.end method

if you look at the smali code and walk through/compare it with the java code, you'll see different ways to tackling the problem

A) just simply return v1 (=FALSE) on the first line. side effects: you bypass the try/catch statements, dunno if you'll break anything

B) - my approach

the (if i>= 15) check). 0xf hex is the same as 15 decimal.

Change 0xf to 0x0, so it'll check if (i >= 0), i.e. at least 0% battery

.line 4961
:goto_45
const/16 v3, [B]0xf[/B]

if-ge v2, v3, :cond_6d

C) you could also target the assignment of the flag inside the if/else statement.

#assignments of the registers at the beginning of function

const/4 v0, 0x1 # true

const/4 v1, 0x0 # false

#what happens inside the condition=true block, until the return statement. condition = enough battery

the "#" lines are my comments

if-ge v2, v3, :cond_6d
#jump to :cond_6d
:cond_6d
move v0, v1 #v0 = v1 , both = FALSE(since v1 was initialize to FALSE)
.line 4961
goto :goto_49
#jump to the :goto_49 tag
:goto_49
move v1, v0 # v1 = v0, both = FALSE

goto :goto_11
#jump to the :goto_11 tag
:goto_11
return v1 # return v1 = FALSE <- result we want

#what happens inside the condition=false block, until the return statement. condition = not enough battery

if-ge v2, v3, :cond_6d # we don't jump, since condition failed. follow the next line

:goto_49
move v1, v0 # v1 = v0, both = TRUE(since v0 was initialized to TRUE)

goto :goto_11
#jump to the :goto_11 tag
:goto_11
return v1 # return v1 = TRUE <- flash forbidden

you could change v0 to initialize to FALSE as well... not sure about the side effects though