summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorYuuki Yokoyama <yuuki.x.yokoyama@sonymobile.com>2017-01-12 16:10:34 +0900
committerTomoharu Kasahara <tomoharu.kasahara@sony.com>2019-01-18 12:25:46 +0900
commit55da3ddbd5c7b87cd1d85ab856887bcb66b40796 (patch)
tree213d54bdd52a6ba77b014edaab9493c2944f13e1 /src/com/android
parent069ba8677d3881928fb8e8f4bc425eaba6808b40 (diff)
downloadplatform_packages_apps_MusicFX-55da3ddbd5c7b87cd1d85ab856887bcb66b40796.tar.gz
platform_packages_apps_MusicFX-55da3ddbd5c7b87cd1d85ab856887bcb66b40796.tar.bz2
platform_packages_apps_MusicFX-55da3ddbd5c7b87cd1d85ab856887bcb66b40796.zip
Fix not to launch MusicActivity directly
When default panel is not saved in the preference, Redirector will launch MusicActivity directly. Search enable app as control panel if default panel is not saved. Bug: 30684724 Test: MusicFX can be launched Change-Id: I87cf6afdb13137c6ad599f0c14ea12988aa83ea4
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/musicfx/Compatibility.java32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/com/android/musicfx/Compatibility.java b/src/com/android/musicfx/Compatibility.java
index 107e132..53d8729 100644
--- a/src/com/android/musicfx/Compatibility.java
+++ b/src/com/android/musicfx/Compatibility.java
@@ -69,12 +69,19 @@ public class Compatibility {
log("read " + defPackage + "/" + defName + " as default");
if (defPackage == null || defName == null) {
Log.e(TAG, "no default set!");
+ ResolveInfo defPanel = Service.searchControlPanel(this, null);
+ if (defPanel == null) {
+ finish();
+ return;
+ }
+ defPackage = defPanel.activityInfo.packageName;
+ defName = defPanel.activityInfo.name;
// use the built-in panel
- i.setComponent(new ComponentName(this, ActivityMusic.class));
+ i.setComponent(new ComponentName(defPackage, defName));
// also save it as the default
Intent updateIntent = new Intent(this, Service.class);
- updateIntent.putExtra("defPackage", getPackageName());
- updateIntent.putExtra("defName", ActivityMusic.class.getName());
+ updateIntent.putExtra("defPackage", defPackage);
+ updateIntent.putExtra("defName", defName);
startService(updateIntent);
} else {
i.setComponent(new ComponentName(defPackage, defName));
@@ -141,15 +148,16 @@ public class Compatibility {
}
}
- private void pickDefaultControlPanel(String updatedPackage) {
+ private static final ResolveInfo searchControlPanel(Context context, String updatedPackage) {
ResolveInfo defPanel = null;
ResolveInfo otherPanel = null;
ResolveInfo thisPanel = null;
Intent i = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL);
- List<ResolveInfo> ris = mPackageManager.queryIntentActivities(i, PackageManager.GET_DISABLED_COMPONENTS);
+ List<ResolveInfo> ris = context.getPackageManager().queryIntentActivities(
+ i, PackageManager.GET_DISABLED_COMPONENTS);
log("found: " + ris.size());
- SharedPreferences pref = getSharedPreferences("musicfx", MODE_PRIVATE);
+ SharedPreferences pref = context.getSharedPreferences("musicfx", Context.MODE_PRIVATE);
String savedDefPackage = pref.getString("defaultpanelpackage", null);
String savedDefName = pref.getString("defaultpanelname", null);
log("saved default: " + savedDefName);
@@ -168,7 +176,8 @@ public class Compatibility {
} else if (foo.activityInfo.packageName.equals(updatedPackage)) {
log("choosing newly installed package " + updatedPackage);
otherPanel = foo;
- } else if (otherPanel == null && !foo.activityInfo.packageName.equals(getPackageName())) {
+ } else if (otherPanel == null &&
+ !foo.activityInfo.packageName.equals(context.getPackageName())) {
otherPanel = foo;
} else {
thisPanel = foo;
@@ -180,13 +189,20 @@ public class Compatibility {
if (otherPanel == null) {
if (thisPanel == null) {
Log.e(TAG, "No control panels found!");
- return;
+ return null;
}
otherPanel = thisPanel;
}
defPanel = otherPanel;
}
+ return defPanel;
+ }
+ private void pickDefaultControlPanel(String updatedPackage) {
+ ResolveInfo defPanel = searchControlPanel(this, updatedPackage);
+ if (defPanel == null) {
+ return;
+ }
// Now that we have selected a default control panel activity, ensure
// that the broadcast receiver(s) in that same package are enabled,
// and the ones in the other packages are disabled.