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:
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.
For example, if reject file is locate at "patchrom/device/temp/reject/android.policy.jar.out/smali/com/android/internal/policy/impl" original file will be located at "patchrom/device/android.policy.jar.out/smali/com/android/internal/policy/impl".
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 file (reject and base). In the reject, we'll see something like this:
The next step will be patching. Before that, we have to get some knowledge about symbology and terminology:
However, the expecting lines doesn't matter a lot. The important part is that we realise that:
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:
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:
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:
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):
This tells me that I'll have to edit:
And change it to:
Besides, I'll have to add this:
Realise that files are partially patched. In this case, it's not needed to add:
Due to it's already in the original file, but in a distinct location. If you want, you can put it under:
To leave it as the reject says, although it's an insignificant change.
So after patching it manually, it look in this way:
PD: I'm busy right now. I'll be adding more explanations and examples to this tutorial, due to this first example it's quite easy. Be patient please:
Quote:
MIUI (which stands for Mi User Interface and pronounced "Me You I", a play on the common abbreviation of the words user interface as UI), developed by Xiaomi Tech, is a stock and aftermarket firmware for smartphones and tablet computers based on the free software Android operating system. MIUI includes various features such as theming support. |
Quote:
Patchrom is a open-source project initiated and maintained by MIUI team. It mainly utilizes the assembler/disassembler technology to craft a MIUI ROM for an existing ROM. Although this project is for MIUI ROM, but the technology and tools is general for crafting any android ROM. |
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.
Quote:
This guide is applicable to all devices and Miui versions (using PatchROM) |
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:
Code:
Hunk #1 FAILED at 111.
1 out of 1 hunks FAILED -- saving rejects to file android.services.jar.out/PhoneWindowManager.smali.rejRealise that PatchROM decompiles framework files at smali code to add MIUI lines. What's smali?:
Quote:
Smali/Baksmali is an assembler/disassembler for the dex format used by dalvik, Android's Java VM implementation. The names "Smali" and "Baksmali" are the Icelandic equivalents of "assembler" and "disassembler" respectively. |
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.
For example, if reject file is locate at "patchrom/device/temp/reject/android.policy.jar.out/smali/com/android/internal/policy/impl" original file will be located at "patchrom/device/android.policy.jar.out/smali/com/android/internal/policy/impl".
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 file (reject and base). In the reject, we'll see something like this:
Code:
*** 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- ***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.
Quote:
We get a reject, because the patch couldn't find the expected source input at the given line numbers and that's why the actual patching fails. |
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:
Code:
*** 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:ICode:
.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;Code:
--- 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:ICode:
.field private final mPowerLongPress:Ljava/lang/Runnable;Code:
.field private mPowerLongPress:Ljava/lang/Runnable;Code:
.field private final mQuickBootLock:Ljava/lang/Object;Code:
.field private final mQuickBootLock:Ljava/lang/Object;Code:
.field mPreloadedRecentApps:ZSo after patching it manually, it look in this way:
Code:
.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:
Code:
Press thanks if I help you :D
Aucun commentaire:
Enregistrer un commentaire