Loading core/res/res/values/attrs_manifest.xml +8 −8 Original line number Original line Diff line number Diff line Loading @@ -1070,29 +1070,29 @@ is launched that task will or will not start depending on whether the package of this is launched that task will or will not start depending on whether the package of this activity has been whitelisted. activity has been whitelisted. <p>Tasks rooted at this activity can only exit lockTask mode using stopLockTask(). --> <p>Tasks rooted at this activity can only exit lockTask mode using stopLockTask(). --> <enum name="lockTaskModeDefault" value="0"/> <enum name="normal" value="0"/> <!-- Tasks will not launch into lockTask mode and cannot be placed there using <!-- Tasks will not launch into lockTask mode and cannot be placed there using {@link android.app.Activity#startLockTask} or be pinned from the Overview screen. {@link android.app.Activity#startLockTask} or be pinned from the Overview screen. If the system is already in lockTask mode when a new task rooted at this activity is If the system is already in lockTask mode when a new task rooted at this activity is launched that task will not be started. launched that task will not be started. <p>Note: This mode is only available to system and privileged applications. <p>Note: This mode is only available to system and privileged applications. Non-privileged apps with this value will be treated as lockTaskModeDefault. Non-privileged apps with this value will be treated as normal. --> --> <enum name="lockTaskModeNever" value="1"/> <enum name="never" value="1"/> <!-- Tasks rooted at this activity will always launch into lockTask mode. If the system is <!-- Tasks rooted at this activity will always launch into lockTask mode. If the system is already in lockTask mode when this task is launched then the new task will be launched already in lockTask mode when this task is launched then the new task will be launched on top of the current task. Tasks launched in this mode are capable of exiting on top of the current task. Tasks launched in this mode are capable of exiting lockTask mode using finish(), whereas tasks entering lockTask mode using lockTask mode using finish(), whereas tasks entering lockTask mode using startLockTask() must use stopLockTask() to exit. startLockTask() must use stopLockTask() to exit. <p>Note: This mode is only available to system and privileged applications. <p>Note: This mode is only available to system and privileged applications. Non-privileged apps with this value will be treated as lockTaskModeDefault. Non-privileged apps with this value will be treated as normal. --> --> <enum name="lockTaskModeAlways" value="2"/> <enum name="always" value="2"/> <!-- If the DevicePolicyManager (DPM) authorizes this package ({@link <!-- If the DevicePolicyManager (DPM) authorizes this package ({@link android.app.admin.DevicePolicyManager#setLockTaskPackages}) then this mode is android.app.admin.DevicePolicyManager#setLockTaskPackages}) then this mode is identical to lockTaskModeAlways. If the DPM does not authorize this package then this identical to always. If the DPM does not authorize this package then this mode is identical to lockTaskModeDefault. --> mode is identical to normal. --> <enum name="lockTaskModeIfWhitelisted" value="3"/> <enum name="if_whitelisted" value="3"/> </attr> </attr> <!-- When set installer will extract native libraries. If set to false <!-- When set installer will extract native libraries. If set to false libraries in the apk must be stored and page-aligned. --> libraries in the apk must be stored and page-aligned. --> Loading tests/LockTaskTests/AndroidManifest.xml +4 −4 Original line number Original line Diff line number Diff line Loading @@ -29,28 +29,28 @@ android:label="@string/title_activity_default" android:label="@string/title_activity_default" android:taskAffinity="" android:taskAffinity="" android:documentLaunchMode="always" android:documentLaunchMode="always" android:lockTaskMode="lockTaskModeDefault" > android:lockTaskMode="normal" > </activity> </activity> <activity <activity android:name="com.google.android.example.locktasktests.LockTaskNeverActivity" android:name="com.google.android.example.locktasktests.LockTaskNeverActivity" android:label="@string/title_activity_never" android:label="@string/title_activity_never" android:taskAffinity="" android:taskAffinity="" android:documentLaunchMode="always" android:documentLaunchMode="always" android:lockTaskMode="lockTaskModeNever" > android:lockTaskMode="never" > </activity> </activity> <activity <activity android:name="com.google.android.example.locktasktests.LockWhitelistedActivity" android:name="com.google.android.example.locktasktests.LockWhitelistedActivity" android:label="@string/title_activity_whitelist" android:label="@string/title_activity_whitelist" android:taskAffinity="" android:taskAffinity="" android:documentLaunchMode="always" android:documentLaunchMode="always" android:lockTaskMode="lockTaskModeIfWhitelisted" > android:lockTaskMode="if_whitelisted" > </activity> </activity> <activity <activity android:name="com.google.android.example.locktasktests.LockAtLaunchActivity" android:name="com.google.android.example.locktasktests.LockAtLaunchActivity" android:label="@string/title_activity_always" android:label="@string/title_activity_always" android:taskAffinity="" android:taskAffinity="" android:documentLaunchMode="always" android:documentLaunchMode="always" android:lockTaskMode="lockTaskModeAlways" > android:lockTaskMode="always" > </activity> </activity> </application> </application> Loading tests/LockTaskTests/res/values/strings.xml +5 −4 Original line number Original line Diff line number Diff line Loading @@ -7,16 +7,17 @@ <string name="title_activity_whitelist">LockWhitelistedActivity</string> <string name="title_activity_whitelist">LockWhitelistedActivity</string> <string name="title_activity_always">LockAtLaunchActivity</string> <string name="title_activity_always">LockAtLaunchActivity</string> <string name="launch_default">android:lockTaskMode=\n <string name="launch_default">android:lockTaskMode=\n \"lockTaskModeDefault\"\n \"default\"\n Pinnable from Overview.</string> Pinnable from Overview.</string> <string name="launch_never">android:lockTaskMode=\n <string name="launch_never">android:lockTaskMode=\n \"lockTaskModeNever\"\n \"never\"\n Not Lockable or Pinnable.</string> Not Lockable or Pinnable.</string> <string name="launch_whitelist">android:lockTaskMode=\n\"lockTaskModeIfWhitelisted\"\n <string name="launch_whitelist">android:lockTaskMode=\n \"if_whitelisted\"\n Lockable if whitelisted, Pinnable.\n Lockable if whitelisted, Pinnable.\n Use SampleDeviceOwner app to set whitelist.</string> Use SampleDeviceOwner app to set whitelist.</string> <string name="launch_always">android:lockTaskMode=\n <string name="launch_always">android:lockTaskMode=\n \"lockTaskModeAlways\"\n \"always\"\n Launches into lock mode.</string> Launches into lock mode.</string> <string name="launch_main">launch MainActivity (as activity)"</string> <string name="launch_main">launch MainActivity (as activity)"</string> <string name="try_lock">Call startLockMode()</string> <string name="try_lock">Call startLockMode()</string> Loading tests/LockTaskTests/src/com/google/android/example/locktasktests/MainActivity.java +29 −5 Original line number Original line Diff line number Diff line Loading @@ -6,26 +6,50 @@ import android.app.ActivityManager; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.os.Bundle; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.view.View; import android.view.View; public class MainActivity extends Activity { public class MainActivity extends Activity { private final static String TAG = "LockTaskTests"; private final static String TAG = "LockTaskTests"; Runnable mBackgroundPolling; boolean mRunning; Handler mHandler; @Override @Override protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setContentView(R.layout.activity_main); } mBackgroundPolling = new Runnable() { // Poll lock task state and set background pink if locked, otherwise white. @Override @Override public void onResume() { public void run() { super.onResume(); if (!mRunning) { return; } ActivityManager activityManager = ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); final int color = activityManager.getLockTaskModeState() != final int color = activityManager.getLockTaskModeState() != ActivityManager.LOCK_TASK_MODE_NONE ? 0xFFFFC0C0 : 0xFFFFFFFF; ActivityManager.LOCK_TASK_MODE_NONE ? 0xFFFFC0C0 : 0xFFFFFFFF; findViewById(R.id.root_launch).setBackgroundColor(color); findViewById(R.id.root_launch).setBackgroundColor(color); mHandler.postDelayed(this, 500); } }; mHandler = new Handler(Looper.getMainLooper()); } @Override public void onResume() { super.onResume(); mRunning = true; mBackgroundPolling.run(); } @Override public void onPause() { super.onPause(); mRunning = false; } } public void onButtonPressed(View v) { public void onButtonPressed(View v) { Loading Loading
core/res/res/values/attrs_manifest.xml +8 −8 Original line number Original line Diff line number Diff line Loading @@ -1070,29 +1070,29 @@ is launched that task will or will not start depending on whether the package of this is launched that task will or will not start depending on whether the package of this activity has been whitelisted. activity has been whitelisted. <p>Tasks rooted at this activity can only exit lockTask mode using stopLockTask(). --> <p>Tasks rooted at this activity can only exit lockTask mode using stopLockTask(). --> <enum name="lockTaskModeDefault" value="0"/> <enum name="normal" value="0"/> <!-- Tasks will not launch into lockTask mode and cannot be placed there using <!-- Tasks will not launch into lockTask mode and cannot be placed there using {@link android.app.Activity#startLockTask} or be pinned from the Overview screen. {@link android.app.Activity#startLockTask} or be pinned from the Overview screen. If the system is already in lockTask mode when a new task rooted at this activity is If the system is already in lockTask mode when a new task rooted at this activity is launched that task will not be started. launched that task will not be started. <p>Note: This mode is only available to system and privileged applications. <p>Note: This mode is only available to system and privileged applications. Non-privileged apps with this value will be treated as lockTaskModeDefault. Non-privileged apps with this value will be treated as normal. --> --> <enum name="lockTaskModeNever" value="1"/> <enum name="never" value="1"/> <!-- Tasks rooted at this activity will always launch into lockTask mode. If the system is <!-- Tasks rooted at this activity will always launch into lockTask mode. If the system is already in lockTask mode when this task is launched then the new task will be launched already in lockTask mode when this task is launched then the new task will be launched on top of the current task. Tasks launched in this mode are capable of exiting on top of the current task. Tasks launched in this mode are capable of exiting lockTask mode using finish(), whereas tasks entering lockTask mode using lockTask mode using finish(), whereas tasks entering lockTask mode using startLockTask() must use stopLockTask() to exit. startLockTask() must use stopLockTask() to exit. <p>Note: This mode is only available to system and privileged applications. <p>Note: This mode is only available to system and privileged applications. Non-privileged apps with this value will be treated as lockTaskModeDefault. Non-privileged apps with this value will be treated as normal. --> --> <enum name="lockTaskModeAlways" value="2"/> <enum name="always" value="2"/> <!-- If the DevicePolicyManager (DPM) authorizes this package ({@link <!-- If the DevicePolicyManager (DPM) authorizes this package ({@link android.app.admin.DevicePolicyManager#setLockTaskPackages}) then this mode is android.app.admin.DevicePolicyManager#setLockTaskPackages}) then this mode is identical to lockTaskModeAlways. If the DPM does not authorize this package then this identical to always. If the DPM does not authorize this package then this mode is identical to lockTaskModeDefault. --> mode is identical to normal. --> <enum name="lockTaskModeIfWhitelisted" value="3"/> <enum name="if_whitelisted" value="3"/> </attr> </attr> <!-- When set installer will extract native libraries. If set to false <!-- When set installer will extract native libraries. If set to false libraries in the apk must be stored and page-aligned. --> libraries in the apk must be stored and page-aligned. --> Loading
tests/LockTaskTests/AndroidManifest.xml +4 −4 Original line number Original line Diff line number Diff line Loading @@ -29,28 +29,28 @@ android:label="@string/title_activity_default" android:label="@string/title_activity_default" android:taskAffinity="" android:taskAffinity="" android:documentLaunchMode="always" android:documentLaunchMode="always" android:lockTaskMode="lockTaskModeDefault" > android:lockTaskMode="normal" > </activity> </activity> <activity <activity android:name="com.google.android.example.locktasktests.LockTaskNeverActivity" android:name="com.google.android.example.locktasktests.LockTaskNeverActivity" android:label="@string/title_activity_never" android:label="@string/title_activity_never" android:taskAffinity="" android:taskAffinity="" android:documentLaunchMode="always" android:documentLaunchMode="always" android:lockTaskMode="lockTaskModeNever" > android:lockTaskMode="never" > </activity> </activity> <activity <activity android:name="com.google.android.example.locktasktests.LockWhitelistedActivity" android:name="com.google.android.example.locktasktests.LockWhitelistedActivity" android:label="@string/title_activity_whitelist" android:label="@string/title_activity_whitelist" android:taskAffinity="" android:taskAffinity="" android:documentLaunchMode="always" android:documentLaunchMode="always" android:lockTaskMode="lockTaskModeIfWhitelisted" > android:lockTaskMode="if_whitelisted" > </activity> </activity> <activity <activity android:name="com.google.android.example.locktasktests.LockAtLaunchActivity" android:name="com.google.android.example.locktasktests.LockAtLaunchActivity" android:label="@string/title_activity_always" android:label="@string/title_activity_always" android:taskAffinity="" android:taskAffinity="" android:documentLaunchMode="always" android:documentLaunchMode="always" android:lockTaskMode="lockTaskModeAlways" > android:lockTaskMode="always" > </activity> </activity> </application> </application> Loading
tests/LockTaskTests/res/values/strings.xml +5 −4 Original line number Original line Diff line number Diff line Loading @@ -7,16 +7,17 @@ <string name="title_activity_whitelist">LockWhitelistedActivity</string> <string name="title_activity_whitelist">LockWhitelistedActivity</string> <string name="title_activity_always">LockAtLaunchActivity</string> <string name="title_activity_always">LockAtLaunchActivity</string> <string name="launch_default">android:lockTaskMode=\n <string name="launch_default">android:lockTaskMode=\n \"lockTaskModeDefault\"\n \"default\"\n Pinnable from Overview.</string> Pinnable from Overview.</string> <string name="launch_never">android:lockTaskMode=\n <string name="launch_never">android:lockTaskMode=\n \"lockTaskModeNever\"\n \"never\"\n Not Lockable or Pinnable.</string> Not Lockable or Pinnable.</string> <string name="launch_whitelist">android:lockTaskMode=\n\"lockTaskModeIfWhitelisted\"\n <string name="launch_whitelist">android:lockTaskMode=\n \"if_whitelisted\"\n Lockable if whitelisted, Pinnable.\n Lockable if whitelisted, Pinnable.\n Use SampleDeviceOwner app to set whitelist.</string> Use SampleDeviceOwner app to set whitelist.</string> <string name="launch_always">android:lockTaskMode=\n <string name="launch_always">android:lockTaskMode=\n \"lockTaskModeAlways\"\n \"always\"\n Launches into lock mode.</string> Launches into lock mode.</string> <string name="launch_main">launch MainActivity (as activity)"</string> <string name="launch_main">launch MainActivity (as activity)"</string> <string name="try_lock">Call startLockMode()</string> <string name="try_lock">Call startLockMode()</string> Loading
tests/LockTaskTests/src/com/google/android/example/locktasktests/MainActivity.java +29 −5 Original line number Original line Diff line number Diff line Loading @@ -6,26 +6,50 @@ import android.app.ActivityManager; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.os.Bundle; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.view.View; import android.view.View; public class MainActivity extends Activity { public class MainActivity extends Activity { private final static String TAG = "LockTaskTests"; private final static String TAG = "LockTaskTests"; Runnable mBackgroundPolling; boolean mRunning; Handler mHandler; @Override @Override protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setContentView(R.layout.activity_main); } mBackgroundPolling = new Runnable() { // Poll lock task state and set background pink if locked, otherwise white. @Override @Override public void onResume() { public void run() { super.onResume(); if (!mRunning) { return; } ActivityManager activityManager = ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); final int color = activityManager.getLockTaskModeState() != final int color = activityManager.getLockTaskModeState() != ActivityManager.LOCK_TASK_MODE_NONE ? 0xFFFFC0C0 : 0xFFFFFFFF; ActivityManager.LOCK_TASK_MODE_NONE ? 0xFFFFC0C0 : 0xFFFFFFFF; findViewById(R.id.root_launch).setBackgroundColor(color); findViewById(R.id.root_launch).setBackgroundColor(color); mHandler.postDelayed(this, 500); } }; mHandler = new Handler(Looper.getMainLooper()); } @Override public void onResume() { super.onResume(); mRunning = true; mBackgroundPolling.run(); } @Override public void onPause() { super.onPause(); mRunning = false; } } public void onButtonPressed(View v) { public void onButtonPressed(View v) { Loading