1/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17public class Main {
18  public static void main(String[] args) {
19    System.loadLibrary(args[0]);
20
21    // With a relocationDelta of 0, the runtime has no way to determine if the oat file in
22    // ANDROID_DATA has been relocated, since a non-relocated oat file always has a 0 delta.
23    // Hitting this condition should be rare and ideally we would prevent it from happening but
24    // there is no way to do so without major changes to the run-test framework.
25    boolean executable_correct = (needsRelocation() ?
26        hasExecutableOat() == (isDex2OatEnabled() || isRelocationDeltaZero()) :
27        hasExecutableOat() == true);
28
29    System.out.println(
30        "dex2oat & patchoat are " + ((isDex2OatEnabled()) ? "enabled" : "disabled") +
31        ", has oat is " + hasOatFile() + ", has executable oat is " + (
32        executable_correct ? "expected" : "not expected") + ".");
33
34    if (!hasOatFile() && isDex2OatEnabled()) {
35      throw new Error("Application with dex2oat enabled runs without an oat file");
36    }
37
38    System.out.println(functionCall());
39  }
40
41  public static String functionCall() {
42    String arr[] = {"This", "is", "a", "function", "call"};
43    String ret = "";
44    for (int i = 0; i < arr.length; i++) {
45      ret = ret + arr[i] + " ";
46    }
47    return ret.substring(0, ret.length() - 1);
48  }
49
50  private native static boolean isDex2OatEnabled();
51
52  private native static boolean needsRelocation();
53
54  private native static boolean hasOatFile();
55
56  private native static boolean hasExecutableOat();
57
58  private native static boolean isRelocationDeltaZero();
59}
60