Merge "Accept all system packages as supported home apps for gesture nav" into qt-dev am: 9114784f35
am: 370d19f213
Change-Id: If85747ecc80784a9a1a22c8822b4952c60bc5749
This commit is contained in:
@@ -33,6 +33,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.om.IOverlayManager;
|
import android.content.om.IOverlayManager;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.ApkAssets;
|
import android.content.res.ApkAssets;
|
||||||
import android.os.PatternMatcher;
|
import android.os.PatternMatcher;
|
||||||
@@ -69,6 +70,8 @@ public class NavigationModeController implements Dumpable {
|
|||||||
private static final String TAG = NavigationModeController.class.getSimpleName();
|
private static final String TAG = NavigationModeController.class.getSimpleName();
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
|
|
||||||
|
private static final int SYSTEM_APP_MASK =
|
||||||
|
ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP;
|
||||||
static final String SHARED_PREFERENCES_NAME = "navigation_mode_controller_preferences";
|
static final String SHARED_PREFERENCES_NAME = "navigation_mode_controller_preferences";
|
||||||
static final String PREFS_SWITCHED_FROM_GESTURE_NAV_KEY = "switched_from_gesture_nav";
|
static final String PREFS_SWITCHED_FROM_GESTURE_NAV_KEY = "switched_from_gesture_nav";
|
||||||
|
|
||||||
@@ -315,6 +318,10 @@ public class NavigationModeController implements Dumpable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.d(TAG, "Switching system navigation to 3-button mode:"
|
||||||
|
+ " defaultLauncher=" + getDefaultLauncherPackageName(mCurrentUserContext)
|
||||||
|
+ " contextUser=" + mCurrentUserContext.getUserId());
|
||||||
|
|
||||||
setModeOverlay(NAV_BAR_MODE_3BUTTON_OVERLAY, USER_CURRENT);
|
setModeOverlay(NAV_BAR_MODE_3BUTTON_OVERLAY, USER_CURRENT);
|
||||||
showNotification(mCurrentUserContext, R.string.notification_content_system_nav_changed);
|
showNotification(mCurrentUserContext, R.string.notification_content_system_nav_changed);
|
||||||
mCurrentUserContext.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE)
|
mCurrentUserContext.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE)
|
||||||
@@ -355,9 +362,10 @@ public class NavigationModeController implements Dumpable {
|
|||||||
if (defaultLauncherPackageName == null) {
|
if (defaultLauncherPackageName == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ComponentName recentsComponentName = ComponentName.unflattenFromString(
|
if (isSystemApp(context, defaultLauncherPackageName)) {
|
||||||
context.getString(com.android.internal.R.string.config_recentsComponentName));
|
return true;
|
||||||
return recentsComponentName.getPackageName().equals(defaultLauncherPackageName);
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getDefaultLauncherPackageName(Context context) {
|
private String getDefaultLauncherPackageName(Context context) {
|
||||||
@@ -368,6 +376,17 @@ public class NavigationModeController implements Dumpable {
|
|||||||
return cn.getPackageName();
|
return cn.getPackageName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns true if the app for the given package name is a system app for this device */
|
||||||
|
private boolean isSystemApp(Context context, String packageName) {
|
||||||
|
try {
|
||||||
|
ApplicationInfo ai = context.getPackageManager().getApplicationInfo(packageName,
|
||||||
|
PackageManager.GET_META_DATA);
|
||||||
|
return ai != null && ((ai.flags & SYSTEM_APP_MASK) != 0);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void showNotification(Context context, int resId) {
|
private void showNotification(Context context, int resId) {
|
||||||
final CharSequence message = context.getResources().getString(resId);
|
final CharSequence message = context.getResources().getString(resId);
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
|
|||||||
Reference in New Issue
Block a user