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 com.android.systemui.car.sideloaded; 18 19 import android.app.IActivityTaskManager; 20 import android.content.Context; 21 import android.os.RemoteException; 22 import android.util.Log; 23 24 import com.android.systemui.SystemUI; 25 import com.android.systemui.dagger.SysUISingleton; 26 27 import javax.inject.Inject; 28 29 /** 30 * Controller responsible for detecting unsafe apps. 31 */ 32 @SysUISingleton 33 public class SideLoadedAppController extends SystemUI { 34 private static final String TAG = SideLoadedAppController.class.getSimpleName(); 35 36 private IActivityTaskManager mActivityTaskManager; 37 private SideLoadedAppListener mSideLoadedAppListener; 38 private SideLoadedAppDetector mSideLoadedAppDetector; 39 private SideLoadedAppStateController mSideLoadedAppStateController; 40 41 @Inject SideLoadedAppController(Context context, IActivityTaskManager activityTaskManager, SideLoadedAppDetector sideLoadedAppDetector, SideLoadedAppListener sideLoadedAppListener, SideLoadedAppStateController sideLoadedAppStateController)42 public SideLoadedAppController(Context context, 43 IActivityTaskManager activityTaskManager, 44 SideLoadedAppDetector sideLoadedAppDetector, 45 SideLoadedAppListener sideLoadedAppListener, 46 SideLoadedAppStateController sideLoadedAppStateController) { 47 super(context); 48 49 mSideLoadedAppDetector = sideLoadedAppDetector; 50 mActivityTaskManager = activityTaskManager; 51 mSideLoadedAppListener = sideLoadedAppListener; 52 mSideLoadedAppStateController = sideLoadedAppStateController; 53 } 54 55 @Override start()56 public void start() { 57 } 58 59 @Override onBootCompleted()60 protected void onBootCompleted() { 61 Log.i(TAG, "OnBootCompleted"); 62 63 try { 64 mActivityTaskManager.registerTaskStackListener(mSideLoadedAppListener); 65 } catch (RemoteException e) { 66 Log.e(TAG, "Could not register car side loaded app listener.", e); 67 } 68 69 if (mSideLoadedAppDetector.hasUnsafeInstalledApps()) { 70 mSideLoadedAppStateController.onUnsafeInstalledAppsDetected(); 71 } 72 } 73 } 74