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.packageinstaller.role.ui; 18 19 import android.app.Activity; 20 import android.content.Intent; 21 import android.os.Bundle; 22 import android.os.Process; 23 24 import com.android.packageinstaller.role.service.RoleSearchIndexablesProvider; 25 26 /** 27 * Trampoline activity for activities exposed from 28 * {@link com.android.packageinstaller.role.service.RoleSearchIndexablesProvider}. 29 */ 30 public class RoleSearchTrampolineActivity extends Activity { 31 32 @Override onCreate(Bundle savedInstanceState)33 protected void onCreate(Bundle savedInstanceState) { 34 super.onCreate(savedInstanceState); 35 36 Intent intent = getIntent(); 37 if (!RoleSearchIndexablesProvider.isIntentValid(intent, this)) { 38 finish(); 39 return; 40 } 41 42 String action = intent.getAction(); 43 if (action == null) { 44 finish(); 45 return; 46 } 47 48 Intent newIntent; 49 switch (action) { 50 case RoleSearchIndexablesProvider.ACTION_MANAGE_DEFAULT_APP: 51 newIntent = DefaultAppActivity.createIntent( 52 // We don't support work profile in search. 53 RoleSearchIndexablesProvider.getOriginalKey(intent), Process.myUserHandle(), 54 this); 55 break; 56 case RoleSearchIndexablesProvider.ACTION_MANAGE_SPECIAL_APP_ACCESS: 57 newIntent = SpecialAppAccessActivity.createIntent( 58 RoleSearchIndexablesProvider.getOriginalKey(intent), this); 59 break; 60 default: 61 finish(); 62 return; 63 } 64 65 newIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); 66 startActivity(newIntent); 67 finish(); 68 } 69 } 70