Loading core/java/android/provider/Settings.java +1 −2 Original line number Diff line number Diff line Loading @@ -2020,8 +2020,7 @@ public final class Settings { * In some cases, a matching Activity may not exist, so ensure you * safeguard against this. * <p> * Input: The Intent's data URI specifies the application package name * to be shown, with the "package" scheme. That is "package:com.my.app". * Input: Nothing. * <p> * Output: Nothing. */ Loading core/java/android/service/quickaccesswallet/QuickAccessWalletClientImpl.java +58 −14 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.service.quickaccesswallet; import static android.service.quickaccesswallet.QuickAccessWalletService.ACTION_VIEW_WALLET; import static android.service.quickaccesswallet.QuickAccessWalletService.ACTION_VIEW_WALLET_SETTINGS; import static android.service.quickaccesswallet.QuickAccessWalletService.SERVICE_INTERFACE; import android.annotation.CallbackExecutor; Loading @@ -26,6 +28,9 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.IBinder; Loading Loading @@ -97,8 +102,7 @@ public class QuickAccessWalletClientImpl implements QuickAccessWalletClient, Ser @Override public boolean isWalletFeatureAvailableWhenDeviceLocked() { return checkSecureSetting(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS) && checkSecureSetting(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS); return checkSecureSetting(Settings.Secure.POWER_MENU_LOCKED_SHOW_CONTENT); } @Override Loading Loading @@ -234,27 +238,67 @@ public class QuickAccessWalletClientImpl implements QuickAccessWalletClient, Ser @Override @Nullable public Intent createWalletIntent() { if (mServiceInfo == null || TextUtils.isEmpty(mServiceInfo.getWalletActivity())) { if (mServiceInfo == null) { return null; } return new Intent(QuickAccessWalletService.ACTION_VIEW_WALLET) .setComponent( new ComponentName( mServiceInfo.getComponentName().getPackageName(), mServiceInfo.getWalletActivity())); String packageName = mServiceInfo.getComponentName().getPackageName(); String walletActivity = mServiceInfo.getWalletActivity(); return createIntent(walletActivity, packageName, ACTION_VIEW_WALLET); } @Override @Nullable public Intent createWalletSettingsIntent() { if (mServiceInfo == null || TextUtils.isEmpty(mServiceInfo.getSettingsActivity())) { if (mServiceInfo == null) { return null; } return new Intent(QuickAccessWalletService.ACTION_VIEW_WALLET_SETTINGS) .setComponent( new ComponentName( mServiceInfo.getComponentName().getPackageName(), mServiceInfo.getSettingsActivity())); String packageName = mServiceInfo.getComponentName().getPackageName(); String settingsActivity = mServiceInfo.getSettingsActivity(); return createIntent(settingsActivity, packageName, ACTION_VIEW_WALLET_SETTINGS); } @Nullable private Intent createIntent(@Nullable String activityName, String packageName, String action) { PackageManager pm = mContext.getPackageManager(); if (TextUtils.isEmpty(activityName)) { activityName = queryActivityForAction(pm, packageName, action); } if (TextUtils.isEmpty(activityName)) { return null; } ComponentName component = new ComponentName(packageName, activityName); if (!isActivityEnabled(pm, component)) { return null; } return new Intent(action).setComponent(component); } @Nullable private static String queryActivityForAction(PackageManager pm, String packageName, String action) { Intent intent = new Intent(action).setPackage(packageName); ResolveInfo resolveInfo = pm.resolveActivity(intent, 0); if (resolveInfo == null || resolveInfo.activityInfo == null || !resolveInfo.activityInfo.exported) { return null; } return resolveInfo.activityInfo.name; } private static boolean isActivityEnabled(PackageManager pm, ComponentName component) { int setting = pm.getComponentEnabledSetting(component); if (setting == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) { return true; } if (setting != PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) { return false; } try { return pm.getActivityInfo(component, 0).isEnabled(); } catch (NameNotFoundException e) { return false; } } @Override Loading Loading
core/java/android/provider/Settings.java +1 −2 Original line number Diff line number Diff line Loading @@ -2020,8 +2020,7 @@ public final class Settings { * In some cases, a matching Activity may not exist, so ensure you * safeguard against this. * <p> * Input: The Intent's data URI specifies the application package name * to be shown, with the "package" scheme. That is "package:com.my.app". * Input: Nothing. * <p> * Output: Nothing. */ Loading
core/java/android/service/quickaccesswallet/QuickAccessWalletClientImpl.java +58 −14 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.service.quickaccesswallet; import static android.service.quickaccesswallet.QuickAccessWalletService.ACTION_VIEW_WALLET; import static android.service.quickaccesswallet.QuickAccessWalletService.ACTION_VIEW_WALLET_SETTINGS; import static android.service.quickaccesswallet.QuickAccessWalletService.SERVICE_INTERFACE; import android.annotation.CallbackExecutor; Loading @@ -26,6 +28,9 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.IBinder; Loading Loading @@ -97,8 +102,7 @@ public class QuickAccessWalletClientImpl implements QuickAccessWalletClient, Ser @Override public boolean isWalletFeatureAvailableWhenDeviceLocked() { return checkSecureSetting(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS) && checkSecureSetting(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS); return checkSecureSetting(Settings.Secure.POWER_MENU_LOCKED_SHOW_CONTENT); } @Override Loading Loading @@ -234,27 +238,67 @@ public class QuickAccessWalletClientImpl implements QuickAccessWalletClient, Ser @Override @Nullable public Intent createWalletIntent() { if (mServiceInfo == null || TextUtils.isEmpty(mServiceInfo.getWalletActivity())) { if (mServiceInfo == null) { return null; } return new Intent(QuickAccessWalletService.ACTION_VIEW_WALLET) .setComponent( new ComponentName( mServiceInfo.getComponentName().getPackageName(), mServiceInfo.getWalletActivity())); String packageName = mServiceInfo.getComponentName().getPackageName(); String walletActivity = mServiceInfo.getWalletActivity(); return createIntent(walletActivity, packageName, ACTION_VIEW_WALLET); } @Override @Nullable public Intent createWalletSettingsIntent() { if (mServiceInfo == null || TextUtils.isEmpty(mServiceInfo.getSettingsActivity())) { if (mServiceInfo == null) { return null; } return new Intent(QuickAccessWalletService.ACTION_VIEW_WALLET_SETTINGS) .setComponent( new ComponentName( mServiceInfo.getComponentName().getPackageName(), mServiceInfo.getSettingsActivity())); String packageName = mServiceInfo.getComponentName().getPackageName(); String settingsActivity = mServiceInfo.getSettingsActivity(); return createIntent(settingsActivity, packageName, ACTION_VIEW_WALLET_SETTINGS); } @Nullable private Intent createIntent(@Nullable String activityName, String packageName, String action) { PackageManager pm = mContext.getPackageManager(); if (TextUtils.isEmpty(activityName)) { activityName = queryActivityForAction(pm, packageName, action); } if (TextUtils.isEmpty(activityName)) { return null; } ComponentName component = new ComponentName(packageName, activityName); if (!isActivityEnabled(pm, component)) { return null; } return new Intent(action).setComponent(component); } @Nullable private static String queryActivityForAction(PackageManager pm, String packageName, String action) { Intent intent = new Intent(action).setPackage(packageName); ResolveInfo resolveInfo = pm.resolveActivity(intent, 0); if (resolveInfo == null || resolveInfo.activityInfo == null || !resolveInfo.activityInfo.exported) { return null; } return resolveInfo.activityInfo.name; } private static boolean isActivityEnabled(PackageManager pm, ComponentName component) { int setting = pm.getComponentEnabledSetting(component); if (setting == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) { return true; } if (setting != PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) { return false; } try { return pm.getActivityInfo(component, 0).isEnabled(); } catch (NameNotFoundException e) { return false; } } @Override Loading