1 /*
2  * Copyright (C) 2019 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 com.android.car.fakelauncher;
18 
19 import android.app.Activity;
20 import android.content.Intent;
21 import android.os.Bundle;
22 import android.os.Trace;
23 import android.os.UserHandle;
24 import android.util.Log;
25 import android.view.View;
26 import android.widget.TextView;
27 
28 /**
29  * A placeholder launcher for CTS.
30  *
31  * Current CarLauncher invokes Maps Activity in its TaskView and it creates unexpected events
32  * for CTS and they make CTS fail.
33  */
34 public class LauncherActivity extends Activity {
35     private static final String TAG = "FakeLauncher";
36 
37     private int mUserId = UserHandle.USER_NULL;
38 
39     @Override
onCreate(Bundle savedInstanceState)40     protected void onCreate(Bundle savedInstanceState) {
41         mUserId = UserHandle.myUserId();
42         Log.i(TAG, "pre.onCreate(): userId=" + mUserId);
43         super.onCreate(savedInstanceState);
44         Log.i(TAG, "post.onCreate(): userId=" + mUserId);
45         View view = getLayoutInflater().inflate(R.layout.launcher_activity, null);
46         setContentView(view);
47 
48         TextView message = findViewById(R.id.message);
49         message.setText(message.getText() + "\n\nI am user " + mUserId);
50         reportFullyDrawn();
51         Log.i(TAG, "done.onCreate(): userId=" + mUserId);
52     }
53 
54     @Override
onResume()55     protected void onResume() {
56         Trace.traceBegin(Trace.TRACE_TAG_APP, "onResume-" + mUserId);
57         Log.i(TAG, "pre.onResume(): userId=" + mUserId);
58         super.onResume();
59         Log.i(TAG, "post.onResume(): userId=" + mUserId);
60         Trace.traceEnd(Trace.TRACE_TAG_APP);
61     }
62 
63     @Override
onPostResume()64     protected void onPostResume() {
65         Trace.traceBegin(Trace.TRACE_TAG_APP, "onPostResume-" + mUserId);
66         Log.i(TAG, "pre.onPostResume(): userId=" + mUserId);
67         super.onPostResume();
68         Log.i(TAG, "post.onPostResume(): userId=" + mUserId);
69         Trace.traceEnd(Trace.TRACE_TAG_APP);
70     }
71 
72     @Override
onRestart()73     protected void onRestart() {
74         Log.i(TAG, "pre.onRestart(): userId=" + mUserId);
75         super.onRestart();
76         Log.i(TAG, "post.onRestart(): userId=" + mUserId);
77     }
78 
79     @Override
onActivityReenter(int resultCode, Intent data)80     public void onActivityReenter(int resultCode, Intent data) {
81         Log.i(TAG, "pre.onActivityReenter(): userId=" + mUserId);
82         super.onActivityReenter(resultCode, data);
83         Log.i(TAG, "post.onActivityReenter(): userId=" + mUserId);
84     }
85 
86     @Override
onEnterAnimationComplete()87     public void onEnterAnimationComplete() {
88         Log.i(TAG, "pre.onEnterAnimationComplete(): userId=" + mUserId);
89         super.onEnterAnimationComplete();
90         Log.i(TAG, "post.onEnterAnimationComplete(): userId=" + mUserId);
91     }
92 
93     @Override
onStop()94     protected void onStop() {
95         Log.i(TAG, "pre.onStop(): userId=" + mUserId);
96         super.onStop();
97         Log.i(TAG, "post.onStop(): userId=" + mUserId);
98     }
99 
100     @Override
onDestroy()101     protected void onDestroy() {
102         Log.i(TAG, "pre.onDestroy(): userId=" + mUserId);
103         super.onDestroy();
104         Log.i(TAG, "post.onDestroy(): userId=" + mUserId);
105     }
106 }
107 
108