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:
19curl: (22) The requested URL returned error: 401 Unauthorized
20These messages seem non-fatal and you should see these dirs after it is done:
21build/  external/  frameworks/  Makefile  prebuilts/
22
23#### Submitting Patches
24
25[Submitting patches to Android](https://source.android.com/source/submit-patches.html)
26
27- `cd external/droiddriver/`
28- `repo start somebranchname .`
29-  make changes and commit them
30- `repo upload`
31
32After 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.
33
34If 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.
35
36#### Working with gerrit
37
38Reviewers must be added to each changeset for them to approve the code. Reviews can be specified on command line in this format:
39
40`$ repo upload --re="<joe@example.com>,<john@example.com>" .`
41
42The '<>' above are literal. The emails must have been registered with Gerrit. You can also use the "--cc" flag.
43
44When 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.
45
46#### Updating patches on Gerrit
47
48- `repo sync`
49- Use the `get fetch` command from the gerrit changeset under the Download menu
50- Make new commit then squash into previous commit to retain the gerrit change id
51- `repo upload`
52
53The [`repo prune`](https://source.android.com/source/using-repo.html) command can be used to delete already merged branches.
54
55#### Building
56
57This sets up environment and some bash functions, particularly "tapas"
58(the counterpart of "lunch" for unbundled projects) and "m".
59
60```bash
61$ . build/envsetup.sh
62$ tapas droiddriver ManualDD
63$ m
64```
65
66ManualDD is an APK you can use to manually test DroidDriver.
67