From d944986fbdb3d45fab9ae4120af76ca4f6b0909c Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Fri, 29 May 2015 14:49:08 -0700 Subject: Fix API review: Camera prewarm Let the intent receiver of a camea launch intent declare a prewarm service instead of sending broadcasts. Bug: 21347653 Change-Id: I11e31aad4f788ad90eb46a661b819d3e808ddb51 --- tests/CameraPrewarmTest/AndroidManifest.xml | 23 +++++++------- tests/CameraPrewarmTest/res/values/strings.xml | 2 +- .../android/test/cameraprewarm/CameraActivity.java | 2 -- .../test/cameraprewarm/PrewarmReceiver.java | 35 ---------------------- .../android/test/cameraprewarm/PrewarmService.java | 33 ++++++++++++++++++++ 5 files changed, 45 insertions(+), 50 deletions(-) delete mode 100644 tests/CameraPrewarmTest/src/com/google/android/test/cameraprewarm/PrewarmReceiver.java create mode 100644 tests/CameraPrewarmTest/src/com/google/android/test/cameraprewarm/PrewarmService.java (limited to 'tests') diff --git a/tests/CameraPrewarmTest/AndroidManifest.xml b/tests/CameraPrewarmTest/AndroidManifest.xml index eb40200..11b2686 100644 --- a/tests/CameraPrewarmTest/AndroidManifest.xml +++ b/tests/CameraPrewarmTest/AndroidManifest.xml @@ -22,13 +22,13 @@ - - - - + + + + - - - - - - - - + + diff --git a/tests/CameraPrewarmTest/res/values/strings.xml b/tests/CameraPrewarmTest/res/values/strings.xml index 11f7ac7..fe39ac1 100644 --- a/tests/CameraPrewarmTest/res/values/strings.xml +++ b/tests/CameraPrewarmTest/res/values/strings.xml @@ -16,6 +16,6 @@ --> - Assistant + Camera Prewarm test Orilla Search Engine diff --git a/tests/CameraPrewarmTest/src/com/google/android/test/cameraprewarm/CameraActivity.java b/tests/CameraPrewarmTest/src/com/google/android/test/cameraprewarm/CameraActivity.java index 4d22234..0b43666 100644 --- a/tests/CameraPrewarmTest/src/com/google/android/test/cameraprewarm/CameraActivity.java +++ b/tests/CameraPrewarmTest/src/com/google/android/test/cameraprewarm/CameraActivity.java @@ -19,7 +19,6 @@ package com.google.android.test.cameraprewarm; import android.app.Activity; import android.os.Bundle; import android.util.Log; -import android.view.WindowManager; import com.google.android.test.cameraprewarm.R; @@ -31,7 +30,6 @@ public class CameraActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera_activity); - getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); Log.i(TAG, "Activity created"); } } diff --git a/tests/CameraPrewarmTest/src/com/google/android/test/cameraprewarm/PrewarmReceiver.java b/tests/CameraPrewarmTest/src/com/google/android/test/cameraprewarm/PrewarmReceiver.java deleted file mode 100644 index d49f96d..0000000 --- a/tests/CameraPrewarmTest/src/com/google/android/test/cameraprewarm/PrewarmReceiver.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2015 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.google.android.test.cameraprewarm; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.provider.MediaStore; -import android.util.Log; - -public class PrewarmReceiver extends BroadcastReceiver { - - @Override - public void onReceive(Context context, Intent intent) { - if (intent.getAction().equals(MediaStore.ACTION_STILL_IMAGE_CAMERA_PREWARM)) { - Log.i(CameraActivity.TAG, "Prewarm received"); - } else if (intent.getAction().equals(MediaStore.ACTION_STILL_IMAGE_CAMERA_COOLDOWN)){ - Log.i(CameraActivity.TAG, "Cooldown received"); - } - } -} diff --git a/tests/CameraPrewarmTest/src/com/google/android/test/cameraprewarm/PrewarmService.java b/tests/CameraPrewarmTest/src/com/google/android/test/cameraprewarm/PrewarmService.java new file mode 100644 index 0000000..d080b1a --- /dev/null +++ b/tests/CameraPrewarmTest/src/com/google/android/test/cameraprewarm/PrewarmService.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2015 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.google.android.test.cameraprewarm; + +import android.service.media.CameraPrewarmService; +import android.util.Log; + +public class PrewarmService extends CameraPrewarmService { + + @Override + public void onPrewarm() { + Log.i("PrewarmService", "Warming up"); + } + + @Override + public void onCooldown(boolean cameraIntentFired) { + Log.i("PrewarmService", "Cooling down fired=" + cameraIntentFired); + } +} -- cgit v1.1