1cc94118f978146761cfb697091da5401cbec6a1bgoneil/* 2cc94118f978146761cfb697091da5401cbec6a1bgoneil * Copyright (C) 2018 The Android Open Source Project 3cc94118f978146761cfb697091da5401cbec6a1bgoneil * 4cc94118f978146761cfb697091da5401cbec6a1bgoneil * Licensed under the Apache License, Version 2.0 (the "License"); 5cc94118f978146761cfb697091da5401cbec6a1bgoneil * you may not use this file except in compliance with the License. 6cc94118f978146761cfb697091da5401cbec6a1bgoneil * You may obtain a copy of the License at 7cc94118f978146761cfb697091da5401cbec6a1bgoneil * 8cc94118f978146761cfb697091da5401cbec6a1bgoneil * http://www.apache.org/licenses/LICENSE-2.0 9cc94118f978146761cfb697091da5401cbec6a1bgoneil * 10cc94118f978146761cfb697091da5401cbec6a1bgoneil * Unless required by applicable law or agreed to in writing, software 11cc94118f978146761cfb697091da5401cbec6a1bgoneil * distributed under the License is distributed on an "AS IS" BASIS, 12cc94118f978146761cfb697091da5401cbec6a1bgoneil * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13cc94118f978146761cfb697091da5401cbec6a1bgoneil * See the License for the specific language governing permissions and 14cc94118f978146761cfb697091da5401cbec6a1bgoneil * limitations under the License. 15cc94118f978146761cfb697091da5401cbec6a1bgoneil */ 16cc94118f978146761cfb697091da5401cbec6a1bgoneil 17cc94118f978146761cfb697091da5401cbec6a1bgoneilpackage com.android.internal.telephony.uicc; 18cc94118f978146761cfb697091da5401cbec6a1bgoneil 19cc94118f978146761cfb697091da5401cbec6a1bgoneilimport android.content.BroadcastReceiver; 20cc94118f978146761cfb697091da5401cbec6a1bgoneilimport android.content.Context; 21cc94118f978146761cfb697091da5401cbec6a1bgoneilimport android.content.Intent; 22cc94118f978146761cfb697091da5401cbec6a1bgoneil 23cc94118f978146761cfb697091da5401cbec6a1bgoneil/** 24cc94118f978146761cfb697091da5401cbec6a1bgoneil * Receiver used to show a notification that prompts the user to install the package (contained in 25cc94118f978146761cfb697091da5401cbec6a1bgoneil * string extras) from the play store 26cc94118f978146761cfb697091da5401cbec6a1bgoneil */ 27cc94118f978146761cfb697091da5401cbec6a1bgoneilpublic class ShowInstallAppNotificationReceiver extends BroadcastReceiver { 28cc94118f978146761cfb697091da5401cbec6a1bgoneil private static final String EXTRA_PACKAGE_NAME = "package_name"; 29cc94118f978146761cfb697091da5401cbec6a1bgoneil 30cc94118f978146761cfb697091da5401cbec6a1bgoneil /** Returns intent used to send a broadcast to this receiver */ 31cc94118f978146761cfb697091da5401cbec6a1bgoneil public static Intent get(Context context, String pkgName) { 32cc94118f978146761cfb697091da5401cbec6a1bgoneil Intent intent = new Intent(context, ShowInstallAppNotificationReceiver.class); 33cc94118f978146761cfb697091da5401cbec6a1bgoneil intent.putExtra(EXTRA_PACKAGE_NAME, pkgName); 34cc94118f978146761cfb697091da5401cbec6a1bgoneil return intent; 35cc94118f978146761cfb697091da5401cbec6a1bgoneil } 36cc94118f978146761cfb697091da5401cbec6a1bgoneil 37cc94118f978146761cfb697091da5401cbec6a1bgoneil @Override 38cc94118f978146761cfb697091da5401cbec6a1bgoneil public void onReceive(Context context, Intent intent) { 39cc94118f978146761cfb697091da5401cbec6a1bgoneil String pkgName = intent.getStringExtra(EXTRA_PACKAGE_NAME); 40cc94118f978146761cfb697091da5401cbec6a1bgoneil 41cc94118f978146761cfb697091da5401cbec6a1bgoneil if (!UiccProfile.isPackageInstalled(context, pkgName)) { 42cc94118f978146761cfb697091da5401cbec6a1bgoneil InstallCarrierAppUtils.showNotification(context, pkgName); 43cc94118f978146761cfb697091da5401cbec6a1bgoneil InstallCarrierAppUtils.registerPackageInstallReceiver(context); 44cc94118f978146761cfb697091da5401cbec6a1bgoneil } 45cc94118f978146761cfb697091da5401cbec6a1bgoneil } 46cc94118f978146761cfb697091da5401cbec6a1bgoneil} 47