[Android] JavierAlonso:
Hello everyone! :D :) ;)

​

Today I present you a guide for PatchROM rejects fixing. I'm not an expert at all, so maybe I'll miss things. Don't expect that I'll explain solution to every issue, however, I try my best to do this tutorial. I'm very happy due to I haven't found a specific thread about this.

Having said that, let's start!

1. Understanding Rejects

First of all, is needed to know why we get a reject. We know that we've got a reject when executing in Terminal "make firstpatch" appears something like this:

Hunk #1 FAILED at 111.
1 out of 1 hunks FAILED -- saving rejects to file android.services.jar.out/PhoneWindowManager.smali.rej

This tells me that the patch couldn't apply it at line 111. Also we know that the half-patched file is located in android.services.jar.out and it's called "PhoneWindowManager.smali".

Realise that PatchROM decompiles framework files at smali code to add MIUI lines. What's smali?:

Now that we've seen the failed hunks, it's time to find the related reject. Reject files are located at temp/reject folder.

Following my example, the half-patched file is located at android.services.jar.out. So I have to open that sub-folder at reject directory, and look for "PhoneWindowManager.smali.rej"; that's the reject file.

Having done that, we have to find the base file. In this case, I'll be located in device root folder (patchrom/device) at

android.services.jar.out. We have to look for "PhoneWindowManager.smali"; I'll be at the same path that reject one.

Once we have found the right file to edit, it's time to patch it manually.

2. Getting Patch Knowledge

Now we have to open both files (reject and base). In the reject, we'll see something like this:

*** PhoneWindowManager.smali 2015-09-09 11:46:13.541852561 -0300
--- PhoneWindowManager.smali 2015-09-09 11:47:07.349851413 -0300
***************
*** 393,404 ****

.field private mPowerKeyTriggered:Z

! .field private final mPowerLongPress:Ljava/lang/Runnable;

.field mPowerManager:Landroid/os/PowerManager;

.field mPreloadedRecentApps:Z

.field mRecentAppsDialog:Lcom/android/internal/policy/impl/RecentApplicationsDialog;

.field mRecentAppsDialogHeldModifiers:I
--- 395,408 ----

.field private mPowerKeyTriggered:Z

! .field private mPowerLongPress:Ljava/lang/Runnable;

.field mPowerManager:Landroid/os/PowerManager;

.field mPreloadedRecentApps:Z

+ .field private final mQuickBootLock:Ljava/lang/Object;
+
.field mRecentAppsDialog:Lcom/android/internal/policy/impl/RecentApplicationsDialog;

.field mRecentAppsDialogHeldModifiers:I

The next step will be patching. Before that, we have to get some knowledge about symbology and terminology:

***XX,XX***: this tells me that the patch is expecting source input (below codes) between the specified lines. In this case, it expected them between line 393 and 404.

---XX,XX---: this tells me how the lines should look after patching, and where they should be. In this case, between line 395 and 408.

However, the expecting lines doesn't matter a lot. The important part is that we realise that:

Lines below asterisks (***) are how they look in base file before patching.

Lines below hyphens (---) are how they look in base file after patching.

So our work will be patching them manually, due to human brain is more intelligent than an automatic patch (not always, jajajaja :silly: )

To do that, we have to understand the symbols:

+ means that the line is added by the patch

- means that the line is removed by the patch

! means that the line is changed/edited by the patch

Having this knowledge, it's time to fix that reject... :cool:

3. Applying Patches Manually

I'm going to follow my example and fix it. Then you'll apply the same procedure with your reject.

Firstly, we have to pay attention to source input (asterisks):

*** 393,404 ****

.field private mPowerKeyTriggered:Z

! .field private final mPowerLongPress:Ljava/lang/Runnable;

.field mPowerManager:Landroid/os/PowerManager;

.field mPreloadedRecentApps:Z

.field mRecentAppsDialog:Lcom/android/internal/policy/impl/RecentApplicationsDialog;

.field mRecentAppsDialogHeldModifiers:I

Now it's time to look for that lines in the base file. They will be located 200 lines after or before the expecting input. Besides, they could be lightly different, almost in values. In my case, this will be the right place to work:

.field private mPowerKeyTriggered:Z

.field private final mPowerLongPress:Ljava/lang/Runnable;

.field mPowerManager:Landroid/os/PowerManager;

.field mPreloadedRecentApps:Z

.field private mPressOnAppSwitchBehavior:I

.field private mPressOnAssistBehavior:I

.field private mPressOnMenuBehavior:I

.field private final mQuickBootLock:Ljava/lang/Object;

.field private final mQuickBootPowerLongPress:Ljava/lang/Runnable;

As you can see, they're in different order, and others doesn't appear. Now we've located the source input, pay attention to the "after patch" (hyphens):

--- 395,408 ----

.field private mPowerKeyTriggered:Z

! .field private mPowerLongPress:Ljava/lang/Runnable;

.field mPowerManager:Landroid/os/PowerManager;

.field mPreloadedRecentApps:Z

+ .field private final mQuickBootLock:Ljava/lang/Object;
+
.field mRecentAppsDialog:Lcom/android/internal/policy/impl/RecentApplicationsDialog;

.field mRecentAppsDialogHeldModifiers:I

This tells me that I'll have to edit:

.field private final mPowerLongPress:Ljava/lang/Runnable;

And change it to:

.field private mPowerLongPress:Ljava/lang/Runnable;

Besides, I'll have to add this:

.field private final mQuickBootLock:Ljava/lang/Object;

Realise that files are partially patched. In this case, it's not needed to add it due to it's already in the original file, but in a distinct location. If you want, you can put it under:

.field mPreloadedRecentApps:Z

To leave it as the reject says, although it's an insignificant change.

So after patching it manually, it look in this way:

.field private mPowerKeyTriggered:Z

.field private mPowerLongPress:Ljava/lang/Runnable;

.field mPowerManager:Landroid/os/PowerManager;

.field mPreloadedRecentApps:Z

.field private mPressOnAppSwitchBehavior:I

.field private mPressOnAssistBehavior:I

.field private mPressOnMenuBehavior:I

.field private final mQuickBootLock:Ljava/lang/Object;

.field private final mQuickBootPowerLongPress:Ljava/lang/Runnable;

Finally, save your changes and exit. Go to another reject! :laugh: :laugh: :laugh:​

Press thanks if I help you ;)

Don't copy my work without my permission