Skip to content

Commit 78bcb1a

Browse files
committed
Release TestDPC 5.0.0 source code
2 parents 38c0839 + ca367ed commit 78bcb1a

File tree

78 files changed

+6794
-573
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+6794
-573
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Test Device Policy Control (Test DPC) App
22
=========================================
33

4-
Test DPC is an app designed to help EMMs, ISVs, and OEMs to test their applications and platforms in a Android enterprise managed profile (i.e. work profile). It serves as both a sample Device Policy Controller and a testing application to flex the APIs available for Android enterprise. It supports devices running Android 5.0 Lollipop or later. As of Mar 24, 2017, it also includes support for devices running API level 26.
4+
Test DPC is an app designed to help EMMs, ISVs, and OEMs to test their applications and platforms in a Android enterprise managed profile (i.e. work profile). It serves as both a sample Device Policy Controller and a testing application to flex the APIs available for Android enterprise. It supports devices running Android 5.0 Lollipop or later.
55

66
See the [documentation](https://developer.android.com/work/index.html) to learn more about Android in the enterprise.
77

app/build.gradle

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@ apply plugin: 'com.android.application'
33
ext {
44
/* Version code for *next* release, bump *after* a release is created. */
55
// 1 or more digits
6-
versionMajor = 4
6+
versionMajor = 5
77
// exactly 1 digit
88
versionMinor = 0
99
// exactly 2 digits
10-
versionBuild = 06
10+
versionBuild = 00
1111
}
1212

1313
android {
14-
compileSdkVersion 27
15-
buildToolsVersion "27.0.1"
14+
compileSdkVersion 'android-P'
1615

1716
defaultConfig {
1817
applicationId "com.afwsamples.testdpc"
1918
minSdkVersion 21
20-
targetSdkVersion 27
19+
targetSdkVersion 28
2120
versionCode versionMajor * 1000 + versionMinor * 100 + versionBuild
2221
versionName "${versionMajor}.${versionMinor}.${versionBuild}"
22+
multiDexEnabled true
2323
}
2424

2525
buildTypes {
@@ -29,6 +29,25 @@ android {
2929
}
3030
}
3131

32+
flavorDimensions "targetSdk", "packageName"
33+
productFlavors {
34+
targetP {
35+
dimension 'targetSdk'
36+
targetSdkVersion 'P'
37+
}
38+
targetO {
39+
dimension 'targetSdk'
40+
targetSdkVersion 27
41+
}
42+
normal {
43+
dimension 'packageName'
44+
}
45+
replica {
46+
dimension 'packageName'
47+
applicationIdSuffix ".replica"
48+
}
49+
}
50+
3251
lintOptions {
3352
check 'NewApi'
3453
abortOnError true
@@ -61,9 +80,14 @@ android {
6180
}
6281

6382
dependencies {
64-
api 'com.android.support:preference-v14:27.0.2'
65-
api 'com.android.support:recyclerview-v7:27.0.2'
66-
api 'com.android.support:support-v13:27.0.2'
67-
api 'com.google.android.gms:play-services-safetynet:+'
68-
api(name:'setup-wizard-lib-platform-release', ext:'aar')
83+
implementation 'com.android.support:multidex:1.0.1'
84+
implementation 'com.android.support:preference-v14:27.0.2'
85+
implementation 'com.android.support:recyclerview-v7:27.0.2'
86+
implementation 'com.android.support:support-v13:27.0.2'
87+
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
88+
implementation 'com.google.android.gms:play-services-safetynet:+'
89+
implementation(name: 'setup-wizard-lib-platform-release', ext: 'aar')
90+
implementation 'org.bouncycastle:bcpkix-jdk15on:1.56'
91+
implementation 'org.bouncycastle:bcprov-jdk15on:1.56'
92+
implementation 'com.google.guava:guava:23.6-android'
6993
}

app/src/main/AndroidManifest.xml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,23 @@
2626
<uses-permission android:name="android.permission.INTERNET" />
2727
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
2828
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
29+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
2930

3031
<application
3132
android:allowBackup="true"
3233
android:icon="@drawable/ic_launcher"
3334
android:theme="@style/AppTheme"
3435
android:label="@string/app_name">
3536

36-
<activity
37-
android:name=".LaunchActivity">
38-
<intent-filter>
39-
<action android:name="android.intent.action.MAIN"/>
40-
<category android:name="android.intent.category.LAUNCHER"/>
41-
</intent-filter>
42-
</activity>
37+
<activity
38+
android:name=".PolicyManagementActivity"
39+
android:label="@string/app_name"
40+
android:windowSoftInputMode="adjustPan">
41+
<intent-filter>
42+
<action android:name="android.intent.action.MAIN"/>
43+
<category android:name="android.intent.category.LAUNCHER"/>
44+
</intent-filter>
45+
</activity>
4346

4447
<activity
4548
android:name=".SetupManagementActivity"
@@ -57,11 +60,6 @@
5760
</intent-filter>
5861
</activity-alias>
5962

60-
<activity
61-
android:name=".PolicyManagementActivity"
62-
android:label="@string/app_name"
63-
android:windowSoftInputMode="adjustPan"/>
64-
6563
<activity
6664
android:name=".AddAccountActivity"
6765
android:label="@string/app_name"
@@ -86,7 +84,6 @@
8684
android:name=".policy.locktask.KioskModeActivity"
8785
android:label="@string/kiosk_mode"
8886
android:launchMode="singleInstance"
89-
android:lockTaskMode="if_whitelisted"
9087
android:enabled="false">
9188
<intent-filter>
9289
<action android:name="android.intent.action.MAIN"/>
@@ -112,10 +109,15 @@
112109
<meta-data
113110
android:name="android.app.device_admin"
114111
android:resource="@xml/device_admin_receiver"/>
112+
<meta-data
113+
android:name="android.app.support_transfer_ownership"
114+
android:value="true"/>
115115
<intent-filter>
116116
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED"/>
117117
<action android:name="android.app.action.PROFILE_PROVISIONING_COMPLETE"/>
118118
<action android:name="android.intent.action.BOOT_COMPLETED"/>
119+
<action android:name="android.app.action.PROFILE_OWNER_CHANGED"/>
120+
<action android:name="android.app.action.DEVICE_OWNER_CHANGED"/>
119121
</intent-filter>
120122
</receiver>
121123

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package com.afwsamples.testdpc;
2+
3+
import android.annotation.TargetApi;
4+
import android.app.Fragment;
5+
import android.content.ComponentName;
6+
import android.content.pm.CrossProfileApps;
7+
import android.os.Bundle;
8+
import android.os.UserHandle;
9+
import android.view.LayoutInflater;
10+
import android.view.View;
11+
import android.view.ViewGroup;
12+
import android.widget.ImageView;
13+
import android.widget.TextView;
14+
import java.util.List;
15+
16+
// TODO: Replace it with P.
17+
@TargetApi(28)
18+
public class CrossProfileAppsFragment extends Fragment {
19+
private static final String TAG = "CrossProfileAppsFragmen";
20+
21+
private View mInflatedView;
22+
private TextView mSwitchProfileTextView;
23+
private TextView mDescriptionTextView;
24+
private ImageView mSwitchProfileImageView;
25+
private CrossProfileApps mCrossProfileApps;
26+
27+
@Override
28+
public View onCreateView(LayoutInflater inflater, ViewGroup container,
29+
Bundle savedInstanceState) {
30+
mInflatedView = inflater.inflate(R.layout.cross_profile_apps, container, false);
31+
mSwitchProfileTextView = mInflatedView.findViewById(R.id.cross_profile_app_label);
32+
mSwitchProfileImageView = mInflatedView.findViewById(R.id.cross_profile_app_icon);
33+
mDescriptionTextView = mInflatedView.findViewById(R.id.cross_profile_app_description);
34+
return mInflatedView;
35+
}
36+
37+
@Override
38+
public void onActivityCreated(Bundle savedInstanceState) {
39+
super.onActivityCreated(savedInstanceState);
40+
mCrossProfileApps = getActivity().getSystemService(CrossProfileApps.class);
41+
}
42+
43+
@Override
44+
public void onResume() {
45+
super.onResume();
46+
refreshUi();
47+
}
48+
49+
private void refreshUi() {
50+
List<UserHandle> targetUserProfiles = mCrossProfileApps.getTargetUserProfiles();
51+
if (targetUserProfiles.isEmpty()) {
52+
showNoTargetUserUi();
53+
} else {
54+
showHasTargetUserUi(targetUserProfiles.get(0));
55+
}
56+
}
57+
58+
private void showNoTargetUserUi() {
59+
mDescriptionTextView.setText(R.string.cross_profile_apps_not_available);
60+
mSwitchProfileTextView.setText("");
61+
mSwitchProfileImageView.setImageDrawable(null);
62+
mSwitchProfileImageView.setOnClickListener(null);
63+
}
64+
65+
private void showHasTargetUserUi(UserHandle userHandle) {
66+
mSwitchProfileTextView.setText(mCrossProfileApps.getProfileSwitchingLabel(userHandle));
67+
mSwitchProfileImageView.setImageDrawable(
68+
mCrossProfileApps.getProfileSwitchingIconDrawable(userHandle));
69+
mDescriptionTextView.setText(R.string.cross_profile_apps_available);
70+
mSwitchProfileImageView.setOnClickListener(
71+
view ->
72+
mCrossProfileApps.startMainActivity(
73+
new ComponentName(getActivity(), PolicyManagementActivity.class), userHandle));
74+
}
75+
}

0 commit comments

Comments
 (0)