1## Working on AOSP
2
3#### Downloading source
4
5Follow instructions at https://source.android.com/source/downloading.html except those noted below. You need to set up authentication to be able to submit changes.
6DroidDriver is an "unbundled" project. If you specify the repo manifest branch "droiddriver-dev" (see below), you'll get only the relevant projects instead of the whole AOSP tree.
7
8Create a dir for AOSP, e.g. ~/android/aosp. It should be separate from your work on the internal repo to avoid confusion.
9Then get a local client of the repo:
10
11```bash
12$ mkdir droiddriver-dev
13$ cd droiddriver-dev
14$ repo init -u https://android.googlesource.com/a/platform/manifest -b droiddriver-dev
15$ repo sync
16```
17
18The code should be downloaded to the current dir. You may see some lines in the output like:
19
20`curl: (22) The requested URL returned error: 401 Unauthorized`
21
22These messages seem non-fatal and you should see these dirs after it is done:
23
24`build/  external/  frameworks/  Makefile  prebuilts/`
25
26#### Submitting Patches
27
28[Submitting patches to Android](https://source.android.com/source/submit-patches.html)
29
30- `cd external/droiddriver/`
31- `repo start somebranchname .`
32-  make changes and commit them
33- `repo upload`
34
35After submitting a branch to gerrit for review, each commit will show up as an individual patch set on gerrit. First the code needs to be code reviewed (+2), then verified & submitted by an approver. Reviewers without approval rights are limited to adding a code review +1.
36
37If commits are uploaded together (on the same branch) then they are considered dependent upon eachother. To submit an individual commit without requiring other commits to be merged first, that commit must be cherry picked to a new branch. This can be done either locally or via the gerrit UI.
38
39#### Working with gerrit
40
41Reviewers must be added to each changeset for them to approve the code. Reviews can be specified on command line in this format:
42
43`$ repo upload --re="<joe@example.com>,<john@example.com>" .`
44
45The '<>' above are literal. The emails must have been registered with Gerrit. You can also use the "--cc" flag.
46
47When commenting on the code, posts will show up as drafts. Drafts are not visible to other users. To post the drafts, press the reply button (keyboard shortcut 'a') and then click Post.
48
49#### Updating patches on Gerrit
50
51- `repo sync`
52- Use the `get fetch` command from the gerrit changeset under the Download menu
53- Make new commit then squash into previous commit to retain the gerrit change id
54- `repo upload`
55
56The [`repo prune`](https://source.android.com/source/using-repo.html) command can be used to delete already merged branches.
57