Merge "Adding Reset Demo Notification" into nyc-mr1-dev
am: 1b9f13d7bc
* commit '1b9f13d7bc35be59f88821393ed552b9c5a28f6d':
Adding Reset Demo Notification
Change-Id: Idee3562505cb64f2ae9c8af120c7984d41418d70
This commit is contained in:
@@ -481,6 +481,8 @@
|
|||||||
<protected-broadcast android:name="android.intent.action.MANAGED_PROFILE_AVAILABLE" />
|
<protected-broadcast android:name="android.intent.action.MANAGED_PROFILE_AVAILABLE" />
|
||||||
<protected-broadcast android:name="android.intent.action.MANAGED_PROFILE_UNAVAILABLE" />
|
<protected-broadcast android:name="android.intent.action.MANAGED_PROFILE_UNAVAILABLE" />
|
||||||
|
|
||||||
|
<protected-broadcast android:name="com.android.server.am.ACTION_RESET_DEMO" />
|
||||||
|
|
||||||
<!-- ====================================================================== -->
|
<!-- ====================================================================== -->
|
||||||
<!-- RUNTIME PERMISSIONS -->
|
<!-- RUNTIME PERMISSIONS -->
|
||||||
<!-- ====================================================================== -->
|
<!-- ====================================================================== -->
|
||||||
|
|||||||
@@ -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.-->
|
<!-- 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>
|
<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. -->
|
<!-- 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>
|
<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. -->
|
<!-- Description of notification shown when device has been forced to safe mode after a security compromise. -->
|
||||||
|
|||||||
@@ -1888,6 +1888,8 @@
|
|||||||
<java-symbol type="string" name="config_persistentDataPackageName" />
|
<java-symbol type="string" name="config_persistentDataPackageName" />
|
||||||
<java-symbol type="string" name="audit_safemode_notification" />
|
<java-symbol type="string" name="audit_safemode_notification" />
|
||||||
<java-symbol type="string" name="audit_safemode_notification_details" />
|
<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="layout" name="resolver_list" />
|
||||||
<java-symbol type="id" name="resolver_list" />
|
<java-symbol type="id" name="resolver_list" />
|
||||||
|
|||||||
@@ -17,6 +17,9 @@
|
|||||||
package com.android.server.am;
|
package com.android.server.am;
|
||||||
|
|
||||||
import android.app.ActivityManagerNative;
|
import android.app.ActivityManagerNative;
|
||||||
|
import android.app.Notification;
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -36,6 +39,7 @@ import android.provider.Settings;
|
|||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
|
|
||||||
import com.android.internal.os.BackgroundThread;
|
import com.android.internal.os.BackgroundThread;
|
||||||
|
import com.android.internal.R;
|
||||||
import com.android.server.ServiceThread;
|
import com.android.server.ServiceThread;
|
||||||
import com.android.server.SystemService;
|
import com.android.server.SystemService;
|
||||||
import com.android.server.pm.UserManagerService;
|
import com.android.server.pm.UserManagerService;
|
||||||
@@ -47,15 +51,18 @@ public class RetailDemoModeService extends SystemService {
|
|||||||
|
|
||||||
private static final String TAG = RetailDemoModeService.class.getSimpleName();
|
private static final String TAG = RetailDemoModeService.class.getSimpleName();
|
||||||
private static final String DEMO_USER_NAME = "Demo";
|
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 static final long SCREEN_WAKEUP_DELAY = 5000;
|
||||||
|
|
||||||
private ActivityManagerService mAms;
|
private ActivityManagerService mAms;
|
||||||
private UserManagerService mUms;
|
private UserManagerService mUms;
|
||||||
|
private NotificationManager mNm;
|
||||||
private PowerManager mPm;
|
private PowerManager mPm;
|
||||||
private PowerManager.WakeLock mWakeLock;
|
private PowerManager.WakeLock mWakeLock;
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
private ServiceThread mHandlerThread;
|
private ServiceThread mHandlerThread;
|
||||||
|
private PendingIntent mResetDemoPendingIntent;
|
||||||
|
|
||||||
private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
@@ -75,6 +82,9 @@ public class RetailDemoModeService extends SystemService {
|
|||||||
}
|
}
|
||||||
}, SCREEN_WAKEUP_DELAY);
|
}, SCREEN_WAKEUP_DELAY);
|
||||||
break;
|
break;
|
||||||
|
case ACTION_RESET_DEMO:
|
||||||
|
createAndSwitchToDemoUser();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -83,6 +93,26 @@ public class RetailDemoModeService extends SystemService {
|
|||||||
super(context);
|
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() {
|
private void createAndSwitchToDemoUser() {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Slog.d(TAG, "Switching to a new demo user");
|
Slog.d(TAG, "Switching to a new demo user");
|
||||||
@@ -162,7 +192,8 @@ public class RetailDemoModeService extends SystemService {
|
|||||||
private void registerBroadcastReceiver() {
|
private void registerBroadcastReceiver() {
|
||||||
final IntentFilter filter = new IntentFilter();
|
final IntentFilter filter = new IntentFilter();
|
||||||
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||||
getContext().registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null);
|
filter.addAction(ACTION_RESET_DEMO);
|
||||||
|
getContext().registerReceiver(mBroadcastReceiver, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -184,6 +215,8 @@ public class RetailDemoModeService extends SystemService {
|
|||||||
mPm = (PowerManager) getContext().getSystemService(Context.POWER_SERVICE);
|
mPm = (PowerManager) getContext().getSystemService(Context.POWER_SERVICE);
|
||||||
mWakeLock = mPm
|
mWakeLock = mPm
|
||||||
.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, TAG);
|
.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, TAG);
|
||||||
|
mNm = NotificationManager.from(getContext());
|
||||||
|
|
||||||
if (UserManager.isDeviceInDemoMode(getContext())) {
|
if (UserManager.isDeviceInDemoMode(getContext())) {
|
||||||
createAndSwitchToDemoUser();
|
createAndSwitchToDemoUser();
|
||||||
}
|
}
|
||||||
@@ -208,5 +241,6 @@ public class RetailDemoModeService extends SystemService {
|
|||||||
if (!mWakeLock.isHeld()) {
|
if (!mWakeLock.isHeld()) {
|
||||||
mWakeLock.acquire();
|
mWakeLock.acquire();
|
||||||
}
|
}
|
||||||
|
mNm.notifyAsUser(TAG, 1, createResetNotification(), UserHandle.of(userId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user