From aef4b828813f6e42abf46397861c411636fcf74b Mon Sep 17 00:00:00 2001 From: Sasha Smundak Date: Sun, 24 Feb 2019 14:47:36 -0800 Subject: Remove unused tests/utils/SleepUtils The presense of these files hinders the conversion of the makefiles to the blueprints (causes failure in the internal builds due to lacking files). Bug: 122332340 Test: treehugger Change-Id: I2a3c38cbba7c14ae1b2880c73c7f6514816f0e68 --- tests/utils/SleepUtils/AlarmService/Android.mk | 26 ---- .../SleepUtils/AlarmService/AndroidManifest.xml | 31 ----- .../com/android/testing/alarmservice/Alarm.aidl | 23 ---- .../android/testing/alarmservice/AlarmImpl.java | 77 ----------- .../android/testing/alarmservice/AlarmService.java | 52 ------- .../android/testing/alarmservice/WakeUpCall.java | 42 ------ .../testing/alarmservice/WakeUpController.java | 59 -------- tests/utils/SleepUtils/Android.mk | 2 - tests/utils/SleepUtils/README | 23 ---- tests/utils/SleepUtils/SleepHelper/Android.mk | 29 ---- .../SleepUtils/SleepHelper/AndroidManifest.xml | 21 --- .../com/android/testing/sleephelper/SetAlarm.java | 152 --------------------- tests/utils/SleepUtils/WakeLoopService/Android.mk | 24 ---- .../SleepUtils/WakeLoopService/AndroidManifest.xml | 32 ----- .../src/android/test/wakeuploop/FileUtil.java | 53 ------- .../android/test/wakeuploop/WakeLoopService.java | 98 ------------- .../src/android/test/wakeuploop/WakeUpCall.java | 112 --------------- 17 files changed, 856 deletions(-) delete mode 100644 tests/utils/SleepUtils/AlarmService/Android.mk delete mode 100644 tests/utils/SleepUtils/AlarmService/AndroidManifest.xml delete mode 100644 tests/utils/SleepUtils/AlarmService/src/com/android/testing/alarmservice/Alarm.aidl delete mode 100644 tests/utils/SleepUtils/AlarmService/src/com/android/testing/alarmservice/AlarmImpl.java delete mode 100644 tests/utils/SleepUtils/AlarmService/src/com/android/testing/alarmservice/AlarmService.java delete mode 100644 tests/utils/SleepUtils/AlarmService/src/com/android/testing/alarmservice/WakeUpCall.java delete mode 100644 tests/utils/SleepUtils/AlarmService/src/com/android/testing/alarmservice/WakeUpController.java delete mode 100644 tests/utils/SleepUtils/Android.mk delete mode 100644 tests/utils/SleepUtils/README delete mode 100644 tests/utils/SleepUtils/SleepHelper/Android.mk delete mode 100644 tests/utils/SleepUtils/SleepHelper/AndroidManifest.xml delete mode 100644 tests/utils/SleepUtils/SleepHelper/src/com/android/testing/sleephelper/SetAlarm.java delete mode 100644 tests/utils/SleepUtils/WakeLoopService/Android.mk delete mode 100644 tests/utils/SleepUtils/WakeLoopService/AndroidManifest.xml delete mode 100644 tests/utils/SleepUtils/WakeLoopService/src/android/test/wakeuploop/FileUtil.java delete mode 100644 tests/utils/SleepUtils/WakeLoopService/src/android/test/wakeuploop/WakeLoopService.java delete mode 100644 tests/utils/SleepUtils/WakeLoopService/src/android/test/wakeuploop/WakeUpCall.java diff --git a/tests/utils/SleepUtils/AlarmService/Android.mk b/tests/utils/SleepUtils/AlarmService/Android.mk deleted file mode 100644 index 9022f03b7cf2..000000000000 --- a/tests/utils/SleepUtils/AlarmService/Android.mk +++ /dev/null @@ -1,26 +0,0 @@ -# -# Copyright (C) 2013 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_SRC_FILES += \ - src/com/android/testing/alarmservice/Alarm.aidl -LOCAL_PACKAGE_NAME := SleepUtilsAlarmService -LOCAL_SDK_VERSION := 7 -include $(BUILD_PACKAGE) diff --git a/tests/utils/SleepUtils/AlarmService/AndroidManifest.xml b/tests/utils/SleepUtils/AlarmService/AndroidManifest.xml deleted file mode 100644 index 1b6de39c91da..000000000000 --- a/tests/utils/SleepUtils/AlarmService/AndroidManifest.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/utils/SleepUtils/AlarmService/src/com/android/testing/alarmservice/Alarm.aidl b/tests/utils/SleepUtils/AlarmService/src/com/android/testing/alarmservice/Alarm.aidl deleted file mode 100644 index 62a8c4866f07..000000000000 --- a/tests/utils/SleepUtils/AlarmService/src/com/android/testing/alarmservice/Alarm.aidl +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2013 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.testing.alarmservice; - -interface Alarm { - int prepare(); - int setAlarmAndWait(long timeoutMills); - int done(); -} \ No newline at end of file diff --git a/tests/utils/SleepUtils/AlarmService/src/com/android/testing/alarmservice/AlarmImpl.java b/tests/utils/SleepUtils/AlarmService/src/com/android/testing/alarmservice/AlarmImpl.java deleted file mode 100644 index 122d55deb3e5..000000000000 --- a/tests/utils/SleepUtils/AlarmService/src/com/android/testing/alarmservice/AlarmImpl.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2013 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.testing.alarmservice; - -import android.app.AlarmManager; -import android.app.PendingIntent; -import android.content.Context; -import android.content.Intent; -import android.os.RemoteException; -import android.os.SystemClock; -import android.util.Log; - -import com.android.testing.alarmservice.Alarm.Stub; - -public class AlarmImpl extends Stub { - - private static final String LOG_TAG = AlarmImpl.class.getSimpleName(); - - private Context mContext; - - public AlarmImpl(Context context) { - super(); - mContext = context; - } - - @Override - public int prepare() throws RemoteException { - WakeUpController.getController().getWakeLock().acquire(); - Log.d(LOG_TAG, "AlarmService prepared, wake lock acquired"); - return 0; - } - - @Override - public int setAlarmAndWait(long timeoutMills) throws RemoteException { - // calculate when device should be waken up - long atTime = SystemClock.elapsedRealtime() + timeoutMills; - AlarmManager am = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); - Intent wakupIntent = new Intent(WakeUpCall.WAKEUP_CALL); - PendingIntent pi = PendingIntent.getBroadcast(mContext, 0, wakupIntent, 0); - // set alarm, which will be delivered in form of the wakeupIntent - am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, atTime, pi); - Log.d(LOG_TAG, String.format("Alarm set: %d, giving up wake lock", atTime)); - Object lock = WakeUpController.getController().getWakeSync(); - // release wakelock and wait for the lock to be poked from the broadcast receiver - WakeUpController.getController().getWakeLock().release(); - // does not really matter if device enters suspend before we start waiting on lock - synchronized (lock) { - try { - lock.wait(); - } catch (InterruptedException e) { - } - } - Log.d(LOG_TAG, String.format("Alarm triggered, done waiting")); - return 0; - } - - @Override - public int done() throws RemoteException { - WakeUpController.getController().getWakeLock().release(); - return 0; - } - -} diff --git a/tests/utils/SleepUtils/AlarmService/src/com/android/testing/alarmservice/AlarmService.java b/tests/utils/SleepUtils/AlarmService/src/com/android/testing/alarmservice/AlarmService.java deleted file mode 100644 index 576a1cfcfbaf..000000000000 --- a/tests/utils/SleepUtils/AlarmService/src/com/android/testing/alarmservice/AlarmService.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2013 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.testing.alarmservice; - -import android.app.Service; -import android.content.Context; -import android.content.Intent; -import android.os.IBinder; - -public class AlarmService extends Service { - - private AlarmImpl mAlarmImpl = null; - static Context sContext; - - @Override - public void onCreate() { - super.onCreate(); - sContext = this; - } - - @Override - public IBinder onBind(Intent intent) { - return getAlarmImpl(); - } - - private AlarmImpl getAlarmImpl() { - if (mAlarmImpl == null) { - mAlarmImpl = new AlarmImpl(this); - } - return mAlarmImpl; - } - - @Override - public void onDestroy() { - sContext = null; - super.onDestroy(); - } -} diff --git a/tests/utils/SleepUtils/AlarmService/src/com/android/testing/alarmservice/WakeUpCall.java b/tests/utils/SleepUtils/AlarmService/src/com/android/testing/alarmservice/WakeUpCall.java deleted file mode 100644 index f4bb4dba4cda..000000000000 --- a/tests/utils/SleepUtils/AlarmService/src/com/android/testing/alarmservice/WakeUpCall.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2013 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.testing.alarmservice; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; - -/** - * The receiver for the alarm we set - * - */ -public class WakeUpCall extends BroadcastReceiver { - - public static final String WAKEUP_CALL = "com.android.testing.alarmservice.WAKEUP"; - - @Override - public void onReceive(Context context, Intent intent) { - // we acquire wakelock without release because user is supposed to manually release it - WakeUpController.getController().getWakeLock().acquire(); - Object lock = WakeUpController.getController().getWakeSync(); - synchronized (lock) { - // poke the lock so the service side can be woken from waiting on the lock - lock.notifyAll(); - } - } - -} diff --git a/tests/utils/SleepUtils/AlarmService/src/com/android/testing/alarmservice/WakeUpController.java b/tests/utils/SleepUtils/AlarmService/src/com/android/testing/alarmservice/WakeUpController.java deleted file mode 100644 index 478371f61f36..000000000000 --- a/tests/utils/SleepUtils/AlarmService/src/com/android/testing/alarmservice/WakeUpController.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2013 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.testing.alarmservice; - -import android.content.Context; -import android.os.PowerManager; -import android.os.PowerManager.WakeLock; -import android.util.Log; - -/** - * A singleton used for controlling and sharing of states/wakelocks - * - */ -public class WakeUpController { - - private static final String LOG_TAG = WakeUpController.class.getName(); - private static WakeUpController mController = null; - private WakeLock mWakeLock = null; - private Object mWakeSync = new Object(); - - private WakeUpController() { - Log.i(LOG_TAG, "Created instance: 0x" + Integer.toHexString(this.hashCode())); - } - - public static synchronized WakeUpController getController() { - if (mController == null) { - mController = new WakeUpController(); - } - return mController; - } - - public WakeLock getWakeLock() { - if (mWakeLock == null) { - PowerManager pm = - (PowerManager) AlarmService.sContext.getSystemService(Context.POWER_SERVICE); - mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "testing-alarmservice"); - Log.i(LOG_TAG, "Create wakelock: 0x" + Integer.toHexString(mWakeLock.hashCode())); - } - return mWakeLock; - } - - public Object getWakeSync() { - return mWakeSync; - } -} diff --git a/tests/utils/SleepUtils/Android.mk b/tests/utils/SleepUtils/Android.mk deleted file mode 100644 index 0e65e2255c5b..000000000000 --- a/tests/utils/SleepUtils/Android.mk +++ /dev/null @@ -1,2 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(call all-makefiles-under, $(LOCAL_PATH)) diff --git a/tests/utils/SleepUtils/README b/tests/utils/SleepUtils/README deleted file mode 100644 index bfe07da4a389..000000000000 --- a/tests/utils/SleepUtils/README +++ /dev/null @@ -1,23 +0,0 @@ -This folder contains utils to properly perform timed suspend and wakeup. - -AlarmService - a service that client can bind to and perform: -1) holding wakelock (singleton to this service) -2) setting alarm for a specified period and releasing the wakelock; service - call will block until alarm has been triggered and the wakelock is held -3) releasing the wakelock - -SleepHelper - a self instrumentation meant as a convenient way to trigger -the service functions from command line. Corresponding to service function -above, supported operations are: -1) holding wakelock -am instrument -w -e command prepare \ - com.android.testing.sleephelper/.SetAlarm - -2) setting alarm and wait til triggered -am instrument -w -e command set_wait \ - -e param