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 package android.incrementalinstall.incrementaltestapp;
17 
18 import static android.incrementalinstall.common.Consts.COMPONENT_STATUS_KEY;
19 import static android.incrementalinstall.common.Consts.INCREMENTAL_TEST_APP_STATUS_RECEIVER_ACTION;
20 import static android.incrementalinstall.common.Consts.TARGET_COMPONENT_KEY;
21 
22 import android.app.Activity;
23 import android.content.Intent;
24 import android.incrementalinstall.common.Consts;
25 import android.os.Bundle;
26 
27 /** A second implementation of MainActivity to verify version updates. */
28 public class MainActivity extends Activity {
29 
30     @Override
onCreate(Bundle icicle)31     public void onCreate(Bundle icicle) {
32         super.onCreate(icicle);
33         for (String component : Consts.SupportedComponents.getAllComponents()) {
34             boolean status = component.equals(Consts.SupportedComponents.ON_CREATE_COMPONENT_2);
35             broadcastStatus(component, status ? "true" : "false");
36         }
37     }
38 
broadcastStatus(String component, String status)39     private void broadcastStatus(String component, String status) {
40         Intent intent = new Intent(INCREMENTAL_TEST_APP_STATUS_RECEIVER_ACTION);
41         intent.putExtra(TARGET_COMPONENT_KEY, component);
42         intent.putExtra(COMPONENT_STATUS_KEY, status);
43         sendBroadcast(intent);
44     }
45 }
46