Loading core/tests/hosttests/test-apps/MultiDexLegacyTestServices/Android.mk 0 → 100644 +40 −0 Original line number Diff line number Diff line # Copyright (C) 2014 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := tests LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_SDK_VERSION := 9 LOCAL_PACKAGE_NAME := MultiDexLegacyTestServices LOCAL_STATIC_JAVA_LIBRARIES := android-support-multidex mainDexList:= \ $(call intermediates-dir-for,APPS,$(LOCAL_PACKAGE_NAME),$(LOCAL_IS_HOST_MODULE),common)/maindex.list LOCAL_DX_FLAGS := --multi-dex --main-dex-list=$(mainDexList) --minimal-main-dex include $(BUILD_PACKAGE) $(mainDexList): $(full_classes_proguard_jar) | $(HOST_OUT_EXECUTABLES)/mainDexClasses $(HOST_OUT_EXECUTABLES)/mainDexClasses $< 1>$@ $(built_dex_intermediate): $(mainDexList) core/tests/hosttests/test-apps/MultiDexLegacyTestServices/AndroidManifest.xml 0 → 100644 +129 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.framework.multidexlegacytestservices" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19" /> <application android:label="MultiDexLegacyTestServices"> <service android:name=".Service1" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices1"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service1" /> </intent-filter> </service> <service android:name=".Service2" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices2"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service2" /> </intent-filter> </service> <service android:name=".Service3" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices3"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service3" /> </intent-filter> </service> <service android:name=".Service4" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices4"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service4" /> </intent-filter> </service> <service android:name=".Service5" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices5"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service5" /> </intent-filter> </service> <service android:name=".Service6" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices6"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service6" /> </intent-filter> </service> <service android:name=".Service7" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices7"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service7" /> </intent-filter> </service> <service android:name=".Service8" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices8"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service8" /> </intent-filter> </service> <service android:name=".Service9" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices9"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service9" /> </intent-filter> </service> <service android:name=".Service10" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices10"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service10" /> </intent-filter> </service> <service android:name=".Service11" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices11"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service11" /> </intent-filter> </service> <service android:name=".Service12" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices12"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service12" /> </intent-filter> </service> <service android:name=".Service13" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices13"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service13" /> </intent-filter> </service> <service android:name=".Service14" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices14"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service14" /> </intent-filter> </service> <service android:name=".Service15" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices15"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service15" /> </intent-filter> </service> <service android:name=".Service16" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices16"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service16" /> </intent-filter> </service> <service android:name=".Service17" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices17"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service17" /> </intent-filter> </service> <service android:name=".Service18" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices18"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service18" /> </intent-filter> </service> <service android:name=".Service19" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices19"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service19" /> </intent-filter> </service> </application> </manifest> core/tests/hosttests/test-apps/MultiDexLegacyTestServices/src/com/android/framework/multidexlegacytestservices/AbstractService.java 0 → 100644 +167 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.framework.multidexlegacytestservices; import android.app.Service; import android.content.Context; import android.content.Intent; import android.os.IBinder; import android.support.multidex.MultiDex; import android.util.Log; import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; /** * Empty service for testing legacy multidex. Access more than 64k methods but some are required at * init, some only at verification and others during execution. */ public abstract class AbstractService extends Service { private final String TAG = "MultidexLegacyTestService" + getId(); private int instanceFieldNotInited; private int instanceFieldInited = new com.android.framework.multidexlegacytestservices.manymethods.Big043().get43(); private static int staticField = new com.android.framework.multidexlegacytestservices.manymethods.Big044().get44(); public AbstractService() { instanceFieldNotInited = new com.android.framework.multidexlegacytestservices.manymethods.Big042().get42(); } @Override public void onCreate() { Log.i(TAG, "onCreate"); Context applicationContext = getApplicationContext(); File resultFile = new File(applicationContext.getFilesDir(), getId()); try { // Append a constant value in result file, if services crashed and is relaunched, size // of the result file will be too big. RandomAccessFile raf = new RandomAccessFile(resultFile, "rw"); raf.seek(raf.length()); Log.i(TAG, "Writing 0x42434445 at " + raf.length() + " in " + resultFile.getPath()); raf.writeInt(0x42434445); raf.close(); } catch (IOException e) { e.printStackTrace(); } MultiDex.install(applicationContext); Log.i(TAG, "Multi dex installation done."); int value = getValue(); Log.i(TAG, "Saving the result (" + value + ") to " + resultFile.getPath()); try { // Append the check value in result file, keeping the constant values already written. RandomAccessFile raf = new RandomAccessFile(resultFile, "rw"); raf.seek(raf.length()); Log.i(TAG, "Writing result at " + raf.length() + " in " + resultFile.getPath()); raf.writeInt(value); raf.close(); } catch (IOException e) { e.printStackTrace(); } try { // Writing end of processing flags, the existence of the file is the criteria RandomAccessFile raf = new RandomAccessFile(new File(applicationContext.getFilesDir(), getId() + ".complete"), "rw"); Log.i(TAG, "creating complete file " + resultFile.getPath()); raf.writeInt(0x32333435); raf.close(); } catch (IOException e) { e.printStackTrace(); } } @Override public int onStartCommand(Intent intent, int flags, int startId) { Log.i("Service" + getId(), "Received start id " + startId + ": " + intent); // We want this service to continue running until it is explicitly // stopped, so return sticky. return START_STICKY; } private String getId() { return this.getClass().getSimpleName(); } @Override public void onDestroy() { } @Override public IBinder onBind(Intent intent) { return null; } public int getValue() { int intermediate = -1; try { intermediate = ReflectIntermediateClass.get(45, 80, 20 /* 5 seems enough on a nakasi, using 20 to get some margin */); } catch (Exception e) { e.printStackTrace(); } int value = new com.android.framework.multidexlegacytestservices.manymethods.Big001().get1() + new com.android.framework.multidexlegacytestservices.manymethods.Big002().get2() + new com.android.framework.multidexlegacytestservices.manymethods.Big003().get3() + new com.android.framework.multidexlegacytestservices.manymethods.Big004().get4() + new com.android.framework.multidexlegacytestservices.manymethods.Big005().get5() + new com.android.framework.multidexlegacytestservices.manymethods.Big006().get6() + new com.android.framework.multidexlegacytestservices.manymethods.Big007().get7() + new com.android.framework.multidexlegacytestservices.manymethods.Big008().get8() + new com.android.framework.multidexlegacytestservices.manymethods.Big009().get9() + new com.android.framework.multidexlegacytestservices.manymethods.Big010().get10() + new com.android.framework.multidexlegacytestservices.manymethods.Big011().get11() + new com.android.framework.multidexlegacytestservices.manymethods.Big012().get12() + new com.android.framework.multidexlegacytestservices.manymethods.Big013().get13() + new com.android.framework.multidexlegacytestservices.manymethods.Big014().get14() + new com.android.framework.multidexlegacytestservices.manymethods.Big015().get15() + new com.android.framework.multidexlegacytestservices.manymethods.Big016().get16() + new com.android.framework.multidexlegacytestservices.manymethods.Big017().get17() + new com.android.framework.multidexlegacytestservices.manymethods.Big018().get18() + new com.android.framework.multidexlegacytestservices.manymethods.Big019().get19() + new com.android.framework.multidexlegacytestservices.manymethods.Big020().get20() + new com.android.framework.multidexlegacytestservices.manymethods.Big021().get21() + new com.android.framework.multidexlegacytestservices.manymethods.Big022().get22() + new com.android.framework.multidexlegacytestservices.manymethods.Big023().get23() + new com.android.framework.multidexlegacytestservices.manymethods.Big024().get24() + new com.android.framework.multidexlegacytestservices.manymethods.Big025().get25() + new com.android.framework.multidexlegacytestservices.manymethods.Big026().get26() + new com.android.framework.multidexlegacytestservices.manymethods.Big027().get27() + new com.android.framework.multidexlegacytestservices.manymethods.Big028().get28() + new com.android.framework.multidexlegacytestservices.manymethods.Big029().get29() + new com.android.framework.multidexlegacytestservices.manymethods.Big030().get30() + new com.android.framework.multidexlegacytestservices.manymethods.Big031().get31() + new com.android.framework.multidexlegacytestservices.manymethods.Big032().get32() + new com.android.framework.multidexlegacytestservices.manymethods.Big033().get33() + new com.android.framework.multidexlegacytestservices.manymethods.Big034().get34() + new com.android.framework.multidexlegacytestservices.manymethods.Big035().get35() + new com.android.framework.multidexlegacytestservices.manymethods.Big036().get36() + new com.android.framework.multidexlegacytestservices.manymethods.Big037().get37() + new com.android.framework.multidexlegacytestservices.manymethods.Big038().get38() + new com.android.framework.multidexlegacytestservices.manymethods.Big039().get39() + new com.android.framework.multidexlegacytestservices.manymethods.Big040().get40() + new com.android.framework.multidexlegacytestservices.manymethods.Big041().get41() + instanceFieldNotInited + instanceFieldInited + staticField + intermediate; return value; } } core/tests/hosttests/test-apps/MultiDexLegacyTestServices/src/com/android/framework/multidexlegacytestservices/ReflectIntermediateClass.java 0 → 100644 +46 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.framework.multidexlegacytestservices; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** * Offer an indirection to some Big0xx classes and have their initialization * spread along a period of time. */ public class ReflectIntermediateClass { public static int get(int from, int to, int sleepMillis) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, InstantiationException { int value = 0; for (int i = from; i <= to; i++) { Class<?> bigClass = Class.forName( "com.android.framework.multidexlegacytestservices.manymethods.Big0" + i); Method get = bigClass.getMethod("get" + i); value += ((Integer) get.invoke(bigClass.newInstance())).intValue(); try { Thread.sleep(sleepMillis); } catch (InterruptedException e) { e.printStackTrace(); } } return value; } } core/tests/hosttests/test-apps/MultiDexLegacyTestServices/src/com/android/framework/multidexlegacytestservices/Service1.java 0 → 100644 +24 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.framework.multidexlegacytestservices; /** * Empty service for testing legacy multidex */ public class Service1 extends AbstractService { } Loading
core/tests/hosttests/test-apps/MultiDexLegacyTestServices/Android.mk 0 → 100644 +40 −0 Original line number Diff line number Diff line # Copyright (C) 2014 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := tests LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_SDK_VERSION := 9 LOCAL_PACKAGE_NAME := MultiDexLegacyTestServices LOCAL_STATIC_JAVA_LIBRARIES := android-support-multidex mainDexList:= \ $(call intermediates-dir-for,APPS,$(LOCAL_PACKAGE_NAME),$(LOCAL_IS_HOST_MODULE),common)/maindex.list LOCAL_DX_FLAGS := --multi-dex --main-dex-list=$(mainDexList) --minimal-main-dex include $(BUILD_PACKAGE) $(mainDexList): $(full_classes_proguard_jar) | $(HOST_OUT_EXECUTABLES)/mainDexClasses $(HOST_OUT_EXECUTABLES)/mainDexClasses $< 1>$@ $(built_dex_intermediate): $(mainDexList)
core/tests/hosttests/test-apps/MultiDexLegacyTestServices/AndroidManifest.xml 0 → 100644 +129 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.framework.multidexlegacytestservices" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19" /> <application android:label="MultiDexLegacyTestServices"> <service android:name=".Service1" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices1"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service1" /> </intent-filter> </service> <service android:name=".Service2" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices2"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service2" /> </intent-filter> </service> <service android:name=".Service3" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices3"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service3" /> </intent-filter> </service> <service android:name=".Service4" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices4"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service4" /> </intent-filter> </service> <service android:name=".Service5" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices5"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service5" /> </intent-filter> </service> <service android:name=".Service6" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices6"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service6" /> </intent-filter> </service> <service android:name=".Service7" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices7"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service7" /> </intent-filter> </service> <service android:name=".Service8" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices8"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service8" /> </intent-filter> </service> <service android:name=".Service9" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices9"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service9" /> </intent-filter> </service> <service android:name=".Service10" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices10"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service10" /> </intent-filter> </service> <service android:name=".Service11" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices11"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service11" /> </intent-filter> </service> <service android:name=".Service12" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices12"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service12" /> </intent-filter> </service> <service android:name=".Service13" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices13"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service13" /> </intent-filter> </service> <service android:name=".Service14" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices14"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service14" /> </intent-filter> </service> <service android:name=".Service15" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices15"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service15" /> </intent-filter> </service> <service android:name=".Service16" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices16"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service16" /> </intent-filter> </service> <service android:name=".Service17" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices17"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service17" /> </intent-filter> </service> <service android:name=".Service18" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices18"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service18" /> </intent-filter> </service> <service android:name=".Service19" android:exported="true" android:process=":com.android.framework.multidexlegacytestservices19"> <intent-filter> <action android:name="com.android.framework.multidexlegacytestservices.action.Service19" /> </intent-filter> </service> </application> </manifest>
core/tests/hosttests/test-apps/MultiDexLegacyTestServices/src/com/android/framework/multidexlegacytestservices/AbstractService.java 0 → 100644 +167 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.framework.multidexlegacytestservices; import android.app.Service; import android.content.Context; import android.content.Intent; import android.os.IBinder; import android.support.multidex.MultiDex; import android.util.Log; import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; /** * Empty service for testing legacy multidex. Access more than 64k methods but some are required at * init, some only at verification and others during execution. */ public abstract class AbstractService extends Service { private final String TAG = "MultidexLegacyTestService" + getId(); private int instanceFieldNotInited; private int instanceFieldInited = new com.android.framework.multidexlegacytestservices.manymethods.Big043().get43(); private static int staticField = new com.android.framework.multidexlegacytestservices.manymethods.Big044().get44(); public AbstractService() { instanceFieldNotInited = new com.android.framework.multidexlegacytestservices.manymethods.Big042().get42(); } @Override public void onCreate() { Log.i(TAG, "onCreate"); Context applicationContext = getApplicationContext(); File resultFile = new File(applicationContext.getFilesDir(), getId()); try { // Append a constant value in result file, if services crashed and is relaunched, size // of the result file will be too big. RandomAccessFile raf = new RandomAccessFile(resultFile, "rw"); raf.seek(raf.length()); Log.i(TAG, "Writing 0x42434445 at " + raf.length() + " in " + resultFile.getPath()); raf.writeInt(0x42434445); raf.close(); } catch (IOException e) { e.printStackTrace(); } MultiDex.install(applicationContext); Log.i(TAG, "Multi dex installation done."); int value = getValue(); Log.i(TAG, "Saving the result (" + value + ") to " + resultFile.getPath()); try { // Append the check value in result file, keeping the constant values already written. RandomAccessFile raf = new RandomAccessFile(resultFile, "rw"); raf.seek(raf.length()); Log.i(TAG, "Writing result at " + raf.length() + " in " + resultFile.getPath()); raf.writeInt(value); raf.close(); } catch (IOException e) { e.printStackTrace(); } try { // Writing end of processing flags, the existence of the file is the criteria RandomAccessFile raf = new RandomAccessFile(new File(applicationContext.getFilesDir(), getId() + ".complete"), "rw"); Log.i(TAG, "creating complete file " + resultFile.getPath()); raf.writeInt(0x32333435); raf.close(); } catch (IOException e) { e.printStackTrace(); } } @Override public int onStartCommand(Intent intent, int flags, int startId) { Log.i("Service" + getId(), "Received start id " + startId + ": " + intent); // We want this service to continue running until it is explicitly // stopped, so return sticky. return START_STICKY; } private String getId() { return this.getClass().getSimpleName(); } @Override public void onDestroy() { } @Override public IBinder onBind(Intent intent) { return null; } public int getValue() { int intermediate = -1; try { intermediate = ReflectIntermediateClass.get(45, 80, 20 /* 5 seems enough on a nakasi, using 20 to get some margin */); } catch (Exception e) { e.printStackTrace(); } int value = new com.android.framework.multidexlegacytestservices.manymethods.Big001().get1() + new com.android.framework.multidexlegacytestservices.manymethods.Big002().get2() + new com.android.framework.multidexlegacytestservices.manymethods.Big003().get3() + new com.android.framework.multidexlegacytestservices.manymethods.Big004().get4() + new com.android.framework.multidexlegacytestservices.manymethods.Big005().get5() + new com.android.framework.multidexlegacytestservices.manymethods.Big006().get6() + new com.android.framework.multidexlegacytestservices.manymethods.Big007().get7() + new com.android.framework.multidexlegacytestservices.manymethods.Big008().get8() + new com.android.framework.multidexlegacytestservices.manymethods.Big009().get9() + new com.android.framework.multidexlegacytestservices.manymethods.Big010().get10() + new com.android.framework.multidexlegacytestservices.manymethods.Big011().get11() + new com.android.framework.multidexlegacytestservices.manymethods.Big012().get12() + new com.android.framework.multidexlegacytestservices.manymethods.Big013().get13() + new com.android.framework.multidexlegacytestservices.manymethods.Big014().get14() + new com.android.framework.multidexlegacytestservices.manymethods.Big015().get15() + new com.android.framework.multidexlegacytestservices.manymethods.Big016().get16() + new com.android.framework.multidexlegacytestservices.manymethods.Big017().get17() + new com.android.framework.multidexlegacytestservices.manymethods.Big018().get18() + new com.android.framework.multidexlegacytestservices.manymethods.Big019().get19() + new com.android.framework.multidexlegacytestservices.manymethods.Big020().get20() + new com.android.framework.multidexlegacytestservices.manymethods.Big021().get21() + new com.android.framework.multidexlegacytestservices.manymethods.Big022().get22() + new com.android.framework.multidexlegacytestservices.manymethods.Big023().get23() + new com.android.framework.multidexlegacytestservices.manymethods.Big024().get24() + new com.android.framework.multidexlegacytestservices.manymethods.Big025().get25() + new com.android.framework.multidexlegacytestservices.manymethods.Big026().get26() + new com.android.framework.multidexlegacytestservices.manymethods.Big027().get27() + new com.android.framework.multidexlegacytestservices.manymethods.Big028().get28() + new com.android.framework.multidexlegacytestservices.manymethods.Big029().get29() + new com.android.framework.multidexlegacytestservices.manymethods.Big030().get30() + new com.android.framework.multidexlegacytestservices.manymethods.Big031().get31() + new com.android.framework.multidexlegacytestservices.manymethods.Big032().get32() + new com.android.framework.multidexlegacytestservices.manymethods.Big033().get33() + new com.android.framework.multidexlegacytestservices.manymethods.Big034().get34() + new com.android.framework.multidexlegacytestservices.manymethods.Big035().get35() + new com.android.framework.multidexlegacytestservices.manymethods.Big036().get36() + new com.android.framework.multidexlegacytestservices.manymethods.Big037().get37() + new com.android.framework.multidexlegacytestservices.manymethods.Big038().get38() + new com.android.framework.multidexlegacytestservices.manymethods.Big039().get39() + new com.android.framework.multidexlegacytestservices.manymethods.Big040().get40() + new com.android.framework.multidexlegacytestservices.manymethods.Big041().get41() + instanceFieldNotInited + instanceFieldInited + staticField + intermediate; return value; } }
core/tests/hosttests/test-apps/MultiDexLegacyTestServices/src/com/android/framework/multidexlegacytestservices/ReflectIntermediateClass.java 0 → 100644 +46 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.framework.multidexlegacytestservices; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** * Offer an indirection to some Big0xx classes and have their initialization * spread along a period of time. */ public class ReflectIntermediateClass { public static int get(int from, int to, int sleepMillis) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, InstantiationException { int value = 0; for (int i = from; i <= to; i++) { Class<?> bigClass = Class.forName( "com.android.framework.multidexlegacytestservices.manymethods.Big0" + i); Method get = bigClass.getMethod("get" + i); value += ((Integer) get.invoke(bigClass.newInstance())).intValue(); try { Thread.sleep(sleepMillis); } catch (InterruptedException e) { e.printStackTrace(); } } return value; } }
core/tests/hosttests/test-apps/MultiDexLegacyTestServices/src/com/android/framework/multidexlegacytestservices/Service1.java 0 → 100644 +24 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.framework.multidexlegacytestservices; /** * Empty service for testing legacy multidex */ public class Service1 extends AbstractService { }