Skip to content

Commit 3766ffb

Browse files
Yueming WangAndroid (Google) Code Review
authored andcommitted
Merge "Remove COMP option and send added account info to managed profile TestDPC." into ub-testdpc-qt
2 parents 919feb4 + 15c0b85 commit 3766ffb

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

app/src/main/java/com/afwsamples/testdpc/FinalizeActivity.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
package com.afwsamples.testdpc;
1818

19+
import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE;
20+
import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME;
21+
1922
import android.accounts.Account;
2023
import android.accounts.AccountManager;
2124
import android.app.Activity;
@@ -67,7 +70,7 @@ protected void onCreate(Bundle savedInstanceState) {
6770
}
6871

6972
// Show the user which account now has management, if specified.
70-
String addedAccount = getIntent().getStringExtra(LaunchIntentUtil.EXTRA_ACCOUNT_NAME);
73+
final String addedAccount = getAddedAccountName();
7174
if (addedAccount != null) {
7275
View accountMigrationStatusLayout;
7376
if (isAccountMigrated(addedAccount)) {
@@ -86,6 +89,17 @@ protected void onCreate(Bundle savedInstanceState) {
8689
: R.string.all_done_explanation_profile_owner);
8790
}
8891

92+
private String getAddedAccountName() {
93+
String addedAccount = getIntent().getStringExtra(LaunchIntentUtil.EXTRA_ACCOUNT_NAME);
94+
// Added account infomation may be contained in EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE
95+
// if FinalizeActivity is started from ACTION_ADMIN_POLICY_COMPLIANCE.
96+
if (addedAccount == null) {
97+
addedAccount = LaunchIntentUtil.getAddedAccountName(
98+
getIntent().getParcelableExtra(EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE));
99+
}
100+
return addedAccount;
101+
}
102+
89103
private boolean isAccountMigrated(String addedAccount) {
90104
Account[] accounts = AccountManager.get(this).getAccounts();
91105
for (Account account : accounts) {

app/src/main/java/com/afwsamples/testdpc/provision/DpcLoginActivity.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,19 @@
1717
package com.afwsamples.testdpc.provision;
1818

1919
import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE;
20+
import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE;
2021

2122
import android.accounts.Account;
2223
import android.app.Activity;
2324
import android.content.Intent;
2425
import android.os.Bundle;
26+
import android.os.PersistableBundle;
2527
import android.util.Log;
2628
import android.view.View;
2729
import android.widget.RadioGroup;
2830
import com.afwsamples.testdpc.AddAccountActivity;
2931
import com.afwsamples.testdpc.R;
32+
import com.afwsamples.testdpc.common.LaunchIntentUtil;
3033
import com.android.setupwizardlib.GlifLayout;
3134

3235
/**
@@ -78,6 +81,9 @@ private Intent createResultIntentFromData(Intent data) {
7881
final Account accountToMigrate = data.getParcelableExtra(
7982
EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE);
8083
resultIntent.putExtra(EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE, accountToMigrate);
84+
final PersistableBundle bundle = new PersistableBundle();
85+
bundle.putString(LaunchIntentUtil.EXTRA_ACCOUNT_NAME, accountToMigrate.name);
86+
resultIntent.putExtra(EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE, bundle);
8187
}
8288
return resultIntent;
8389
}
@@ -95,11 +101,6 @@ private void onNavigateNext(View nextButton) {
95101
new Intent(getApplicationContext(), AddAccountActivity.class),
96102
ADD_ACCOUNT_REQUEST_CODE);
97103
return;
98-
case R.id.dpc_login_comp:
99-
intent.putExtra(EXTRA_PROVISIONING_MODE,
100-
PROVISIONING_MODE_MANAGED_PROFILE_ON_FULLY_MANAGED_DEVICE);
101-
finishWithIntent(intent);
102-
return;
103104
default:
104105
finish();
105106
}

app/src/main/res/layout/activity_dpc_login.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@
5555
android:layout_width="wrap_content"
5656
android:layout_height="wrap_content"
5757
android:text="@string/dpc_login_po" />
58-
59-
<RadioButton
60-
android:id="@+id/dpc_login_comp"
61-
android:layout_width="match_parent"
62-
android:layout_height="wrap_content"
63-
android:text="@string/dpc_login_comp" />
6458
</RadioGroup>
6559
</LinearLayout>
6660

0 commit comments

Comments
 (0)