1 /*
2  * Copyright (C) 2017 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 package androidx.wear.ambient;
17 
18 import android.os.Bundle;
19 
20 import androidx.fragment.app.FragmentActivity;
21 
22 public class AmbientModeTestActivity extends FragmentActivity
23         implements AmbientMode.AmbientCallbackProvider {
24     AmbientMode.AmbientController mAmbientController;
25 
26     boolean mEnterAmbientCalled;
27     boolean mUpdateAmbientCalled;
28     boolean mExitAmbientCalled;
29 
30     @Override
onCreate(Bundle savedInstanceState)31     protected void onCreate(Bundle savedInstanceState) {
32         super.onCreate(savedInstanceState);
33         mAmbientController = AmbientMode.attachAmbientSupport(this);
34     }
35 
36     @Override
getAmbientCallback()37     public AmbientMode.AmbientCallback getAmbientCallback() {
38         return new MyAmbientCallback();
39     }
40 
41     private class MyAmbientCallback extends AmbientMode.AmbientCallback {
42 
43         @Override
onEnterAmbient(Bundle ambientDetails)44         public void onEnterAmbient(Bundle ambientDetails) {
45             mEnterAmbientCalled = true;
46         }
47 
48         @Override
onUpdateAmbient()49         public void onUpdateAmbient() {
50             mUpdateAmbientCalled = true;
51         }
52 
53         @Override
onExitAmbient()54         public void onExitAmbient() {
55             mExitAmbientCalled = true;
56         }
57     }
58 
getAmbientController()59     public AmbientMode.AmbientController getAmbientController() {
60         return mAmbientController;
61     }
62 
63 }
64