Loading core/res/AndroidManifest.xml +2 −0 Original line number Diff line number Diff line Loading @@ -481,6 +481,8 @@ <protected-broadcast android:name="android.intent.action.MANAGED_PROFILE_AVAILABLE" /> <protected-broadcast android:name="android.intent.action.MANAGED_PROFILE_UNAVAILABLE" /> <protected-broadcast android:name="com.android.server.am.ACTION_RESET_DEMO" /> <!-- ====================================================================== --> <!-- RUNTIME PERMISSIONS --> <!-- ====================================================================== --> Loading core/res/res/values/strings.xml +5 −0 Original line number Diff line number Diff line Loading @@ -4362,6 +4362,11 @@ <!-- The representation of a time duration when negative. An example is -1:14. This can be used with a countdown timer for example.--> <string name="negative_duration">\u2212<xliff:g id="time" example="1:14">%1$s</xliff:g></string> <!-- Title of notification to start a new demo session when device is in retail mode [CHAR LIMIT=NONE] --> <string name="reset_retail_demo_mode_title">Restart Session</string> <!-- Text of notification to start a new demo session when device is in retail mode [CHAR LIMIT=NONE] --> <string name="reset_retail_demo_mode_text">Tap to start a new demo session</string> <!-- Title of notification shown when device has been forced to safe mode after a security compromise. --> <string name="audit_safemode_notification">Factory reset to use this device without restrictions</string> <!-- Description of notification shown when device has been forced to safe mode after a security compromise. --> Loading core/res/res/values/symbols.xml +2 −0 Original line number Diff line number Diff line Loading @@ -1888,6 +1888,8 @@ <java-symbol type="string" name="config_persistentDataPackageName" /> <java-symbol type="string" name="audit_safemode_notification" /> <java-symbol type="string" name="audit_safemode_notification_details" /> <java-symbol type="string" name="reset_retail_demo_mode_title" /> <java-symbol type="string" name="reset_retail_demo_mode_text" /> <java-symbol type="layout" name="resolver_list" /> <java-symbol type="id" name="resolver_list" /> Loading services/core/java/com/android/server/am/RetailDemoModeService.java +35 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,9 @@ package com.android.server.am; import android.app.ActivityManagerNative; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.Context; Loading @@ -36,6 +39,7 @@ import android.provider.Settings; import android.util.Slog; import com.android.internal.os.BackgroundThread; import com.android.internal.R; import com.android.server.ServiceThread; import com.android.server.SystemService; import com.android.server.pm.UserManagerService; Loading @@ -47,15 +51,18 @@ public class RetailDemoModeService extends SystemService { private static final String TAG = RetailDemoModeService.class.getSimpleName(); private static final String DEMO_USER_NAME = "Demo"; private static final String ACTION_RESET_DEMO = "com.android.server.am.ACTION_RESET_DEMO"; private static final long SCREEN_WAKEUP_DELAY = 5000; private ActivityManagerService mAms; private UserManagerService mUms; private NotificationManager mNm; private PowerManager mPm; private PowerManager.WakeLock mWakeLock; private Handler mHandler; private ServiceThread mHandlerThread; private PendingIntent mResetDemoPendingIntent; private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { @Override Loading @@ -75,6 +82,9 @@ public class RetailDemoModeService extends SystemService { } }, SCREEN_WAKEUP_DELAY); break; case ACTION_RESET_DEMO: createAndSwitchToDemoUser(); break; } } }; Loading @@ -83,6 +93,26 @@ public class RetailDemoModeService extends SystemService { super(context); } private Notification createResetNotification() { return new Notification.Builder(getContext()) .setContentTitle(getContext().getString(R.string.reset_retail_demo_mode_title)) .setContentText(getContext().getString(R.string.reset_retail_demo_mode_text)) .setOngoing(true) .setSmallIcon(R.drawable.platlogo) .setShowWhen(false) .setVisibility(Notification.VISIBILITY_PUBLIC) .setContentIntent(getResetDemoPendingIntent()) .build(); } private PendingIntent getResetDemoPendingIntent() { if (mResetDemoPendingIntent == null) { Intent intent = new Intent(ACTION_RESET_DEMO); mResetDemoPendingIntent = PendingIntent.getBroadcast(getContext(), 0, intent, 0); } return mResetDemoPendingIntent; } private void createAndSwitchToDemoUser() { if (DEBUG) { Slog.d(TAG, "Switching to a new demo user"); Loading Loading @@ -162,7 +192,8 @@ public class RetailDemoModeService extends SystemService { private void registerBroadcastReceiver() { final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_SCREEN_OFF); getContext().registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null); filter.addAction(ACTION_RESET_DEMO); getContext().registerReceiver(mBroadcastReceiver, filter); } @Override Loading @@ -184,6 +215,8 @@ public class RetailDemoModeService extends SystemService { mPm = (PowerManager) getContext().getSystemService(Context.POWER_SERVICE); mWakeLock = mPm .newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, TAG); mNm = NotificationManager.from(getContext()); if (UserManager.isDeviceInDemoMode(getContext())) { createAndSwitchToDemoUser(); } Loading @@ -208,5 +241,6 @@ public class RetailDemoModeService extends SystemService { if (!mWakeLock.isHeld()) { mWakeLock.acquire(); } mNm.notifyAsUser(TAG, 1, createResetNotification(), UserHandle.of(userId)); } } Loading
core/res/AndroidManifest.xml +2 −0 Original line number Diff line number Diff line Loading @@ -481,6 +481,8 @@ <protected-broadcast android:name="android.intent.action.MANAGED_PROFILE_AVAILABLE" /> <protected-broadcast android:name="android.intent.action.MANAGED_PROFILE_UNAVAILABLE" /> <protected-broadcast android:name="com.android.server.am.ACTION_RESET_DEMO" /> <!-- ====================================================================== --> <!-- RUNTIME PERMISSIONS --> <!-- ====================================================================== --> Loading
core/res/res/values/strings.xml +5 −0 Original line number Diff line number Diff line Loading @@ -4362,6 +4362,11 @@ <!-- The representation of a time duration when negative. An example is -1:14. This can be used with a countdown timer for example.--> <string name="negative_duration">\u2212<xliff:g id="time" example="1:14">%1$s</xliff:g></string> <!-- Title of notification to start a new demo session when device is in retail mode [CHAR LIMIT=NONE] --> <string name="reset_retail_demo_mode_title">Restart Session</string> <!-- Text of notification to start a new demo session when device is in retail mode [CHAR LIMIT=NONE] --> <string name="reset_retail_demo_mode_text">Tap to start a new demo session</string> <!-- Title of notification shown when device has been forced to safe mode after a security compromise. --> <string name="audit_safemode_notification">Factory reset to use this device without restrictions</string> <!-- Description of notification shown when device has been forced to safe mode after a security compromise. --> Loading
core/res/res/values/symbols.xml +2 −0 Original line number Diff line number Diff line Loading @@ -1888,6 +1888,8 @@ <java-symbol type="string" name="config_persistentDataPackageName" /> <java-symbol type="string" name="audit_safemode_notification" /> <java-symbol type="string" name="audit_safemode_notification_details" /> <java-symbol type="string" name="reset_retail_demo_mode_title" /> <java-symbol type="string" name="reset_retail_demo_mode_text" /> <java-symbol type="layout" name="resolver_list" /> <java-symbol type="id" name="resolver_list" /> Loading
services/core/java/com/android/server/am/RetailDemoModeService.java +35 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,9 @@ package com.android.server.am; import android.app.ActivityManagerNative; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.Context; Loading @@ -36,6 +39,7 @@ import android.provider.Settings; import android.util.Slog; import com.android.internal.os.BackgroundThread; import com.android.internal.R; import com.android.server.ServiceThread; import com.android.server.SystemService; import com.android.server.pm.UserManagerService; Loading @@ -47,15 +51,18 @@ public class RetailDemoModeService extends SystemService { private static final String TAG = RetailDemoModeService.class.getSimpleName(); private static final String DEMO_USER_NAME = "Demo"; private static final String ACTION_RESET_DEMO = "com.android.server.am.ACTION_RESET_DEMO"; private static final long SCREEN_WAKEUP_DELAY = 5000; private ActivityManagerService mAms; private UserManagerService mUms; private NotificationManager mNm; private PowerManager mPm; private PowerManager.WakeLock mWakeLock; private Handler mHandler; private ServiceThread mHandlerThread; private PendingIntent mResetDemoPendingIntent; private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { @Override Loading @@ -75,6 +82,9 @@ public class RetailDemoModeService extends SystemService { } }, SCREEN_WAKEUP_DELAY); break; case ACTION_RESET_DEMO: createAndSwitchToDemoUser(); break; } } }; Loading @@ -83,6 +93,26 @@ public class RetailDemoModeService extends SystemService { super(context); } private Notification createResetNotification() { return new Notification.Builder(getContext()) .setContentTitle(getContext().getString(R.string.reset_retail_demo_mode_title)) .setContentText(getContext().getString(R.string.reset_retail_demo_mode_text)) .setOngoing(true) .setSmallIcon(R.drawable.platlogo) .setShowWhen(false) .setVisibility(Notification.VISIBILITY_PUBLIC) .setContentIntent(getResetDemoPendingIntent()) .build(); } private PendingIntent getResetDemoPendingIntent() { if (mResetDemoPendingIntent == null) { Intent intent = new Intent(ACTION_RESET_DEMO); mResetDemoPendingIntent = PendingIntent.getBroadcast(getContext(), 0, intent, 0); } return mResetDemoPendingIntent; } private void createAndSwitchToDemoUser() { if (DEBUG) { Slog.d(TAG, "Switching to a new demo user"); Loading Loading @@ -162,7 +192,8 @@ public class RetailDemoModeService extends SystemService { private void registerBroadcastReceiver() { final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_SCREEN_OFF); getContext().registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null); filter.addAction(ACTION_RESET_DEMO); getContext().registerReceiver(mBroadcastReceiver, filter); } @Override Loading @@ -184,6 +215,8 @@ public class RetailDemoModeService extends SystemService { mPm = (PowerManager) getContext().getSystemService(Context.POWER_SERVICE); mWakeLock = mPm .newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, TAG); mNm = NotificationManager.from(getContext()); if (UserManager.isDeviceInDemoMode(getContext())) { createAndSwitchToDemoUser(); } Loading @@ -208,5 +241,6 @@ public class RetailDemoModeService extends SystemService { if (!mWakeLock.isHeld()) { mWakeLock.acquire(); } mNm.notifyAsUser(TAG, 1, createResetNotification(), UserHandle.of(userId)); } }