Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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.cts.verifier.managedprovisioning; |
| 18 | |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 19 | import android.app.admin.DevicePolicyManager; |
| 20 | import android.content.ActivityNotFoundException; |
| 21 | import android.content.ComponentName; |
Daniel Xie | a41d497 | 2015-10-19 15:35:16 -0700 | [diff] [blame] | 22 | import android.content.Context; |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 23 | import android.content.Intent; |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 24 | import android.content.pm.PackageManager; |
| 25 | import android.os.Bundle; |
| 26 | import android.provider.Settings; |
| 27 | import android.util.Log; |
| 28 | import android.view.View; |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 29 | import android.view.View.OnClickListener; |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 30 | import android.widget.Toast; |
| 31 | |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 32 | import com.android.cts.verifier.ArrayTestListAdapter; |
| 33 | import com.android.cts.verifier.DialogTestListActivity; |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 34 | import com.android.cts.verifier.R; |
| 35 | import com.android.cts.verifier.TestListActivity; |
Zoltan Szatmary-Ban | 46b5ceb | 2015-07-24 12:28:19 +0100 | [diff] [blame] | 36 | import com.android.cts.verifier.TestListAdapter.TestListItem; |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 37 | import com.android.cts.verifier.TestResult; |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 38 | |
| 39 | /** |
| 40 | * CTS verifier test for BYOD managed provisioning flow. |
| 41 | * This activity is responsible for starting the managed provisioning flow and verify the outcome of provisioning. |
| 42 | * It performs the following verifications: |
| 43 | * Full disk encryption is enabled. |
| 44 | * Profile owner is correctly installed. |
| 45 | * Profile owner shows up in the Settings app. |
| 46 | * Badged work apps show up in launcher. |
| 47 | * The first two verifications are performed automatically, by interacting with profile owner using |
| 48 | * cross-profile intents, while the last two are carried out manually by the user. |
| 49 | */ |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 50 | public class ByodFlowTestActivity extends DialogTestListActivity { |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 51 | |
| 52 | private final String TAG = "ByodFlowTestActivity"; |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 53 | private static final int REQUEST_MANAGED_PROVISIONING = 0; |
Sudheer Shanka | 98ff000 | 2015-03-26 16:32:59 +0000 | [diff] [blame] | 54 | private static final int REQUEST_PROFILE_OWNER_STATUS = 1; |
| 55 | private static final int REQUEST_INTENT_FILTERS_STATUS = 2; |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 56 | |
| 57 | private ComponentName mAdminReceiverComponent; |
| 58 | |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 59 | private DialogTestListItem mProfileOwnerInstalled; |
| 60 | private DialogTestListItem mProfileAccountVisibleTest; |
| 61 | private DialogTestListItem mDeviceAdminVisibleTest; |
| 62 | private DialogTestListItem mWorkAppVisibleTest; |
Daniel Xie | a41d497 | 2015-10-19 15:35:16 -0700 | [diff] [blame] | 63 | private DialogTestListItem mCrossProfileIntentFiltersTestFromPersonal; |
| 64 | private DialogTestListItem mCrossProfileIntentFiltersTestFromWork; |
| 65 | private DialogTestListItem mAppLinkingTest; |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 66 | private DialogTestListItem mDisableNonMarketTest; |
| 67 | private DialogTestListItem mEnableNonMarketTest; |
| 68 | private DialogTestListItem mWorkNotificationBadgedTest; |
| 69 | private DialogTestListItem mWorkStatusBarIconTest; |
| 70 | private DialogTestListItem mWorkStatusBarToastTest; |
| 71 | private DialogTestListItem mAppSettingsVisibleTest; |
| 72 | private DialogTestListItem mLocationSettingsVisibleTest; |
Michal Karpinski | bb5c533 | 2015-08-12 16:15:31 +0100 | [diff] [blame] | 73 | private DialogTestListItem mBatterySettingsVisibleTest; |
| 74 | private DialogTestListItem mDataUsageSettingsVisibleTest; |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 75 | private DialogTestListItem mCredSettingsVisibleTest; |
| 76 | private DialogTestListItem mPrintSettingsVisibleTest; |
| 77 | private DialogTestListItem mIntentFiltersTest; |
Sudheer Shanka | 72ba56a | 2015-07-17 18:30:44 +0100 | [diff] [blame] | 78 | private DialogTestListItem mPermissionLockdownTest; |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 79 | private DialogTestListItem mCrossProfileImageCaptureSupportTest; |
| 80 | private DialogTestListItem mCrossProfileVideoCaptureSupportTest; |
| 81 | private DialogTestListItem mCrossProfileAudioCaptureSupportTest; |
Zoltan Szatmary-Ban | 46b5ceb | 2015-07-24 12:28:19 +0100 | [diff] [blame] | 82 | private TestListItem mKeyguardDisabledFeaturesTest; |
Alex Chau | 4c990c3 | 2015-08-14 15:55:18 +0100 | [diff] [blame] | 83 | private DialogTestListItem mDisableNfcBeamTest; |
Daniel Xie | a41d497 | 2015-10-19 15:35:16 -0700 | [diff] [blame] | 84 | private TestListItem mAuthenticationBoundKeyTest; |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 85 | |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 86 | public ByodFlowTestActivity() { |
| 87 | super(R.layout.provisioning_byod, |
| 88 | R.string.provisioning_byod, R.string.provisioning_byod_info, |
| 89 | R.string.provisioning_byod_instructions); |
| 90 | } |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 91 | |
| 92 | @Override |
| 93 | protected void onCreate(Bundle savedInstanceState) { |
| 94 | super.onCreate(savedInstanceState); |
| 95 | mAdminReceiverComponent = new ComponentName(this, DeviceAdminTestReceiver.class.getName()); |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 96 | |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 97 | disableComponent(); |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 98 | mPrepareTestButton.setText(R.string.provisioning_byod_start); |
| 99 | mPrepareTestButton.setOnClickListener(new OnClickListener() { |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 100 | @Override |
| 101 | public void onClick(View v) { |
| 102 | startByodProvisioning(); |
| 103 | } |
| 104 | }); |
| 105 | |
| 106 | // If we are started by managed provisioning (fresh managed provisioning after encryption |
| 107 | // reboot), redirect the user back to the main test list. This is because the test result |
| 108 | // is only saved by the parent TestListActivity, and if we did allow the user to proceed |
| 109 | // here, the test result would be lost when this activity finishes. |
| 110 | if (ByodHelperActivity.ACTION_PROFILE_OWNER_STATUS.equals(getIntent().getAction())) { |
| 111 | startActivity(new Intent(this, TestListActivity.class)); |
| 112 | // Calling super.finish() because we delete managed profile in our overridden of finish(), |
| 113 | // which is not what we want to do here. |
| 114 | super.finish(); |
| 115 | } else { |
| 116 | queryProfileOwner(false); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | @Override |
| 121 | protected void onNewIntent(Intent intent) { |
| 122 | // This is called when managed provisioning completes successfully without reboot. |
| 123 | super.onNewIntent(intent); |
| 124 | if (ByodHelperActivity.ACTION_PROFILE_OWNER_STATUS.equals(intent.getAction())) { |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 125 | handleStatusUpdate(RESULT_OK, intent); |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 126 | } |
| 127 | } |
| 128 | |
| 129 | @Override |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 130 | protected void handleActivityResult(int requestCode, int resultCode, Intent data) { |
| 131 | switch (requestCode) { |
| 132 | case REQUEST_MANAGED_PROVISIONING: |
| 133 | return; |
| 134 | case REQUEST_PROFILE_OWNER_STATUS: { |
| 135 | // Called after queryProfileOwner() |
| 136 | handleStatusUpdate(resultCode, data); |
| 137 | } break; |
| 138 | case REQUEST_INTENT_FILTERS_STATUS: { |
| 139 | // Called after checkIntentFilters() |
| 140 | handleIntentFiltersStatus(resultCode); |
| 141 | } break; |
| 142 | default: { |
| 143 | super.handleActivityResult(requestCode, resultCode, data); |
| 144 | } |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 145 | } |
| 146 | } |
| 147 | |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 148 | private void handleStatusUpdate(int resultCode, Intent data) { |
| 149 | boolean provisioned = data != null && |
| 150 | data.getBooleanExtra(ByodHelperActivity.EXTRA_PROVISIONED, false); |
| 151 | setTestResult(mProfileOwnerInstalled, (provisioned && resultCode == RESULT_OK) ? |
| 152 | TestResult.TEST_RESULT_PASSED : TestResult.TEST_RESULT_FAILED); |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | @Override |
| 156 | public void finish() { |
| 157 | // Pass and fail buttons are known to call finish() when clicked, and this is when we want to |
| 158 | // clean up the provisioned profile. |
| 159 | requestDeleteProfileOwner(); |
| 160 | super.finish(); |
| 161 | } |
| 162 | |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 163 | @Override |
| 164 | protected void setupTests(ArrayTestListAdapter adapter) { |
| 165 | mProfileOwnerInstalled = new DialogTestListItem(this, |
| 166 | R.string.provisioning_byod_profileowner, |
| 167 | "BYOD_ProfileOwnerInstalled") { |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 168 | @Override |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 169 | public void performTest(DialogTestListActivity activity) { |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 170 | queryProfileOwner(true); |
| 171 | } |
| 172 | }; |
| 173 | |
Alexandra Gherghina | 9c1c5a5 | 2014-12-09 12:55:23 +0000 | [diff] [blame] | 174 | /* |
| 175 | * To keep the image in this test up to date, use the instructions in |
| 176 | * {@link ByodIconSamplerActivity}. |
| 177 | */ |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 178 | mWorkAppVisibleTest = new DialogTestListItemWithIcon(this, |
Alexandra Gherghina | 2c672b7 | 2015-01-22 11:20:23 +0000 | [diff] [blame] | 179 | R.string.provisioning_byod_workapps_visible, |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 180 | "BYOD_WorkAppVisibleTest", |
Rubin Xu | c2b00d8 | 2015-02-02 11:30:26 +0000 | [diff] [blame] | 181 | R.string.provisioning_byod_workapps_visible_instruction, |
Alexandra Gherghina | 2c672b7 | 2015-01-22 11:20:23 +0000 | [diff] [blame] | 182 | new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME), |
| 183 | R.drawable.badged_icon); |
| 184 | |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 185 | mWorkNotificationBadgedTest = new DialogTestListItemWithIcon(this, |
Alexandra Gherghina | 2c672b7 | 2015-01-22 11:20:23 +0000 | [diff] [blame] | 186 | R.string.provisioning_byod_work_notification, |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 187 | "BYOD_WorkNotificationBadgedTest", |
Alexandra Gherghina | 2c672b7 | 2015-01-22 11:20:23 +0000 | [diff] [blame] | 188 | R.string.provisioning_byod_work_notification_instruction, |
| 189 | new Intent(WorkNotificationTestActivity.ACTION_WORK_NOTIFICATION), |
| 190 | R.drawable.ic_corp_icon); |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 191 | |
Kenny Guy | 68e7df9 | 2015-05-29 15:26:28 +0100 | [diff] [blame] | 192 | Intent workStatusIcon = new Intent(WorkStatusTestActivity.ACTION_WORK_STATUS_ICON); |
| 193 | workStatusIcon.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 194 | mWorkStatusBarIconTest = new DialogTestListItemWithIcon(this, |
Kenny Guy | 68e7df9 | 2015-05-29 15:26:28 +0100 | [diff] [blame] | 195 | R.string.provisioning_byod_work_status_icon, |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 196 | "BYOD_WorkStatusBarIconTest", |
Kenny Guy | 68e7df9 | 2015-05-29 15:26:28 +0100 | [diff] [blame] | 197 | R.string.provisioning_byod_work_status_icon_instruction, |
| 198 | workStatusIcon, |
| 199 | R.drawable.stat_sys_managed_profile_status); |
| 200 | |
| 201 | Intent workStatusToast = new Intent(WorkStatusTestActivity.ACTION_WORK_STATUS_TOAST); |
| 202 | workStatusToast.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 203 | mWorkStatusBarToastTest = new DialogTestListItem(this, |
Kenny Guy | 68e7df9 | 2015-05-29 15:26:28 +0100 | [diff] [blame] | 204 | R.string.provisioning_byod_work_status_toast, |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 205 | "BYOD_WorkStatusBarToastTest", |
Kenny Guy | 68e7df9 | 2015-05-29 15:26:28 +0100 | [diff] [blame] | 206 | R.string.provisioning_byod_work_status_toast_instruction, |
| 207 | workStatusToast); |
| 208 | |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 209 | mDisableNonMarketTest = new DialogTestListItem(this, |
| 210 | R.string.provisioning_byod_nonmarket_deny, |
| 211 | "BYOD_DisableNonMarketTest", |
Robin Lee | 020f185 | 2015-01-15 11:56:05 +0000 | [diff] [blame] | 212 | R.string.provisioning_byod_nonmarket_deny_info, |
| 213 | new Intent(ByodHelperActivity.ACTION_INSTALL_APK) |
| 214 | .putExtra(ByodHelperActivity.EXTRA_ALLOW_NON_MARKET_APPS, false)); |
| 215 | |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 216 | mEnableNonMarketTest = new DialogTestListItem(this, |
| 217 | R.string.provisioning_byod_nonmarket_allow, |
| 218 | "BYOD_EnableNonMarketTest", |
Robin Lee | 020f185 | 2015-01-15 11:56:05 +0000 | [diff] [blame] | 219 | R.string.provisioning_byod_nonmarket_allow_info, |
| 220 | new Intent(ByodHelperActivity.ACTION_INSTALL_APK) |
| 221 | .putExtra(ByodHelperActivity.EXTRA_ALLOW_NON_MARKET_APPS, true)); |
| 222 | |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 223 | mProfileAccountVisibleTest = new DialogTestListItem(this, |
| 224 | R.string.provisioning_byod_profile_visible, |
| 225 | "BYOD_ProfileAccountVisibleTest", |
Rubin Xu | c2b00d8 | 2015-02-02 11:30:26 +0000 | [diff] [blame] | 226 | R.string.provisioning_byod_profile_visible_instruction, |
| 227 | new Intent(Settings.ACTION_SETTINGS)); |
| 228 | |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 229 | mAppSettingsVisibleTest = new DialogTestListItem(this, |
| 230 | R.string.provisioning_byod_app_settings, |
| 231 | "BYOD_AppSettingsVisibleTest", |
Rubin Xu | c2b00d8 | 2015-02-02 11:30:26 +0000 | [diff] [blame] | 232 | R.string.provisioning_byod_app_settings_instruction, |
| 233 | new Intent(Settings.ACTION_APPLICATION_SETTINGS)); |
| 234 | |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 235 | mDeviceAdminVisibleTest = new DialogTestListItem(this, |
| 236 | R.string.provisioning_byod_admin_visible, |
| 237 | "BYOD_DeviceAdminVisibleTest", |
Rubin Xu | c2b00d8 | 2015-02-02 11:30:26 +0000 | [diff] [blame] | 238 | R.string.provisioning_byod_admin_visible_instruction, |
| 239 | new Intent(Settings.ACTION_SECURITY_SETTINGS)); |
| 240 | |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 241 | mCredSettingsVisibleTest = new DialogTestListItem(this, |
| 242 | R.string.provisioning_byod_cred_settings, |
| 243 | "BYOD_CredSettingsVisibleTest", |
Rubin Xu | c2b00d8 | 2015-02-02 11:30:26 +0000 | [diff] [blame] | 244 | R.string.provisioning_byod_cred_settings_instruction, |
| 245 | new Intent(Settings.ACTION_SECURITY_SETTINGS)); |
| 246 | |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 247 | mLocationSettingsVisibleTest = new DialogTestListItem(this, |
Rubin Xu | c2b00d8 | 2015-02-02 11:30:26 +0000 | [diff] [blame] | 248 | R.string.provisioning_byod_location_settings, |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 249 | "BYOD_LocationSettingsVisibleTest", |
Rubin Xu | c2b00d8 | 2015-02-02 11:30:26 +0000 | [diff] [blame] | 250 | R.string.provisioning_byod_location_settings_instruction, |
| 251 | new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); |
| 252 | |
Michal Karpinski | bb5c533 | 2015-08-12 16:15:31 +0100 | [diff] [blame] | 253 | mBatterySettingsVisibleTest = new DialogTestListItem(this, |
| 254 | R.string.provisioning_byod_battery_settings, |
| 255 | "BYOD_BatterySettingsVisibleTest", |
| 256 | R.string.provisioning_byod_battery_settings_instruction, |
| 257 | new Intent(Intent.ACTION_POWER_USAGE_SUMMARY)); |
| 258 | |
| 259 | mDataUsageSettingsVisibleTest = new DialogTestListItem(this, |
| 260 | R.string.provisioning_byod_data_usage_settings, |
| 261 | "BYOD_DataUsageSettingsVisibleTest", |
| 262 | R.string.provisioning_byod_data_usage_settings_instruction, |
| 263 | new Intent(Settings.ACTION_SETTINGS)); |
| 264 | |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 265 | mPrintSettingsVisibleTest = new DialogTestListItem(this, |
| 266 | R.string.provisioning_byod_print_settings, |
| 267 | "BYOD_PrintSettingsVisibleTest", |
Rubin Xu | c2b00d8 | 2015-02-02 11:30:26 +0000 | [diff] [blame] | 268 | R.string.provisioning_byod_print_settings_instruction, |
| 269 | new Intent(Settings.ACTION_PRINT_SETTINGS)); |
| 270 | |
Daniel Xie | a41d497 | 2015-10-19 15:35:16 -0700 | [diff] [blame] | 271 | Intent intent = new Intent(CrossProfileTestActivity.ACTION_CROSS_PROFILE_TO_WORK); |
| 272 | intent.putExtra(CrossProfileTestActivity.EXTRA_STARTED_FROM_WORK, false); |
Rubin Xu | c2b00d8 | 2015-02-02 11:30:26 +0000 | [diff] [blame] | 273 | Intent chooser = Intent.createChooser(intent, |
| 274 | getResources().getString(R.string.provisioning_cross_profile_chooser)); |
Daniel Xie | a41d497 | 2015-10-19 15:35:16 -0700 | [diff] [blame] | 275 | mCrossProfileIntentFiltersTestFromPersonal = new DialogTestListItem(this, |
| 276 | R.string.provisioning_byod_cross_profile_from_personal, |
| 277 | "BYOD_CrossProfileIntentFiltersTestFromPersonal", |
| 278 | R.string.provisioning_byod_cross_profile_from_personal_instruction, |
Alexandra Gherghina | aa24ed7 | 2014-10-08 01:11:32 +0100 | [diff] [blame] | 279 | chooser); |
| 280 | |
Daniel Xie | a41d497 | 2015-10-19 15:35:16 -0700 | [diff] [blame] | 281 | mCrossProfileIntentFiltersTestFromWork = new DialogTestListItem(this, |
| 282 | R.string.provisioning_byod_cross_profile_from_work, |
| 283 | "BYOD_CrossProfileIntentFiltersTestFromWork", |
| 284 | R.string.provisioning_byod_cross_profile_from_work_instruction, |
| 285 | new Intent(ByodHelperActivity.ACTION_TEST_CROSS_PROFILE_INTENTS_DIALOG)); |
| 286 | |
| 287 | mAppLinkingTest = new DialogTestListItem(this, |
| 288 | R.string.provisioning_app_linking, |
| 289 | "BYOD_AppLinking", |
| 290 | R.string.provisioning_byod_app_linking_instruction, |
| 291 | new Intent(ByodHelperActivity.ACTION_TEST_APP_LINKING_DIALOG)); |
| 292 | |
Zoltan Szatmary-Ban | 46b5ceb | 2015-07-24 12:28:19 +0100 | [diff] [blame] | 293 | mKeyguardDisabledFeaturesTest = TestListItem.newTest(this, |
| 294 | R.string.provisioning_byod_keyguard_disabled_features, |
| 295 | KeyguardDisabledFeaturesActivity.class.getName(), |
| 296 | new Intent(this, KeyguardDisabledFeaturesActivity.class), null); |
| 297 | |
Daniel Xie | a41d497 | 2015-10-19 15:35:16 -0700 | [diff] [blame] | 298 | mAuthenticationBoundKeyTest = TestListItem.newTest(this, |
| 299 | R.string.provisioning_byod_auth_bound_key, |
| 300 | AuthenticationBoundKeyTestActivity.class.getName(), |
| 301 | new Intent(AuthenticationBoundKeyTestActivity.ACTION_AUTH_BOUND_KEY_TEST), |
| 302 | null); |
| 303 | |
Sudheer Shanka | 98ff000 | 2015-03-26 16:32:59 +0000 | [diff] [blame] | 304 | // Test for checking if the required intent filters are set during managed provisioning. |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 305 | mIntentFiltersTest = new DialogTestListItem(this, |
| 306 | R.string.provisioning_byod_cross_profile_intent_filters, |
| 307 | "BYOD_IntentFiltersTest") { |
Sudheer Shanka | 98ff000 | 2015-03-26 16:32:59 +0000 | [diff] [blame] | 308 | @Override |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 309 | public void performTest(DialogTestListActivity activity) { |
Sudheer Shanka | 98ff000 | 2015-03-26 16:32:59 +0000 | [diff] [blame] | 310 | checkIntentFilters(); |
| 311 | } |
| 312 | }; |
Daniel Xie | a41d497 | 2015-10-19 15:35:16 -0700 | [diff] [blame] | 313 | |
Sudheer Shanka | 72ba56a | 2015-07-17 18:30:44 +0100 | [diff] [blame] | 314 | Intent permissionCheckIntent = new Intent( |
| 315 | PermissionLockdownTestActivity.ACTION_MANAGED_PROFILE_CHECK_PERMISSION_LOCKDOWN); |
| 316 | mPermissionLockdownTest = new DialogTestListItem(this, |
| 317 | R.string.device_profile_owner_permission_lockdown_test, |
| 318 | "BYOD_PermissionLockdownTest", |
| 319 | R.string.profile_owner_permission_lockdown_test_info, |
| 320 | permissionCheckIntent); |
Sudheer Shanka | 98ff000 | 2015-03-26 16:32:59 +0000 | [diff] [blame] | 321 | |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 322 | adapter.add(mProfileOwnerInstalled); |
Rubin Xu | c2b00d8 | 2015-02-02 11:30:26 +0000 | [diff] [blame] | 323 | |
| 324 | // Badge related tests |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 325 | adapter.add(mWorkAppVisibleTest); |
| 326 | adapter.add(mWorkNotificationBadgedTest); |
| 327 | adapter.add(mWorkStatusBarIconTest); |
| 328 | adapter.add(mWorkStatusBarToastTest); |
Rubin Xu | c2b00d8 | 2015-02-02 11:30:26 +0000 | [diff] [blame] | 329 | |
| 330 | // Settings related tests. |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 331 | adapter.add(mProfileAccountVisibleTest); |
| 332 | adapter.add(mDeviceAdminVisibleTest); |
| 333 | adapter.add(mCredSettingsVisibleTest); |
| 334 | adapter.add(mAppSettingsVisibleTest); |
| 335 | adapter.add(mLocationSettingsVisibleTest); |
Michal Karpinski | bb5c533 | 2015-08-12 16:15:31 +0100 | [diff] [blame] | 336 | adapter.add(mBatterySettingsVisibleTest); |
| 337 | adapter.add(mDataUsageSettingsVisibleTest); |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 338 | adapter.add(mPrintSettingsVisibleTest); |
Rubin Xu | c2b00d8 | 2015-02-02 11:30:26 +0000 | [diff] [blame] | 339 | |
Daniel Xie | a41d497 | 2015-10-19 15:35:16 -0700 | [diff] [blame] | 340 | adapter.add(mCrossProfileIntentFiltersTestFromPersonal); |
| 341 | adapter.add(mCrossProfileIntentFiltersTestFromWork); |
| 342 | adapter.add(mAppLinkingTest); |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 343 | adapter.add(mDisableNonMarketTest); |
| 344 | adapter.add(mEnableNonMarketTest); |
| 345 | adapter.add(mIntentFiltersTest); |
Sudheer Shanka | 72ba56a | 2015-07-17 18:30:44 +0100 | [diff] [blame] | 346 | adapter.add(mPermissionLockdownTest); |
Zoltan Szatmary-Ban | 46b5ceb | 2015-07-24 12:28:19 +0100 | [diff] [blame] | 347 | adapter.add(mKeyguardDisabledFeaturesTest); |
Daniel Xie | a41d497 | 2015-10-19 15:35:16 -0700 | [diff] [blame] | 348 | adapter.add(mAuthenticationBoundKeyTest); |
Sander Alewijnse | 7e24fda | 2015-03-26 17:41:57 +0000 | [diff] [blame] | 349 | |
Mahaver Chopra | db56817 | 2015-10-15 12:01:35 +0100 | [diff] [blame] | 350 | /* If there is an application that handles ACTION_IMAGE_CAPTURE, test that it handles it |
| 351 | * well. |
| 352 | */ |
Sander Alewijnse | 7e24fda | 2015-03-26 17:41:57 +0000 | [diff] [blame] | 353 | if (canResolveIntent(ByodHelperActivity.getCaptureImageIntent())) { |
| 354 | // Capture image intent can be resolved in primary profile, so test. |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 355 | mCrossProfileImageCaptureSupportTest = new DialogTestListItem(this, |
Sander Alewijnse | 7e24fda | 2015-03-26 17:41:57 +0000 | [diff] [blame] | 356 | R.string.provisioning_byod_capture_image_support, |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 357 | "BYOD_CrossProfileImageCaptureSupportTest", |
Sander Alewijnse | 7e24fda | 2015-03-26 17:41:57 +0000 | [diff] [blame] | 358 | R.string.provisioning_byod_capture_image_support_info, |
| 359 | new Intent(ByodHelperActivity.ACTION_CAPTURE_AND_CHECK_IMAGE)); |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 360 | adapter.add(mCrossProfileImageCaptureSupportTest); |
Sander Alewijnse | 7e24fda | 2015-03-26 17:41:57 +0000 | [diff] [blame] | 361 | } else { |
| 362 | // Capture image intent cannot be resolved in primary profile, so skip test. |
| 363 | Toast.makeText(ByodFlowTestActivity.this, |
| 364 | R.string.provisioning_byod_no_image_capture_resolver, Toast.LENGTH_SHORT) |
| 365 | .show(); |
| 366 | } |
| 367 | |
Mahaver Chopra | db56817 | 2015-10-15 12:01:35 +0100 | [diff] [blame] | 368 | /* If there is an application that handles ACTION_VIDEO_CAPTURE, test that it handles it |
| 369 | * well. |
| 370 | */ |
Sander Alewijnse | 7e24fda | 2015-03-26 17:41:57 +0000 | [diff] [blame] | 371 | if (canResolveIntent(ByodHelperActivity.getCaptureVideoIntent())) { |
| 372 | // Capture video intent can be resolved in primary profile, so test. |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 373 | mCrossProfileVideoCaptureSupportTest = new DialogTestListItem(this, |
Sander Alewijnse | 7e24fda | 2015-03-26 17:41:57 +0000 | [diff] [blame] | 374 | R.string.provisioning_byod_capture_video_support, |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 375 | "BYOD_CrossProfileVideoCaptureSupportTest", |
Sander Alewijnse | 7e24fda | 2015-03-26 17:41:57 +0000 | [diff] [blame] | 376 | R.string.provisioning_byod_capture_video_support_info, |
| 377 | new Intent(ByodHelperActivity.ACTION_CAPTURE_AND_CHECK_VIDEO)); |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 378 | adapter.add(mCrossProfileVideoCaptureSupportTest); |
Sander Alewijnse | 7e24fda | 2015-03-26 17:41:57 +0000 | [diff] [blame] | 379 | } else { |
| 380 | // Capture video intent cannot be resolved in primary profile, so skip test. |
| 381 | Toast.makeText(ByodFlowTestActivity.this, |
| 382 | R.string.provisioning_byod_no_video_capture_resolver, Toast.LENGTH_SHORT) |
| 383 | .show(); |
| 384 | } |
| 385 | |
Alex Chau | c7ef16d | 2015-07-30 18:01:30 +0100 | [diff] [blame] | 386 | if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) { |
Alex Chau | 4c990c3 | 2015-08-14 15:55:18 +0100 | [diff] [blame] | 387 | mDisableNfcBeamTest = new DialogTestListItem(this, R.string.provisioning_byod_nfc_beam, |
| 388 | "BYOD_DisableNfcBeamTest", |
Alex Chau | c7ef16d | 2015-07-30 18:01:30 +0100 | [diff] [blame] | 389 | R.string.provisioning_byod_nfc_beam_allowed_instruction, |
| 390 | new Intent(ByodHelperActivity.ACTION_TEST_NFC_BEAM)) { |
| 391 | @Override |
Alex Chau | 4c990c3 | 2015-08-14 15:55:18 +0100 | [diff] [blame] | 392 | public void performTest(final DialogTestListActivity activity) { |
Alex Chau | c7ef16d | 2015-07-30 18:01:30 +0100 | [diff] [blame] | 393 | activity.showManualTestDialog(mDisableNfcBeamTest, |
| 394 | new DefaultTestCallback(mDisableNfcBeamTest) { |
| 395 | @Override |
| 396 | public void onPass() { |
| 397 | // Start a second test with beam disallowed by policy. |
| 398 | Intent testNfcBeamIntent = new Intent( |
| 399 | ByodHelperActivity.ACTION_TEST_NFC_BEAM); |
| 400 | testNfcBeamIntent.putExtra(NfcTestActivity.EXTRA_DISALLOW_BY_POLICY, |
| 401 | true); |
Alex Chau | 4c990c3 | 2015-08-14 15:55:18 +0100 | [diff] [blame] | 402 | DialogTestListItem disableNfcBeamTest2 = |
| 403 | new DialogTestListItem(activity, |
Alex Chau | c7ef16d | 2015-07-30 18:01:30 +0100 | [diff] [blame] | 404 | R.string.provisioning_byod_nfc_beam, |
Alex Chau | 4c990c3 | 2015-08-14 15:55:18 +0100 | [diff] [blame] | 405 | "BYOD_DisableNfcBeamTest", |
Alex Chau | c7ef16d | 2015-07-30 18:01:30 +0100 | [diff] [blame] | 406 | R.string.provisioning_byod_nfc_beam_disallowed_instruction, |
| 407 | testNfcBeamIntent); |
| 408 | // The result should be reflected on the original test. |
| 409 | activity.showManualTestDialog(disableNfcBeamTest2, |
| 410 | new DefaultTestCallback(mDisableNfcBeamTest)); |
| 411 | } |
| 412 | }); |
| 413 | } |
| 414 | }; |
Alex Chau | 4c990c3 | 2015-08-14 15:55:18 +0100 | [diff] [blame] | 415 | adapter.add(mDisableNfcBeamTest); |
Alex Chau | c7ef16d | 2015-07-30 18:01:30 +0100 | [diff] [blame] | 416 | } |
| 417 | |
Mahaver Chopra | db56817 | 2015-10-15 12:01:35 +0100 | [diff] [blame] | 418 | /* If there is an application that handles RECORD_SOUND_ACTION, test that it handles it |
| 419 | * well. |
| 420 | */ |
Sander Alewijnse | 7e24fda | 2015-03-26 17:41:57 +0000 | [diff] [blame] | 421 | if (canResolveIntent(ByodHelperActivity.getCaptureAudioIntent())) { |
| 422 | // Capture audio intent can be resolved in primary profile, so test. |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 423 | mCrossProfileAudioCaptureSupportTest = new DialogTestListItem(this, |
Sander Alewijnse | 7e24fda | 2015-03-26 17:41:57 +0000 | [diff] [blame] | 424 | R.string.provisioning_byod_capture_audio_support, |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 425 | "BYOD_CrossProfileAudioCaptureSupportTest", |
Sander Alewijnse | 7e24fda | 2015-03-26 17:41:57 +0000 | [diff] [blame] | 426 | R.string.provisioning_byod_capture_audio_support_info, |
| 427 | new Intent(ByodHelperActivity.ACTION_CAPTURE_AND_CHECK_AUDIO)); |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 428 | adapter.add(mCrossProfileAudioCaptureSupportTest); |
Sander Alewijnse | 7e24fda | 2015-03-26 17:41:57 +0000 | [diff] [blame] | 429 | } else { |
| 430 | // Capture audio intent cannot be resolved in primary profile, so skip test. |
| 431 | Toast.makeText(ByodFlowTestActivity.this, |
| 432 | R.string.provisioning_byod_no_audio_capture_resolver, Toast.LENGTH_SHORT) |
| 433 | .show(); |
| 434 | } |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 435 | } |
| 436 | |
Sander Alewijnse | 7e24fda | 2015-03-26 17:41:57 +0000 | [diff] [blame] | 437 | // Return whether the intent can be resolved in the current profile |
| 438 | private boolean canResolveIntent(Intent intent) { |
| 439 | return intent.resolveActivity(getPackageManager()) != null; |
| 440 | } |
| 441 | |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 442 | @Override |
| 443 | protected void clearRemainingState(final DialogTestListItem test) { |
| 444 | super.clearRemainingState(test); |
Alexandra Gherghina | 2c672b7 | 2015-01-22 11:20:23 +0000 | [diff] [blame] | 445 | if (WorkNotificationTestActivity.ACTION_WORK_NOTIFICATION.equals( |
| 446 | test.getManualTestIntent().getAction())) { |
Rubin Xu | c2b00d8 | 2015-02-02 11:30:26 +0000 | [diff] [blame] | 447 | try { |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 448 | startActivity(new Intent( |
Rubin Xu | c2b00d8 | 2015-02-02 11:30:26 +0000 | [diff] [blame] | 449 | WorkNotificationTestActivity.ACTION_CLEAR_WORK_NOTIFICATION)); |
| 450 | } catch (ActivityNotFoundException e) { |
| 451 | // User shouldn't run this test before work profile is set up. |
| 452 | } |
Alexandra Gherghina | 2c672b7 | 2015-01-22 11:20:23 +0000 | [diff] [blame] | 453 | } |
| 454 | } |
| 455 | |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 456 | private void startByodProvisioning() { |
| 457 | Intent sending = new Intent(DevicePolicyManager.ACTION_PROVISION_MANAGED_PROFILE); |
Sudheer Shanka | b64e0dc | 2015-03-23 16:42:35 +0000 | [diff] [blame] | 458 | sending.putExtra(DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME, |
| 459 | mAdminReceiverComponent); |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 460 | |
| 461 | if (sending.resolveActivity(getPackageManager()) != null) { |
| 462 | // ManagedProvisioning must be started with startActivityForResult, but we don't |
| 463 | // care about the result, so passing 0 as a requestCode |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 464 | startActivityForResult(sending, REQUEST_MANAGED_PROVISIONING); |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 465 | } else { |
| 466 | showToast(R.string.provisioning_byod_disabled); |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | private void queryProfileOwner(boolean showToast) { |
| 471 | try { |
| 472 | Intent intent = new Intent(ByodHelperActivity.ACTION_QUERY_PROFILE_OWNER); |
Sudheer Shanka | 98ff000 | 2015-03-26 16:32:59 +0000 | [diff] [blame] | 473 | startActivityForResult(intent, REQUEST_PROFILE_OWNER_STATUS); |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 474 | } |
| 475 | catch (ActivityNotFoundException e) { |
| 476 | Log.d(TAG, "queryProfileOwner: ActivityNotFoundException", e); |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 477 | setTestResult(mProfileOwnerInstalled, TestResult.TEST_RESULT_FAILED); |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 478 | if (showToast) { |
| 479 | showToast(R.string.provisioning_byod_no_activity); |
| 480 | } |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | private void requestDeleteProfileOwner() { |
| 485 | try { |
| 486 | Intent intent = new Intent(ByodHelperActivity.ACTION_REMOVE_PROFILE_OWNER); |
| 487 | startActivity(intent); |
| 488 | showToast(R.string.provisioning_byod_delete_profile); |
| 489 | } |
| 490 | catch (ActivityNotFoundException e) { |
| 491 | Log.d(TAG, "requestDeleteProfileOwner: ActivityNotFoundException", e); |
| 492 | } |
| 493 | } |
| 494 | |
Sudheer Shanka | 98ff000 | 2015-03-26 16:32:59 +0000 | [diff] [blame] | 495 | private void checkIntentFilters() { |
| 496 | try { |
| 497 | // We disable the ByodHelperActivity in the primary profile. So, this intent |
| 498 | // will be handled by the ByodHelperActivity in the managed profile. |
| 499 | Intent intent = new Intent(ByodHelperActivity.ACTION_CHECK_INTENT_FILTERS); |
| 500 | startActivityForResult(intent, REQUEST_INTENT_FILTERS_STATUS); |
| 501 | } catch (ActivityNotFoundException e) { |
| 502 | Log.d(TAG, "checkIntentFilters: ActivityNotFoundException", e); |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 503 | setTestResult(mIntentFiltersTest, TestResult.TEST_RESULT_FAILED); |
Sudheer Shanka | 98ff000 | 2015-03-26 16:32:59 +0000 | [diff] [blame] | 504 | showToast(R.string.provisioning_byod_no_activity); |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | private void handleIntentFiltersStatus(int resultCode) { |
| 509 | // we use the resultCode from ByodHelperActivity in the managed profile to know if certain |
| 510 | // intents fired from the managed profile are forwarded. |
| 511 | final boolean intentFiltersSetForManagedIntents = (resultCode == RESULT_OK); |
| 512 | // Since the ByodFlowTestActivity is running in the primary profile, we directly use |
| 513 | // the IntentFiltersTestHelper to know if certain intents fired from the primary profile |
| 514 | // are forwarded. |
| 515 | final boolean intentFiltersSetForPrimaryIntents = |
| 516 | new IntentFiltersTestHelper(this).checkCrossProfileIntentFilters( |
| 517 | IntentFiltersTestHelper.FLAG_INTENTS_FROM_PRIMARY); |
| 518 | final boolean intentFiltersSet = |
| 519 | intentFiltersSetForPrimaryIntents & intentFiltersSetForManagedIntents; |
| 520 | setTestResult(mIntentFiltersTest, |
Zoltan Szatmary-Ban | 27a2bb5 | 2015-07-23 11:58:49 +0100 | [diff] [blame] | 521 | intentFiltersSet ? TestResult.TEST_RESULT_PASSED : TestResult.TEST_RESULT_FAILED); |
Sudheer Shanka | 98ff000 | 2015-03-26 16:32:59 +0000 | [diff] [blame] | 522 | } |
| 523 | |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 524 | private void disableComponent() { |
| 525 | // Disable app components in the current profile, so only the counterpart in the other profile |
| 526 | // can respond (via cross-profile intent filter) |
Sudheer Shanka | 72ba56a | 2015-07-17 18:30:44 +0100 | [diff] [blame] | 527 | final String[] components = { |
| 528 | ByodHelperActivity.class.getName(), |
| 529 | WorkNotificationTestActivity.class.getName(), |
| 530 | WorkStatusTestActivity.class.getName(), |
Daniel Xie | a41d497 | 2015-10-19 15:35:16 -0700 | [diff] [blame] | 531 | PermissionLockdownTestActivity.ACTIVITY_ALIAS, |
| 532 | AuthenticationBoundKeyTestActivity.class.getName() |
Sudheer Shanka | 72ba56a | 2015-07-17 18:30:44 +0100 | [diff] [blame] | 533 | }; |
| 534 | for (String component : components) { |
| 535 | getPackageManager().setComponentEnabledSetting(new ComponentName(this, component), |
| 536 | PackageManager.COMPONENT_ENABLED_STATE_DISABLED, |
| 537 | PackageManager.DONT_KILL_APP); |
| 538 | } |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 539 | } |
Daniel Xie | a41d497 | 2015-10-19 15:35:16 -0700 | [diff] [blame] | 540 | |
Rubin Xu | 55d22d4 | 2014-09-24 19:56:58 +0100 | [diff] [blame] | 541 | } |