Home | History | Annotate | Download | only in am
      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 
     17 package android.server.am;
     18 
     19 import static android.server.am.Components.MoveTaskToBackActivity.EXTRA_FINISH_POINT;
     20 import static android.server.am.Components.MoveTaskToBackActivity.FINISH_POINT_ON_PAUSE;
     21 import static android.server.am.Components.MoveTaskToBackActivity.FINISH_POINT_ON_STOP;
     22 
     23 import android.content.Intent;
     24 import android.os.Bundle;
     25 
     26 /**
     27  * Activity that finishes itself using "moveTaskToBack".
     28  */
     29 public class MoveTaskToBackActivity extends AbstractLifecycleLogActivity {
     30 
     31     private String mFinishPoint;
     32 
     33     @Override
     34     protected void onCreate(Bundle icicle) {
     35         super.onCreate(icicle);
     36 
     37         final Intent intent = getIntent();
     38         mFinishPoint = intent.getExtras().getString(EXTRA_FINISH_POINT);
     39     }
     40 
     41     @Override
     42     protected void onPause() {
     43         super.onPause();
     44 
     45         if (FINISH_POINT_ON_PAUSE.equals(mFinishPoint)) {
     46             moveTaskToBack(true /* nonRoot */);
     47         }
     48     }
     49 
     50     @Override
     51     protected void onStop() {
     52         super.onStop();
     53 
     54         if (FINISH_POINT_ON_STOP.equals(mFinishPoint)) {
     55             moveTaskToBack(true /* nonRoot */);
     56         }
     57     }
     58 }
     59