[TUTORIAL]How to Fix Rejects in Flyme Patchrom

3914

4

2017-08-04 17:36

Edited by RendyAK at 2017-08-06 07:40

Introduction:
Many people encounter difficulties when fixing rejects, and Im here to help!
Without many useless talks here, let's start!

Why?:
Flyme Patchrom README says:
Automatic patching may cause code merge conflicts. Conflicts will be marked in the form of the following, developers need to manually resolve these conflicts in the vendor's file.
How do I fix rejects?:
Fixing rejects is pretty simple, just like how you fix rejects in git.
The scheme of rejects is:
  1. <<<<<<< VENDOR
  2.       original code block
  3.     =======
  4.       Flyme code block
  5.     >>>>>>> BOSP
Copy the Code
For example, this is the reject
  1. <<<<<<< VENDOR #Conflict 1
  2.     new-instance v79, Lcom/android/server/LockSettingsService;
  3. ======= #@.method private startOtherServices@
  4.     new-instance v77, Lcom/android/server/FlymeExtLockSettingsService;
  5. >>>>>>> BOSP #Conflict 1
Copy the Code
So how do we fix it?
Pretty easy, what you need to do is replace
  1. Lcom/android/server/LockSettingsService;
Copy the Code
in this line:
  1. new-instance v79, Lcom/android/server/LockSettingsService;
Copy the Code
to
  1. Lcom/android/server/FlymeExtLockSettingsService;
Copy the Code
so, when we have replace it, it should looks like this
  1. new-instance v79, Lcom/android/server/FlymeExtLockSettingsService;
Copy the Code
and then we can go work to other rejects!
Tip!
Never replace registers (vxx) and label (:xxx_try_xxx_xxx) while fixing rejects!
Hey! I have multiple lines rejects, how do I fix it?
Now this is pretty hard, this mostly happens on services.jar.out rejects, especially SystemServer.smali, now read carefully how to fix it!

For example:
this is out reject
  1. <<<<<<< VENDOR #Conflict 3
  2.     .local v84, "mmsService":Lcom/android/server/MmsServiceBroker;
  3.     :try_start_3d
  4.     invoke-static/range {v67 .. v67}, Ljava/lang/Class;->forName(Ljava/lang/String;)Ljava/lang/Class;
  5. ======= #@.method private startOtherServices@
  6.     .local v82, "mmsService":Lcom/android/server/MmsServiceBroker;

  7.     move-object/from16 v0, p0

  8.     move-object/from16 v3, v111

  9.     move-object/from16 v4, v108

  10.     invoke-static {v0, v3, v4}, Lcom/android/server/SystemServer$FlymeInjector;->addFlymeServices(Lcom/android/server/SystemServer;Lcom/android/server/wm/WindowManagerService;Lcom/android/server/wallpaper/WallpaperManagerService;)V

  11.     :try_start_3b
  12.     invoke-static/range {v65 .. v65}, Ljava/lang/Class;->forName(Ljava/lang/String;)Ljava/lang/Class;
  13. >>>>>>> BOSP #Conflict 3
Copy the Code
Pretty hard, isn't it?
now what we do is, replace
  1. .local v84, "mmsService":Lcom/android/server/MmsServiceBroker;
Copy the Code
with
  1. .local v82, "mmsService":Lcom/android/server/MmsServiceBroker;

  2. move-object/from16 v0, p0

  3. move-object/from16 v3, v111

  4. move-object/from16 v4, v108
Copy the Code
but keep the registers and label!
now, replace the v82 into v84, to match with vendor register.
and :try_start_3b with :try_start_3d to match with vendor label.
And now, this is the tricky part, we need to correct the v111, and v108 register
now open up the BOSP's file, in this case, BOSP's SystemServer.smali.
and now, search for the method its stated in the reject part, in "======= #@.method private startOtherServices@" and ".method private startOtherServices" is the method in this case.
now, search for what is v111 and v108 is for.
I've found where is v111 and v108 is defined.
  1. .local v111, "wm":Lcom/android/server/wm/WindowManagerService; (for v111)
  2. .local v108, "wallpaper":Lcom/android/server/wallpaper/WallpaperManagerService; (v108)
Copy the Code
So, what now?
We should find what is
  1. "wm":Lcom/android/server/wm/WindowManagerService;
Copy the Code

register and
  1. "wallpaper":Lcom/android/server/wallpaper/WallpaperManagerService;
Copy the Code

register in vendor

In this case, I've found it is
  1. .local v110, "wallpaper":Lcom/android/server/wallpaper/WallpaperManagerService;
  2. .local v113, "wm":Lcom/android/server/wm/WindowManagerService;
Copy the Code
So, we need to replace v111 with v113, and v108 with v110.
So our result is
  1. .local v84, "mmsService":Lcom/android/server/MmsServiceBroker;

  2. move-object/from16 v0, p0

  3. move-object/from16 v3, v108

  4. move-object/from16 v4, v110
Copy the Code
And now we can put
  1. invoke-static {v0, v3, v4}, Lcom/android/server/SystemServer$FlymeInjector;->addFlymeServices(Lcom/android/server/SystemServer;Lcom/android/server/wm/WindowManagerService;Lcom/android/server/wallpaper/WallpaperManagerService;)V

  2. :try_start_3b
  3. invoke-static/range {v65 .. v65}, Ljava/lang/Class;->forName(Ljava/lang/String;)Ljava/lang/Class;
Copy the Code
with :try_start_3b changed to :try_start_3d to match with vendor.
So our final result is
  1. .local v84, "mmsService":Lcom/android/server/MmsServiceBroker;

  2. move-object/from16 v0, p0

  3. move-object/from16 v3, v108

  4. move-object/from16 v4, v110

  5. invoke-static {v0, v3, v4}, Lcom/android/server/SystemServer$FlymeInjector;->addFlymeServices(Lcom/android/server/SystemServer;Lcom/android/server/wm/WindowManagerService;Lcom/android/server/wallpaper/WallpaperManagerService;)V

  6. :try_start_3d
  7. invoke-static/range {v65 .. v65}, Ljava/lang/Class;->forName(Ljava/lang/String;)Ljava/lang/Class;
Copy the Code

That's not really that hard, isn't it? Now you can go create the Flyme package with
  1. $ flyme fullota
Copy the Code
and enjoy your builded FlymeOS!