Merge "Use POWER_MENU_LOCKED_SHOW_CONTENT in wallet" into rvc-dev am: 2b49f81e7e am: a300892263 am: 1dea6c7268
Change-Id: I7382e041befd306fcc3bb517c4ab45d249dd469a
This commit is contained in:
@@ -2020,8 +2020,7 @@ public final class Settings {
|
|||||||
* In some cases, a matching Activity may not exist, so ensure you
|
* In some cases, a matching Activity may not exist, so ensure you
|
||||||
* safeguard against this.
|
* safeguard against this.
|
||||||
* <p>
|
* <p>
|
||||||
* Input: The Intent's data URI specifies the application package name
|
* Input: Nothing.
|
||||||
* to be shown, with the "package" scheme. That is "package:com.my.app".
|
|
||||||
* <p>
|
* <p>
|
||||||
* Output: Nothing.
|
* Output: Nothing.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package android.service.quickaccesswallet;
|
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 static android.service.quickaccesswallet.QuickAccessWalletService.SERVICE_INTERFACE;
|
||||||
|
|
||||||
import android.annotation.CallbackExecutor;
|
import android.annotation.CallbackExecutor;
|
||||||
@@ -26,6 +28,9 @@ import android.content.ComponentName;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.ServiceConnection;
|
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.graphics.drawable.Drawable;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
@@ -97,8 +102,7 @@ public class QuickAccessWalletClientImpl implements QuickAccessWalletClient, Ser
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWalletFeatureAvailableWhenDeviceLocked() {
|
public boolean isWalletFeatureAvailableWhenDeviceLocked() {
|
||||||
return checkSecureSetting(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS)
|
return checkSecureSetting(Settings.Secure.POWER_MENU_LOCKED_SHOW_CONTENT);
|
||||||
&& checkSecureSetting(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -234,27 +238,67 @@ public class QuickAccessWalletClientImpl implements QuickAccessWalletClient, Ser
|
|||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public Intent createWalletIntent() {
|
public Intent createWalletIntent() {
|
||||||
if (mServiceInfo == null || TextUtils.isEmpty(mServiceInfo.getWalletActivity())) {
|
if (mServiceInfo == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new Intent(QuickAccessWalletService.ACTION_VIEW_WALLET)
|
String packageName = mServiceInfo.getComponentName().getPackageName();
|
||||||
.setComponent(
|
String walletActivity = mServiceInfo.getWalletActivity();
|
||||||
new ComponentName(
|
return createIntent(walletActivity, packageName, ACTION_VIEW_WALLET);
|
||||||
mServiceInfo.getComponentName().getPackageName(),
|
|
||||||
mServiceInfo.getWalletActivity()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public Intent createWalletSettingsIntent() {
|
public Intent createWalletSettingsIntent() {
|
||||||
if (mServiceInfo == null || TextUtils.isEmpty(mServiceInfo.getSettingsActivity())) {
|
if (mServiceInfo == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new Intent(QuickAccessWalletService.ACTION_VIEW_WALLET_SETTINGS)
|
String packageName = mServiceInfo.getComponentName().getPackageName();
|
||||||
.setComponent(
|
String settingsActivity = mServiceInfo.getSettingsActivity();
|
||||||
new ComponentName(
|
return createIntent(settingsActivity, packageName, ACTION_VIEW_WALLET_SETTINGS);
|
||||||
mServiceInfo.getComponentName().getPackageName(),
|
}
|
||||||
mServiceInfo.getSettingsActivity()));
|
|
||||||
|
@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
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user