From efc1c4d50104e9b9a7581c9b60703727805897f0 Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Thu, 21 Jul 2016 07:44:33 -0700 Subject: Enable web action apps based on system setting Bug: 28140107 Change-Id: I4cff49165be6432404b9a616ca35bee249daab2a --- core/java/android/provider/Settings.java | 7 ++++++ .../android/server/pm/PackageManagerService.java | 26 +++++++++++++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 1ed27ce38e7a..0b428d43ed16 100755 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -6325,6 +6325,13 @@ public final class Settings { public static final String DEMO_USER_SETUP_COMPLETE = "demo_user_setup_complete"; + /** + * Specifies whether the web action API is enabled. + * + * @hide + */ + public static final String WEB_ACTION_ENABLED = "web_action_enabled"; + /** * This are the settings to be backed up. * diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 29cbdbb990de..f84356bdb2b7 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -197,6 +197,7 @@ import android.os.storage.StorageManager; import android.os.storage.VolumeInfo; import android.os.storage.VolumeRecord; import android.provider.Settings.Global; +import android.provider.Settings.Secure; import android.security.KeyStore; import android.security.SystemKeyStore; import android.system.ErrnoException; @@ -364,6 +365,7 @@ public class PackageManagerService extends IPackageManager.Stub { static final boolean CLEAR_RUNTIME_PERMISSIONS_ON_UPGRADE = false; + // STOPSHIP; b/30256615 private static final boolean DISABLE_EPHEMERAL_APPS = !Build.IS_DEBUGGABLE; private static final int RADIO_UID = Process.PHONE_UID; @@ -4766,11 +4768,23 @@ public class PackageManagerService extends IPackageManager.Stub { false, false, false, userId); } + private boolean isEphemeralDisabled() { + // ephemeral apps have been disabled across the board + if (DISABLE_EPHEMERAL_APPS) { + return true; + } + // system isn't up yet; can't read settings, so, assume no ephemeral apps + if (!mSystemReady) { + return true; + } + return Secure.getInt(mContext.getContentResolver(), Secure.WEB_ACTION_ENABLED, 1) == 0; + } + private boolean isEphemeralAllowed( Intent intent, List resolvedActivities, int userId, boolean skipPackageCheck) { // Short circuit and return early if possible. - if (DISABLE_EPHEMERAL_APPS) { + if (isEphemeralDisabled()) { return false; } final int callingUser = UserHandle.getCallingUserId(); @@ -6239,7 +6253,7 @@ public class PackageManagerService extends IPackageManager.Stub { @Override public ParceledListSlice getEphemeralApplications(int userId) { - if (DISABLE_EPHEMERAL_APPS) { + if (isEphemeralDisabled()) { return null; } @@ -6263,7 +6277,7 @@ public class PackageManagerService extends IPackageManager.Stub { enforceCrossUserPermission(Binder.getCallingUid(), userId, true /* requireFullPermission */, false /* checkShell */, "isEphemeral"); - if (DISABLE_EPHEMERAL_APPS) { + if (isEphemeralDisabled()) { return false; } @@ -6281,7 +6295,7 @@ public class PackageManagerService extends IPackageManager.Stub { @Override public byte[] getEphemeralApplicationCookie(String packageName, int userId) { - if (DISABLE_EPHEMERAL_APPS) { + if (isEphemeralDisabled()) { return null; } @@ -6299,7 +6313,7 @@ public class PackageManagerService extends IPackageManager.Stub { @Override public boolean setEphemeralApplicationCookie(String packageName, byte[] cookie, int userId) { - if (DISABLE_EPHEMERAL_APPS) { + if (isEphemeralDisabled()) { return true; } @@ -6317,7 +6331,7 @@ public class PackageManagerService extends IPackageManager.Stub { @Override public Bitmap getEphemeralApplicationIcon(String packageName, int userId) { - if (DISABLE_EPHEMERAL_APPS) { + if (isEphemeralDisabled()) { return null; } -- cgit v1.2.3-59-g8ed1b