/*** Return a bit mask of the differences between this Configuration* object and the given one. Does not change the values of either. Any* undefined fields in delta are ignored.* @return Returns a bit mask indicating which configuration* values has changed, containing any combination of* {@link android.content.pm.ActivityInfo#CONFIG_FONT_SCALE* PackageManager.ActivityInfo.CONFIG_FONT_SCALE},* {@link android.content.pm.ActivityInfo#CONFIG_MCC* PackageManager.ActivityInfo.CONFIG_MCC},* {@link android.content.pm.ActivityInfo#CONFIG_MNC* PackageManager.ActivityInfo.CONFIG_MNC},* {@link android.content.pm.ActivityInfo#CONFIG_LOCALE* PackageManager.ActivityInfo.CONFIG_LOCALE},* {@link android.content.pm.ActivityInfo#CONFIG_TOUCHSCREEN* PackageManager.ActivityInfo.CONFIG_TOUCHSCREEN},* {@link android.content.pm.ActivityInfo#CONFIG_KEYBOARD* PackageManager.ActivityInfo.CONFIG_KEYBOARD},* {@link android.content.pm.ActivityInfo#CONFIG_NAVIGATION* PackageManager.ActivityInfo.CONFIG_NAVIGATION},* {@link android.content.pm.ActivityInfo#CONFIG_ORIENTATION* PackageManager.ActivityInfo.CONFIG_ORIENTATION},* {@link android.content.pm.ActivityInfo#CONFIG_SCREEN_LAYOUT* PackageManager.ActivityInfo.CONFIG_SCREEN_LAYOUT}, or* {@link android.content.pm.ActivityInfo#CONFIG_SCREEN_SIZE* PackageManager.ActivityInfo.CONFIG_SCREEN_SIZE}, or* {@link android.content.pm.ActivityInfo#CONFIG_SMALLEST_SCREEN_SIZE* PackageManager.ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE}.* {@link android.content.pm.ActivityInfo#CONFIG_LAYOUT_DIRECTION* PackageManager.ActivityInfo.CONFIG_LAYOUT_DIRECTION}.*/
public int diff(Configuration delta) {
int changed = 0;
if (delta.fontScale > 0 && fontScale != delta.fontScale) {
changed |= ActivityInfo.CONFIG_FONT_SCALE;
}
if (delta.mcc != 0 && mcc != delta.mcc) {
changed |= ActivityInfo.CONFIG_MCC;
}
if (delta.mnc != 0 && mnc != delta.mnc) {
changed |= ActivityInfo.CONFIG_MNC;
}
if (delta.locale != null
&& (locale == null || !locale.equals(delta.locale))) {
changed |= ActivityInfo.CONFIG_LOCALE;
changed |= ActivityInfo.CONFIG_LAYOUT_DIRECTION;
}
final int deltaScreenLayoutDir = delta.screenLayout & SCREENLAYOUT_LAYOUTDIR_MASK;
if (deltaScreenLayoutDir != SCREENLAYOUT_LAYOUTDIR_UNDEFINED &&
deltaScreenLayoutDir != (screenLayout & SCREENLAYOUT_LAYOUTDIR_MASK)) {
changed |= ActivityInfo.CONFIG_LAYOUT_DIRECTION;
}
if (delta.touchscreen != TOUCHSCREEN_UNDEFINED
&& touchscreen != delta.touchscreen) {
changed |= ActivityInfo.CONFIG_TOUCHSCREEN;
}
if (delta.keyboard != KEYBOARD_UNDEFINED
&& keyboard != delta.keyboard) {
changed |= ActivityInfo.CONFIG_KEYBOARD;
}
if (delta.keyboardHidden != KEYBOARDHIDDEN_UNDEFINED
&& keyboardHidden != delta.keyboardHidden) {
changed |= ActivityInfo.CONFIG_KEYBOARD_HIDDEN;
}
if (delta.hardKeyboardHidden != HARDKEYBOARDHIDDEN_UNDEFINED
&& hardKeyboardHidden != delta.hardKeyboardHidden) {
changed |= ActivityInfo.CONFIG_KEYBOARD_HIDDEN;
}
if (delta.navigation != NAVIGATION_UNDEFINED
&& navigation != delta.navigation) {
changed |= ActivityInfo.CONFIG_NAVIGATION;
}
if (delta.navigationHidden != NAVIGATIONHIDDEN_UNDEFINED
&& navigationHidden != delta.navigationHidden) {
changed |= ActivityInfo.CONFIG_KEYBOARD_HIDDEN;
}
if (delta.orientation != ORIENTATION_UNDEFINED
&& orientation != delta.orientation) {
changed |= ActivityInfo.CONFIG_ORIENTATION;
}
if (getScreenLayoutNoDirection(delta.screenLayout) !=
(SCREENLAYOUT_SIZE_UNDEFINED | SCREENLAYOUT_LONG_UNDEFINED)
&& getScreenLayoutNoDirection(screenLayout) !=
getScreenLayoutNoDirection(delta.screenLayout)) {
changed |= ActivityInfo.CONFIG_SCREEN_LAYOUT;
}
if (delta.uiMode != (UI_MODE_TYPE_UNDEFINED|UI_MODE_NIGHT_UNDEFINED)
&& uiMode != delta.uiMode) {
changed |= ActivityInfo.CONFIG_UI_MODE;
}
if (delta.screenWidthDp != SCREEN_WIDTH_DP_UNDEFINED
&& screenWidthDp != delta.screenWidthDp) {
changed |= ActivityInfo.CONFIG_SCREEN_SIZE;
}
if (delta.screenHeightDp != SCREEN_HEIGHT_DP_UNDEFINED
&& screenHeightDp != delta.screenHeightDp) {
changed |= ActivityInfo.CONFIG_SCREEN_SIZE;
}
if (delta.smallestScreenWidthDp != SMALLEST_SCREEN_WIDTH_DP_UNDEFINED
&& smallestScreenWidthDp != delta.smallestScreenWidthDp) {
changed |= ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
}
if (delta.densityDpi != DENSITY_DPI_UNDEFINED
&& densityDpi != delta.densityDpi) {
changed |= ActivityInfo.CONFIG_DENSITY;
}
return changed;
}