Fix Settings crash after disabling Settings Suggestion

- Settings Suggestion App is responsible for searching, we can not
prevent user disable it. Hide search feature if user disable it.

Fixes: 118805907
Fixes: 117921464
Test: manual
Change-Id: I61c47c52265a6efd79ef2fa60272bf6513e678b1
This commit is contained in:
Raff Tsai
2018-11-05 16:10:19 +08:00
parent 7d704c8798
commit 2928cd4c72
8 changed files with 69 additions and 3 deletions

View File

@@ -979,4 +979,14 @@ public final class Utils extends com.android.settingslib.Utils {
return packageManager.getDefaultActivityIcon();
}
}
/** Returns true if the current package is installed & enabled. */
public static boolean isPackageEnabled(Context context, String packageName) {
try {
return context.getPackageManager().getApplicationInfo(packageName, 0).enabled;
} catch (Exception e) {
Log.e(TAG, "Error while retrieving application info for package " + packageName, e);
}
return false;
}
}