[LG Optimus 2x] pastime1971:
sure. i will try my best to explain it.

(edit) in the following bold are what you actually type, but red-marked needs to be replaced with what you actually have.

let say you have original frameworks/base/services/java/com/android/server/am/ActivityManagerService.java and the patched one.

then those diff files were generated by running diff -Npru ORIGINAL MODIFIED > DIFF

and patch command is used to change your repo'ed file to the modified.

now your repo'ed file changed from one that i used to create diff files, and therefore patching fails. (only one hunk among many)

you need to modify diff file such that it works for your changed repo'ed file.

easiest way is copy ActivityManagerService.java to ~/temp/, make a change according to the failed hunk (you can find it from *.rej)

in your case, it is to add import android.privacy.surrogate.PrivacyActivityManagerService;

(go to ~/ first where your repo(android/) is under.)

then you can generate a diff file for that hunk only by running diff -Npru android/frameworks/base/services/java/com/android/server/am/ActivityManagerService.java ~/temp/ActivityManagerService.java > ~/temp/new_hunk.diff and you will see what needs to be changed from the framework.diff file.

to explain the syntax, each hunk is marked by @ -START, LINES +START,LINES

the first is the location of hunk in the original file, and the second is the location after change is made.

patch command is smart enough to figure out the actual location by comparing extra lines, so don't worry too much about getting START numbers correct.

however, LINES numbers are very important to be correct.

following is the source codes. it adds a space if no change, - for deletion, + for addition.

by default, white spaces matters when you patch, which is easier to save the hunk from the above procedure, and replace it in diff file.

since framework.diff contains many files under framework/base, you have to replace only that hunk. not overwrite the whole file.

edit: do not change --- file +++ file part. just from @ line to until before next @ line

for example, blue-marked is one hunk

diff -Npru --exclude='.svn*' --exclude='.git*' cyanogen/frameworks/base/services/java/com/android/server/am/ActivityManagerService.java pang/frameworks/base/services/java/com/android/server/am/ActivityManagerService.java
--- cyanogen/frameworks/base/services/java/com/android/server/am/ActivityManagerService.java 2012-03-29 23:41:14.045720104 -0700
+++ pang/frameworks/base/services/java/com/android/server/am/ActivityManagerService.java 2012-03-29 23:11:05.086052516 -0700
[COLOR="Blue"]@@ -138,6 +138,9 @@ import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import dalvik.system.Zygote;
+// BEGIN privacy-added
+import android.privacy.surrogate.PrivacyActivityManagerService;
+// END privacy-added

public final class ActivityManagerService extends ActivityManagerNative
implements Watchdog.Monitor, BatteryStatsImpl.BatteryCallback {[/COLOR]
@@ -11053,6 +11056,9 @@ public final class ActivityManagerServic
}

Object nextReceiver = r.receivers.get(recIdx);
+ // BEGIN privacy-added
+ enforcePrivacyPermission(nextReceiver, r);
+ // END privacy-added
if (nextReceiver instanceof BroadcastFilter) {
// Simple case: this is a registered receiver who gets
// a direct call.