1 /*
2  * Copyright (C) 2020 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.wm;
18 
19 
20 import static android.server.wm.StartActivityAsUserTests.EXTRA_CALLBACK;
21 import static android.server.wm.StartActivityAsUserTests.KEY_USER_ID;
22 
23 import android.app.Activity;
24 import android.os.Bundle;
25 import android.os.RemoteCallback;
26 import android.os.UserHandle;
27 import android.util.Log;
28 
29 public class StartActivityAsUserActivity extends Activity {
30     private static final String LOG_TAG = "startActivityAsUserTest";
31 
32     @Override
onCreate(Bundle bundle)33     public void onCreate(Bundle bundle) {
34         super.onCreate(bundle);
35         Bundle extra = getIntent().getExtras();
36         RemoteCallback cb = (RemoteCallback) extra.get(EXTRA_CALLBACK);
37         if (cb != null) {
38             Bundle result = new Bundle();
39             result.putInt(KEY_USER_ID, UserHandle.myUserId());
40             cb.sendResult(result);
41         }
42         Log.i(LOG_TAG, "Second activity started with user " + UserHandle.myUserId());
43         finish();
44     }
45 }
46 
47 
48