10a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light/*
20a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light * Copyright (C) 2014 The Android Open Source Project
30a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light *
40a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light * Licensed under the Apache License, Version 2.0 (the "License");
50a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light * you may not use this file except in compliance with the License.
60a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light * You may obtain a copy of the License at
70a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light *
80a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light *      http://www.apache.org/licenses/LICENSE-2.0
90a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light *
100a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light * Unless required by applicable law or agreed to in writing, software
110a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light * distributed under the License is distributed on an "AS IS" BASIS,
120a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
130a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light * See the License for the specific language governing permissions and
140a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light * limitations under the License.
150a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light */
160a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light
170a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Lightpublic class Main {
180a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light  public static void main(String[] args) {
195ef2990c2933152021633e6697d5325103649499Igor Murashkin    boolean executable_correct = (isPic() ?
205ef2990c2933152021633e6697d5325103649499Igor Murashkin                                  hasExecutableOat() == true :
215ef2990c2933152021633e6697d5325103649499Igor Murashkin                                  hasExecutableOat() == isDex2OatEnabled());
225ef2990c2933152021633e6697d5325103649499Igor Murashkin
230a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light    System.out.println(
240a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light        "dex2oat & patchoat are " + ((isDex2OatEnabled()) ? "enabled" : "disabled") +
255ef2990c2933152021633e6697d5325103649499Igor Murashkin        ", has oat is " + hasOat() + ", has executable oat is " + (
265ef2990c2933152021633e6697d5325103649499Igor Murashkin        executable_correct ? "expected" : "not expected") + ".");
270a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light
280a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light    if (!hasOat() && isDex2OatEnabled()) {
290a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light      throw new Error("Application with dex2oat enabled runs without an oat file");
300a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light    }
310a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light
320a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light    System.out.println(functionCall());
330a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light  }
340a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light
350a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light  public static String functionCall() {
360a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light    String arr[] = {"This", "is", "a", "function", "call"};
370a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light    String ret = "";
380a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light    for (int i = 0; i < arr.length; i++) {
390a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light      ret = ret + arr[i] + " ";
400a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light    }
410a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light    return ret.substring(0, ret.length() - 1);
420a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light  }
430a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light
440a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light  static {
450a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light    System.loadLibrary("arttest");
460a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light  }
470a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light
480a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light  private native static boolean isDex2OatEnabled();
490a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light
505ef2990c2933152021633e6697d5325103649499Igor Murashkin  private native static boolean isPic();
515ef2990c2933152021633e6697d5325103649499Igor Murashkin
520a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light  private native static boolean hasOat();
530a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light
540a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light  private native static boolean hasExecutableOat();
550a112bbbcd761c749c346bfec0ec39c1ef37a590Alex Light}
56