Allow calling in demo mode

Allow outgoing calls, but clear the call log when
the next demo session starts so that the next
customer doesn't see any residue.

Fixes: 30220132
Change-Id: Ice71ba750f43fb31bf657d6ae31da62abbd72cfc
This commit is contained in:
Amith Yamasani
2016-07-19 11:49:38 -07:00
parent 586f23c14b
commit bc26f5fb6a

View File

@@ -26,6 +26,7 @@ import android.app.PendingIntent;
import android.app.RetailDemoModeServiceInternal;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentProvider;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
@@ -53,6 +54,7 @@ import android.os.RemoteException;
import android.os.SystemClock;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.CallLog;
import android.provider.MediaStore;
import android.provider.Settings;
import android.util.KeyValueListParser;
@@ -327,6 +329,8 @@ public class RetailDemoModeService extends SystemService {
um.setUserRestriction(UserManager.DISALLOW_USB_FILE_TRANSFER, true, user);
um.setUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS, true, user);
um.setUserRestriction(UserManager.DISALLOW_CONFIG_BLUETOOTH, true, user);
// Set this to false because the default is true on user creation
um.setUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS, false, user);
// Disallow rebooting in safe mode - controlled by user 0
getUserManager().setUserRestriction(UserManager.DISALLOW_SAFE_BOOT, true,
UserHandle.SYSTEM);
@@ -335,7 +339,8 @@ public class RetailDemoModeService extends SystemService {
Settings.Secure.putIntForUser(getContext().getContentResolver(),
Settings.Global.PACKAGE_VERIFIER_ENABLE, 0, userInfo.id);
grantRuntimePermissionToCamera(userInfo.getUserHandle());
grantRuntimePermissionToCamera(user);
clearPrimaryCallLog();
}
private void grantRuntimePermissionToCamera(UserHandle user) {
@@ -353,7 +358,18 @@ public class RetailDemoModeService extends SystemService {
} catch (Exception e) {
// Ignore
}
}
private void clearPrimaryCallLog() {
final ContentResolver resolver = getContext().getContentResolver();
// Deleting primary user call log so that it doesn't get copied to the new demo user
final Uri uri = CallLog.Calls.CONTENT_URI;
try {
resolver.delete(uri, null, null);
} catch (Exception e) {
Slog.w(TAG, "Deleting call log failed: " + e);
}
}
void logSessionDuration() {