Skip to content

Commit eea444f

Browse files
gvictorAndroid (Google) Code Review
authored andcommitted
Merge "Api change of DPM.setApplicationRestrictionsManagingPackage() throws NameNotFound Exception" into ub-testdpc-nyc
2 parents 226cbce + 2104437 commit eea444f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

app/src/main/java/com/afwsamples/testdpc/profilepolicy/apprestrictions/AppRestrictionsManagingPackageFragment.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import com.afwsamples.testdpc.R;
2525
import com.afwsamples.testdpc.common.SelectAppFragment;
2626

27+
import java.lang.IllegalArgumentException;
28+
2729
/**
2830
* This fragment lets the user select an app that can manage application restrictions for the
2931
* current user. Related APIs:
@@ -49,14 +51,19 @@ public void onResume() {
4951

5052
@Override
5153
protected void setSelectedPackage(String pkgName) {
52-
mDpm.setApplicationRestrictionsManagingPackage(
53-
DeviceAdminReceiver.getComponentName(getActivity()), pkgName);
54+
try {
55+
mDpm.setApplicationRestrictionsManagingPackage(
56+
DeviceAdminReceiver.getComponentName(getActivity()), pkgName);
57+
// TODO: Catch NameNotFoundException instead when NYC SDK
58+
// setApplicationRestrictionsManagingPackage starts to throw NameNotFoundException
59+
} catch (Exception nnpe) {
60+
throw new IllegalArgumentException(nnpe);
61+
}
5462
}
5563

5664
@Override
5765
protected void clearSelectedPackage() {
58-
mDpm.setApplicationRestrictionsManagingPackage(
59-
DeviceAdminReceiver.getComponentName(getActivity()), null);
66+
setSelectedPackage(null);
6067
}
6168

6269
@Override

0 commit comments

Comments
 (0)