1 /* 2 * Copyright (C) 2021 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.car.settingslib.enterprise; 18 19 import android.content.Intent; 20 import android.net.Uri; 21 import android.provider.ContactsContract; 22 import android.provider.MediaStore; 23 24 /** 25 * UI grouping of important intents that can be configured by device and profile owners. 26 */ 27 // TODO(b/208511815): copied from phone (but stripped what's not used), should be moved to 28 // SettingsLib 29 public enum EnterpriseDefaultApps { 30 BROWSER(new Intent[] { 31 buildIntent(Intent.ACTION_VIEW, Intent.CATEGORY_BROWSABLE, "http:", null)}), 32 CALENDAR(new Intent[] { 33 buildIntent(Intent.ACTION_INSERT, null, null, "vnd.android.cursor.dir/event")}), 34 CAMERA(new Intent[] { 35 new Intent(MediaStore.ACTION_IMAGE_CAPTURE), 36 new Intent(MediaStore.ACTION_VIDEO_CAPTURE)}), 37 CONTACTS(new Intent[] { 38 buildIntent(Intent.ACTION_PICK, null, null, ContactsContract.Contacts.CONTENT_TYPE)}), 39 EMAIL(new Intent[] { 40 new Intent(Intent.ACTION_SENDTO), new Intent(Intent.ACTION_SEND), 41 new Intent(Intent.ACTION_SEND_MULTIPLE)}), 42 MAP(new Intent[] {buildIntent(Intent.ACTION_VIEW, null, "geo:", null)}), 43 PHONE(new Intent[] {new Intent(Intent.ACTION_DIAL), new Intent(Intent.ACTION_CALL)}); 44 private final Intent[] mIntents; 45 EnterpriseDefaultApps(Intent[] intents)46 EnterpriseDefaultApps(Intent[] intents) { 47 mIntents = intents; 48 } 49 getIntents()50 public Intent[] getIntents() { 51 return mIntents; 52 } 53 buildIntent(String action, String category, String protocol, String type)54 private static Intent buildIntent(String action, String category, String protocol, 55 String type) { 56 final Intent intent = new Intent(action); 57 if (category != null) { 58 intent.addCategory(category); 59 } 60 if (protocol != null) { 61 intent.setData(Uri.parse(protocol)); 62 } 63 if (type != null) { 64 intent.setType(type); 65 } 66 return intent; 67 } 68 } 69