Skip to content

Commit 7383502

Browse files
committed
Update testdpc with API change in ActivityOptions.setLockTaskEnabled
According to API review, we changed the API name to ActivityOptions.setLockTaskEnabled. Because of uncertain prebuilt drops and the developer preview, we should temporarily accept both versions. Bug: 71866618 Test: manual Change-Id: I91fd04291ed1788e4d15a2674c7d009d69609e03
1 parent 69b3255 commit 7383502

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

app/src/main/java/com/afwsamples/testdpc/policy/PolicyManagementFragment.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3154,7 +3154,25 @@ private void relaunchInLockTaskMode() {
31543154
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
31553155

31563156
final ActivityOptions options = ActivityOptions.makeBasic();
3157-
options.setLockTaskMode(true);
3157+
try {
3158+
ReflectionUtil.invoke(
3159+
options,
3160+
"setLockTaskMode",
3161+
new Class[]{boolean.class},
3162+
true);
3163+
} catch (ReflectionUtil.ReflectionIsTemporaryException e1) {
3164+
// API name was recently changed, so we should be robust enough to support both.
3165+
// This workaround can be removed once the new API name is in the SDK prebuilt.
3166+
try {
3167+
ReflectionUtil.invoke(
3168+
options,
3169+
"setLockTaskEnabled",
3170+
new Class[]{boolean.class},
3171+
true);
3172+
} catch (ReflectionUtil.ReflectionIsTemporaryException e2) {
3173+
Log.e(TAG, "Unable to set lock task activity option.", e2);
3174+
}
3175+
}
31583176

31593177
try {
31603178
startActivity(intent, options.toBundle());

0 commit comments

Comments
 (0)