id
int32
0
12.9k
code
sequencelengths
2
264k
8,200
[ "<s>", "package", "com", ".", "android", ".", "server", ".", "wm", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "FIRST_APPLICATION_WINDOW", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "FIRST_SUB_WINDOW", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "FLAG_BLUR_BEHIND", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "FLAG_COMPATIBLE_WINDOW", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "FLAG_DIM_BEHIND", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "FLAG_KEEP_SCREEN_ON", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "FLAG_NOT_FOCUSABLE", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "FLAG_ALT_FOCUSABLE_IM", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "FLAG_SHOW_WALLPAPER", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "LAST_APPLICATION_WINDOW", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "LAST_SUB_WINDOW", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_APPLICATION_STARTING", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_BASE_APPLICATION", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_INPUT_METHOD", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_INPUT_METHOD_DIALOG", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_WALLPAPER", ";", "import", "com", ".", "android", ".", "internal", ".", "app", ".", "IBatteryStats", ";", "import", "com", ".", "android", ".", "internal", ".", "policy", ".", "PolicyManager", ";", "import", "com", ".", "android", ".", "internal", ".", "policy", ".", "impl", ".", "PhoneWindowManager", ";", "import", "com", ".", "android", ".", "internal", ".", "view", ".", "BaseInputHandler", ";", "import", "com", ".", "android", ".", "internal", ".", "view", ".", "IInputContext", ";", "import", "com", ".", "android", ".", "internal", ".", "view", ".", "IInputMethodClient", ";", "import", "com", ".", "android", ".", "internal", ".", "view", ".", "IInputMethodManager", ";", "import", "com", ".", "android", ".", "internal", ".", "view", ".", "WindowManagerPolicyThread", ";", "import", "com", ".", "android", ".", "server", ".", "AttributeCache", ";", "import", "com", ".", "android", ".", "server", ".", "EventLogTags", ";", "import", "com", ".", "android", ".", "server", ".", "PowerManagerService", ";", "import", "com", ".", "android", ".", "server", ".", "Watchdog", ";", "import", "com", ".", "android", ".", "server", ".", "am", ".", "BatteryStatsService", ";", "import", "android", ".", "Manifest", ";", "import", "android", ".", "app", ".", "ActivityManagerNative", ";", "import", "android", ".", "app", ".", "IActivityManager", ";", "import", "android", ".", "app", ".", "StatusBarManager", ";", "import", "android", ".", "app", ".", "admin", ".", "DevicePolicyManager", ";", "import", "android", ".", "content", ".", "BroadcastReceiver", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "content", ".", "IntentFilter", ";", "import", "android", ".", "content", ".", "pm", ".", "ActivityInfo", ";", "import", "android", ".", "content", ".", "pm", ".", "PackageManager", ";", "import", "android", ".", "content", ".", "res", ".", "CompatibilityInfo", ";", "import", "android", ".", "content", ".", "res", ".", "Configuration", ";", "import", "android", ".", "graphics", ".", "Bitmap", ";", "import", "android", ".", "graphics", ".", "Canvas", ";", "import", "android", ".", "graphics", ".", "Matrix", ";", "import", "android", ".", "graphics", ".", "PixelFormat", ";", "import", "android", ".", "graphics", ".", "Point", ";", "import", "android", ".", "graphics", ".", "Rect", ";", "import", "android", ".", "graphics", ".", "Region", ";", "import", "android", ".", "os", ".", "BatteryStats", ";", "import", "android", ".", "os", ".", "Binder", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "os", ".", "Debug", ";", "import", "android", ".", "os", ".", "Handler", ";", "import", "android", ".", "os", ".", "IBinder", ";", "import", "android", ".", "os", ".", "IRemoteCallback", ";", "import", "android", ".", "os", ".", "LocalPowerManager", ";", "import", "android", ".", "os", ".", "Looper", ";", "import", "android", ".", "os", ".", "Message", ";", "import", "android", ".", "os", ".", "Parcel", ";", "import", "android", ".", "os", ".", "ParcelFileDescriptor", ";", "import", "android", ".", "os", ".", "Power", ";", "import", "android", ".", "os", ".", "PowerManager", ";", "import", "android", ".", "os", ".", "Process", ";", "import", "android", ".", "os", ".", "RemoteException", ";", "import", "android", ".", "os", ".", "ServiceManager", ";", "import", "android", ".", "os", ".", "StrictMode", ";", "import", "android", ".", "os", ".", "SystemClock", ";", "import", "android", ".", "os", ".", "SystemProperties", ";", "import", "android", ".", "os", ".", "TokenWatcher", ";", "import", "android", ".", "provider", ".", "Settings", ";", "import", "android", ".", "util", ".", "DisplayMetrics", ";", "import", "android", ".", "util", ".", "EventLog", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "util", ".", "Pair", ";", "import", "android", ".", "util", ".", "Slog", ";", "import", "android", ".", "util", ".", "SparseIntArray", ";", "import", "android", ".", "util", ".", "TypedValue", ";", "import", "android", ".", "view", ".", "Display", ";", "import", "android", ".", "view", ".", "Gravity", ";", "import", "android", ".", "view", ".", "IApplicationToken", ";", "import", "android", ".", "view", ".", "IOnKeyguardExitResult", ";", "import", "android", ".", "view", ".", "IRotationWatcher", ";", "import", "android", ".", "view", ".", "IWindow", ";", "import", "android", ".", "view", ".", "IWindowManager", ";", "import", "android", ".", "view", ".", "IWindowSession", ";", "import", "android", ".", "view", ".", "InputChannel", ";", "import", "android", ".", "view", ".", "InputDevice", ";", "import", "android", ".", "view", ".", "InputEvent", ";", "import", "android", ".", "view", ".", "InputHandler", ";", "import", "android", ".", "view", ".", "InputQueue", ";", "import", "android", ".", "view", ".", "KeyEvent", ";", "import", "android", ".", "view", ".", "MotionEvent", ";", "import", "android", ".", "view", ".", "Surface", ";", "import", "android", ".", "view", ".", "SurfaceSession", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "view", ".", "WindowManager", ";", "import", "android", ".", "view", ".", "WindowManagerImpl", ";", "import", "android", ".", "view", ".", "WindowManagerPolicy", ";", "import", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ";", "import", "android", ".", "view", ".", "WindowManagerPolicy", ".", "FakeWindow", ";", "import", "android", ".", "view", ".", "animation", ".", "Animation", ";", "import", "android", ".", "view", ".", "animation", ".", "AnimationUtils", ";", "import", "android", ".", "view", ".", "animation", ".", "Transformation", ";", "import", "java", ".", "io", ".", "BufferedWriter", ";", "import", "java", ".", "io", ".", "DataInputStream", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileDescriptor", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "FileNotFoundException", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "java", ".", "io", ".", "OutputStreamWriter", ";", "import", "java", ".", "io", ".", "PrintWriter", ";", "import", "java", ".", "io", ".", "StringWriter", ";", "import", "java", ".", "net", ".", "Socket", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "public", "class", "WindowManagerService", "extends", "IWindowManager", ".", "Stub", "implements", "Watchdog", ".", "Monitor", ",", "WindowManagerPolicy", ".", "WindowManagerFuncs", "{", "static", "final", "String", "TAG", "=", "\"\"", ";", "static", "final", "boolean", "DEBUG", "=", "false", ";", "static", "final", "boolean", "DEBUG_ADD_REMOVE", "=", "false", ";", "static", "final", "boolean", "DEBUG_FOCUS", "=", "false", ";", "static", "final", "boolean", "DEBUG_ANIM", "=", "false", ";", "static", "final", "boolean", "DEBUG_LAYOUT", "=", "false", ";", "static", "final", "boolean", "DEBUG_RESIZE", "=", "false", ";", "static", "final", "boolean", "DEBUG_LAYERS", "=", "false", ";", "static", "final", "boolean", "DEBUG_INPUT", "=", "false", ";", "static", "final", "boolean", "DEBUG_INPUT_METHOD", "=", "false", ";", "static", "final", "boolean", "DEBUG_VISIBILITY", "=", "false", ";", "static", "final", "boolean", "DEBUG_WINDOW_MOVEMENT", "=", "false", ";", "static", "final", "boolean", "DEBUG_TOKEN_MOVEMENT", "=", "false", ";", "static", "final", "boolean", "DEBUG_ORIENTATION", "=", "false", ";", "static", "final", "boolean", "DEBUG_APP_ORIENTATION", "=", "false", ";", "static", "final", "boolean", "DEBUG_CONFIGURATION", "=", "false", ";", "static", "final", "boolean", "DEBUG_APP_TRANSITIONS", "=", "false", ";", "static", "final", "boolean", "DEBUG_STARTING_WINDOW", "=", "false", ";", "static", "final", "boolean", "DEBUG_REORDER", "=", "false", ";", "static", "final", "boolean", "DEBUG_WALLPAPER", "=", "false", ";", "static", "final", "boolean", "DEBUG_DRAG", "=", "false", ";", "static", "final", "boolean", "DEBUG_SCREEN_ON", "=", "false", ";", "static", "final", "boolean", "DEBUG_SCREENSHOT", "=", "false", ";", "static", "final", "boolean", "DEBUG_BOOT", "=", "false", ";", "static", "final", "boolean", "SHOW_SURFACE_ALLOC", "=", "false", ";", "static", "final", "boolean", "SHOW_TRANSACTIONS", "=", "false", ";", "static", "final", "boolean", "SHOW_LIGHT_TRANSACTIONS", "=", "false", "||", "SHOW_TRANSACTIONS", ";", "static", "final", "boolean", "HIDE_STACK_CRAWLS", "=", "true", ";", "static", "final", "boolean", "PROFILE_ORIENTATION", "=", "false", ";", "static", "final", "boolean", "BLUR", "=", "true", ";", "static", "final", "boolean", "localLOGV", "=", "DEBUG", ";", "static", "final", "int", "TYPE_LAYER_MULTIPLIER", "=", "10000", ";", "static", "final", "int", "TYPE_LAYER_OFFSET", "=", "1000", ";", "static", "final", "int", "WINDOW_LAYER_MULTIPLIER", "=", "5", ";", "static", "final", "int", "LAYER_OFFSET_DIM", "=", "1", ";", "static", "final", "int", "LAYER_OFFSET_BLUR", "=", "2", ";", "static", "final", "int", "FREEZE_LAYER", "=", "(", "TYPE_LAYER_MULTIPLIER", "*", "200", ")", "+", "1", ";", "static", "final", "int", "MASK_LAYER", "=", "TYPE_LAYER_MULTIPLIER", "*", "200", ";", "static", "final", "int", "MAX_ANIMATION_DURATION", "=", "10", "*", "1000", ";", "static", "final", "int", "DEFAULT_DIM_DURATION", "=", "200", ";", "static", "final", "int", "DEFAULT_FADE_IN_OUT_DURATION", "=", "400", ";", "static", "final", "boolean", "CUSTOM_SCREEN_ROTATION", "=", "true", ";", "private", "static", "final", "int", "INJECTION_TIMEOUT_MILLIS", "=", "30", "*", "1000", ";", "private", "static", "final", "int", "INPUT_DEVICES_READY_FOR_SAFE_MODE_DETECTION_TIMEOUT_MILLIS", "=", "1000", ";", "static", "final", "long", "DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS", "=", "5000", "*", "1000000L", ";", "static", "final", "int", "UPDATE_FOCUS_NORMAL", "=", "0", ";", "static", "final", "int", "UPDATE_FOCUS_WILL_ASSIGN_LAYERS", "=", "1", ";", "static", "final", "int", "UPDATE_FOCUS_PLACING_SURFACES", "=", "2", ";", "static", "final", "int", "UPDATE_FOCUS_WILL_PLACE_SURFACES", "=", "3", ";", "private", "static", "final", "String", "SYSTEM_SECURE", "=", "\"ro.secure\"", ";", "private", "static", "final", "String", "SYSTEM_DEBUGGABLE", "=", "\"\"", ";", "private", "boolean", "mKeyguardDisabled", "=", "false", ";", "private", "static", "final", "int", "ALLOW_DISABLE_YES", "=", "1", ";", "private", "static", "final", "int", "ALLOW_DISABLE_NO", "=", "0", ";", "private", "static", "final", "int", "ALLOW_DISABLE_UNKNOWN", "=", "-", "1", ";", "private", "int", "mAllowDisableKeyguard", "=", "ALLOW_DISABLE_UNKNOWN", ";", "final", "TokenWatcher", "mKeyguardTokenWatcher", "=", "new", "TokenWatcher", "(", "new", "Handler", "(", ")", ",", "\"\"", ")", "{", "public", "void", "acquired", "(", ")", "{", "if", "(", "shouldAllowDisableKeyguard", "(", ")", ")", "{", "mPolicy", ".", "enableKeyguard", "(", "false", ")", ";", "mKeyguardDisabled", "=", "true", ";", "}", "else", "{", "Log", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "}", "}", "public", "void", "released", "(", ")", "{", "mPolicy", ".", "enableKeyguard", "(", "true", ")", ";", "synchronized", "(", "mKeyguardTokenWatcher", ")", "{", "mKeyguardDisabled", "=", "false", ";", "mKeyguardTokenWatcher", ".", "notifyAll", "(", ")", ";", "}", "}", "}", ";", "final", "BroadcastReceiver", "mBroadcastReceiver", "=", "new", "BroadcastReceiver", "(", ")", "{", "@", "Override", "public", "void", "onReceive", "(", "Context", "context", ",", "Intent", "intent", ")", "{", "mPolicy", ".", "enableKeyguard", "(", "true", ")", ";", "synchronized", "(", "mKeyguardTokenWatcher", ")", "{", "mAllowDisableKeyguard", "=", "ALLOW_DISABLE_UNKNOWN", ";", "mKeyguardDisabled", "=", "false", ";", "}", "}", "}", ";", "final", "Context", "mContext", ";", "final", "boolean", "mHaveInputMethods", ";", "final", "boolean", "mAllowBootMessages", ";", "final", "boolean", "mLimitedAlphaCompositing", ";", "final", "boolean", "mSetLandscapeProperty", ";", "final", "WindowManagerPolicy", "mPolicy", "=", "PolicyManager", ".", "makeNewWindowManager", "(", ")", ";", "final", "IActivityManager", "mActivityManager", ";", "final", "IBatteryStats", "mBatteryStats", ";", "final", "HashSet", "<", "Session", ">", "mSessions", "=", "new", "HashSet", "<", "Session", ">", "(", ")", ";", "final", "HashMap", "<", "IBinder", ",", "WindowState", ">", "mWindowMap", "=", "new", "HashMap", "<", "IBinder", ",", "WindowState", ">", "(", ")", ";", "final", "HashMap", "<", "IBinder", ",", "WindowToken", ">", "mTokenMap", "=", "new", "HashMap", "<", "IBinder", ",", "WindowToken", ">", "(", ")", ";", "final", "ArrayList", "<", "WindowToken", ">", "mExitingTokens", "=", "new", "ArrayList", "<", "WindowToken", ">", "(", ")", ";", "final", "ArrayList", "<", "AppWindowToken", ">", "mAppTokens", "=", "new", "ArrayList", "<", "AppWindowToken", ">", "(", ")", ";", "final", "ArrayList", "<", "AppWindowToken", ">", "mExitingAppTokens", "=", "new", "ArrayList", "<", "AppWindowToken", ">", "(", ")", ";", "final", "ArrayList", "<", "AppWindowToken", ">", "mFinishedStarting", "=", "new", "ArrayList", "<", "AppWindowToken", ">", "(", ")", ";", "final", "ArrayList", "<", "WindowState", ">", "mWindows", "=", "new", "ArrayList", "<", "WindowState", ">", "(", ")", ";", "final", "ArrayList", "<", "FakeWindowImpl", ">", "mFakeWindows", "=", "new", "ArrayList", "<", "FakeWindowImpl", ">", "(", ")", ";", "final", "ArrayList", "<", "WindowState", ">", "mResizingWindows", "=", "new", "ArrayList", "<", "WindowState", ">", "(", ")", ";", "final", "ArrayList", "<", "WindowState", ">", "mPendingRemove", "=", "new", "ArrayList", "<", "WindowState", ">", "(", ")", ";", "WindowState", "[", "]", "mPendingRemoveTmp", "=", "new", "WindowState", "[", "20", "]", ";", "final", "ArrayList", "<", "WindowState", ">", "mDestroySurface", "=", "new", "ArrayList", "<", "WindowState", ">", "(", ")", ";", "ArrayList", "<", "WindowState", ">", "mLosingFocus", "=", "new", "ArrayList", "<", "WindowState", ">", "(", ")", ";", "ArrayList", "<", "WindowState", ">", "mForceRemoves", ";", "ArrayList", "<", "Pair", "<", "WindowState", ",", "IRemoteCallback", ">", ">", "mWaitingForDrawn", "=", "new", "ArrayList", "<", "Pair", "<", "WindowState", ",", "IRemoteCallback", ">", ">", "(", ")", ";", "WindowState", "[", "]", "mRebuildTmp", "=", "new", "WindowState", "[", "20", "]", ";", "IInputMethodManager", "mInputMethodManager", ";", "SurfaceSession", "mFxSession", ";", "private", "DimAnimator", "mDimAnimator", "=", "null", ";", "Surface", "mBlurSurface", ";", "boolean", "mBlurShown", ";", "Watermark", "mWatermark", ";", "StrictModeFlash", "mStrictModeFlash", ";", "ScreenRotationAnimation", "mScreenRotationAnimation", ";", "BlackFrame", "mBlackFrame", ";", "int", "mTransactionSequence", "=", "0", ";", "final", "float", "[", "]", "mTmpFloats", "=", "new", "float", "[", "9", "]", ";", "boolean", "mSafeMode", ";", "boolean", "mDisplayEnabled", "=", "false", ";", "boolean", "mSystemBooted", "=", "false", ";", "boolean", "mForceDisplayEnabled", "=", "false", ";", "boolean", "mShowingBootMessages", "=", "false", ";", "final", "Object", "mDisplaySizeLock", "=", "new", "Object", "(", ")", ";", "int", "mInitialDisplayWidth", "=", "0", ";", "int", "mInitialDisplayHeight", "=", "0", ";", "int", "mBaseDisplayWidth", "=", "0", ";", "int", "mBaseDisplayHeight", "=", "0", ";", "int", "mCurDisplayWidth", "=", "0", ";", "int", "mCurDisplayHeight", "=", "0", ";", "int", "mAppDisplayWidth", "=", "0", ";", "int", "mAppDisplayHeight", "=", "0", ";", "int", "mRotation", "=", "0", ";", "int", "mForcedAppOrientation", "=", "ActivityInfo", ".", "SCREEN_ORIENTATION_UNSPECIFIED", ";", "boolean", "mAltOrientation", "=", "false", ";", "ArrayList", "<", "IRotationWatcher", ">", "mRotationWatchers", "=", "new", "ArrayList", "<", "IRotationWatcher", ">", "(", ")", ";", "int", "mDeferredRotationPauseCount", ";", "boolean", "mLayoutNeeded", "=", "true", ";", "boolean", "mAnimationPending", "=", "false", ";", "boolean", "mDisplayFrozen", "=", "false", ";", "boolean", "mWaitingForConfig", "=", "false", ";", "boolean", "mWindowsFreezingScreen", "=", "false", ";", "int", "mAppsFreezingScreen", "=", "0", ";", "int", "mLastWindowForcedOrientation", "=", "ActivityInfo", ".", "SCREEN_ORIENTATION_UNSPECIFIED", ";", "int", "mLayoutSeq", "=", "0", ";", "int", "mLastStatusBarVisibility", "=", "0", ";", "boolean", "mFocusMayChange", ";", "Configuration", "mCurConfiguration", "=", "new", "Configuration", "(", ")", ";", "PowerManager", ".", "WakeLock", "mScreenFrozenLock", ";", "int", "mNextAppTransition", "=", "WindowManagerPolicy", ".", "TRANSIT_UNSET", ";", "String", "mNextAppTransitionPackage", ";", "int", "mNextAppTransitionEnter", ";", "int", "mNextAppTransitionExit", ";", "boolean", "mAppTransitionReady", "=", "false", ";", "boolean", "mAppTransitionRunning", "=", "false", ";", "boolean", "mAppTransitionTimeout", "=", "false", ";", "boolean", "mStartingIconInTransition", "=", "false", ";", "boolean", "mSkipAppTransitionAnimation", "=", "false", ";", "final", "ArrayList", "<", "AppWindowToken", ">", "mOpeningApps", "=", "new", "ArrayList", "<", "AppWindowToken", ">", "(", ")", ";", "final", "ArrayList", "<", "AppWindowToken", ">", "mClosingApps", "=", "new", "ArrayList", "<", "AppWindowToken", ">", "(", ")", ";", "final", "ArrayList", "<", "AppWindowToken", ">", "mToTopApps", "=", "new", "ArrayList", "<", "AppWindowToken", ">", "(", ")", ";", "final", "ArrayList", "<", "AppWindowToken", ">", "mToBottomApps", "=", "new", "ArrayList", "<", "AppWindowToken", ">", "(", ")", ";", "Display", "mDisplay", ";", "final", "DisplayMetrics", "mDisplayMetrics", "=", "new", "DisplayMetrics", "(", ")", ";", "final", "DisplayMetrics", "mRealDisplayMetrics", "=", "new", "DisplayMetrics", "(", ")", ";", "final", "DisplayMetrics", "mTmpDisplayMetrics", "=", "new", "DisplayMetrics", "(", ")", ";", "final", "DisplayMetrics", "mCompatDisplayMetrics", "=", "new", "DisplayMetrics", "(", ")", ";", "H", "mH", "=", "new", "H", "(", ")", ";", "WindowState", "mCurrentFocus", "=", "null", ";", "WindowState", "mLastFocus", "=", "null", ";", "WindowState", "mInputMethodTarget", "=", "null", ";", "boolean", "mInputMethodTargetWaitingAnim", ";", "int", "mInputMethodAnimLayerAdjustment", ";", "WindowState", "mInputMethodWindow", "=", "null", ";", "final", "ArrayList", "<", "WindowState", ">", "mInputMethodDialogs", "=", "new", "ArrayList", "<", "WindowState", ">", "(", ")", ";", "boolean", "mHardKeyboardAvailable", ";", "boolean", "mHardKeyboardEnabled", ";", "OnHardKeyboardStatusChangeListener", "mHardKeyboardStatusChangeListener", ";", "final", "ArrayList", "<", "WindowToken", ">", "mWallpaperTokens", "=", "new", "ArrayList", "<", "WindowToken", ">", "(", ")", ";", "WindowState", "mWallpaperTarget", "=", "null", ";", "WindowState", "mLowerWallpaperTarget", "=", "null", ";", "WindowState", "mUpperWallpaperTarget", "=", "null", ";", "WindowState", "mWindowDetachedWallpaper", "=", "null", ";", "DimSurface", "mWindowAnimationBackgroundSurface", "=", "null", ";", "int", "mWallpaperAnimLayerAdjustment", ";", "float", "mLastWallpaperX", "=", "-", "1", ";", "float", "mLastWallpaperY", "=", "-", "1", ";", "float", "mLastWallpaperXStep", "=", "-", "1", ";", "float", "mLastWallpaperYStep", "=", "-", "1", ";", "WindowState", "mWaitingOnWallpaper", ";", "long", "mLastWallpaperTimeoutTime", ";", "static", "final", "long", "WALLPAPER_TIMEOUT", "=", "150", ";", "static", "final", "long", "WALLPAPER_TIMEOUT_RECOVERY", "=", "10000", ";", "AppWindowToken", "mFocusedApp", "=", "null", ";", "PowerManagerService", "mPowerManager", ";", "float", "mWindowAnimationScale", "=", "1.0f", ";", "float", "mTransitionAnimationScale", "=", "1.0f", ";", "final", "InputManager", "mInputManager", ";", "private", "boolean", "mForceDisableHardwareKeyboard", "=", "false", ";", "Session", "mHoldingScreenOn", ";", "PowerManager", ".", "WakeLock", "mHoldingScreenWakeLock", ";", "boolean", "mTurnOnScreen", ";", "DragState", "mDragState", "=", "null", ";", "final", "InputHandler", "mDragInputHandler", "=", "new", "BaseInputHandler", "(", ")", "{", "@", "Override", "public", "void", "handleMotion", "(", "MotionEvent", "event", ",", "InputQueue", ".", "FinishedCallback", "finishedCallback", ")", "{", "boolean", "handled", "=", "false", ";", "try", "{", "if", "(", "(", "event", ".", "getSource", "(", ")", "&", "InputDevice", ".", "SOURCE_CLASS_POINTER", ")", "!=", "0", "&&", "mDragState", "!=", "null", ")", "{", "boolean", "endDrag", "=", "false", ";", "final", "float", "newX", "=", "event", ".", "getRawX", "(", ")", ";", "final", "float", "newY", "=", "event", ".", "getRawY", "(", ")", ";", "switch", "(", "event", ".", "getAction", "(", ")", ")", "{", "case", "MotionEvent", ".", "ACTION_DOWN", ":", "{", "if", "(", "DEBUG_DRAG", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "}", "}", "break", ";", "case", "MotionEvent", ".", "ACTION_MOVE", ":", "{", "synchronized", "(", "mWindowMap", ")", "{", "mDragState", ".", "notifyMoveLw", "(", "newX", ",", "newY", ")", ";", "}", "}", "break", ";", "case", "MotionEvent", ".", "ACTION_UP", ":", "{", "if", "(", "DEBUG_DRAG", ")", "Slog", ".", "d", "(", "TAG", ",", "\"\"", "+", "newX", "+", "\",\"", "+", "newY", ")", ";", "synchronized", "(", "mWindowMap", ")", "{", "endDrag", "=", "mDragState", ".", "notifyDropLw", "(", "newX", ",", "newY", ")", ";", "}", "}", "break", ";", "case", "MotionEvent", ".", "ACTION_CANCEL", ":", "{", "if", "(", "DEBUG_DRAG", ")", "Slog", ".", "d", "(", "TAG", ",", "\"\"", ")", ";", "endDrag", "=", "true", ";", "}", "break", ";", "}", "if", "(", "endDrag", ")", "{", "if", "(", "DEBUG_DRAG", ")", "Slog", ".", "d", "(", "TAG", ",", "\"\"", ")", ";", "synchronized", "(", "mWindowMap", ")", "{", "mDragState", ".", "endDragLw", "(", ")", ";", "}", "}", "handled", "=", "true", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "Slog", ".", "e", "(", "TAG", ",", "\"\"", ",", "e", ")", ";", "}", "finally", "{", "finishedCallback", ".", "finished", "(", "handled", ")", ";", "}", "}", "}", ";", "boolean", "mInTouchMode", "=", "true", ";", "private", "ViewServer", "mViewServer", ";", "private", "ArrayList", "<", "WindowChangeListener", ">", "mWindowChangeListeners", "=", "new", "ArrayList", "<", "WindowChangeListener", ">", "(", ")", ";", "private", "boolean", "mWindowsChanged", "=", "false", ";", "public", "interface", "WindowChangeListener", "{", "public", "void", "windowsChanged", "(", ")", ";", "public", "void", "focusChanged", "(", ")", ";", "}", "final", "Configuration", "mTempConfiguration", "=", "new", "Configuration", "(", ")", ";", "float", "mCompatibleScreenScale", ";", "public", "static", "WindowManagerService", "main", "(", "Context", "context", ",", "PowerManagerService", "pm", ",", "boolean", "haveInputMethods", ",", "boolean", "allowBootMsgs", ")", "{", "WMThread", "thr", "=", "new", "WMThread", "(", "context", ",", "pm", ",", "haveInputMethods", ",", "allowBootMsgs", ")", ";", "thr", ".", "start", "(", ")", ";", "synchronized", "(", "thr", ")", "{", "while", "(", "thr", ".", "mService", "==", "null", ")", "{", "try", "{", "thr", ".", "wait", "(", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "}", "return", "thr", ".", "mService", ";", "}", "}", "static", "class", "WMThread", "extends", "Thread", "{", "WindowManagerService", "mService", ";", "private", "final", "Context", "mContext", ";", "private", "final", "PowerManagerService", "mPM", ";", "private", "final", "boolean", "mHaveInputMethods", ";", "private", "final", "boolean", "mAllowBootMessages", ";", "public", "WMThread", "(", "Context", "context", ",", "PowerManagerService", "pm", ",", "boolean", "haveInputMethods", ",", "boolean", "allowBootMsgs", ")", "{", "super", "(", "\"\"", ")", ";", "mContext", "=", "context", ";", "mPM", "=", "pm", ";", "mHaveInputMethods", "=", "haveInputMethods", ";", "mAllowBootMessages", "=", "allowBootMsgs", ";", "}", "public", "void", "run", "(", ")", "{", "Looper", ".", "prepare", "(", ")", ";", "WindowManagerService", "s", "=", "new", "WindowManagerService", "(", "mContext", ",", "mPM", ",", "mHaveInputMethods", ",", "mAllowBootMessages", ")", ";", "android", ".", "os", ".", "Process", ".", "setThreadPriority", "(", "android", ".", "os", ".", "Process", ".", "THREAD_PRIORITY_DISPLAY", ")", ";", "android", ".", "os", ".", "Process", ".", "setCanSelfBackground", "(", "false", ")", ";", "synchronized", "(", "this", ")", "{", "mService", "=", "s", ";", "notifyAll", "(", ")", ";", "}", "if", "(", "StrictMode", ".", "conditionallyEnableDebugLogging", "(", ")", ")", "{", "Slog", ".", "i", "(", "TAG", ",", "\"\"", ")", ";", "}", "Looper", ".", "loop", "(", ")", ";", "}", "}", "static", "class", "PolicyThread", "extends", "Thread", "{", "private", "final", "WindowManagerPolicy", "mPolicy", ";", "private", "final", "WindowManagerService", "mService", ";", "private", "final", "Context", "mContext", ";", "private", "final", "PowerManagerService", "mPM", ";", "boolean", "mRunning", "=", "false", ";", "public", "PolicyThread", "(", "WindowManagerPolicy", "policy", ",", "WindowManagerService", "service", ",", "Context", "context", ",", "PowerManagerService", "pm", ")", "{", "super", "(", "\"\"", ")", ";", "mPolicy", "=", "policy", ";", "mService", "=", "service", ";", "mContext", "=", "context", ";", "mPM", "=", "pm", ";", "}", "public", "void", "run", "(", ")", "{", "Looper", ".", "prepare", "(", ")", ";", "WindowManagerPolicyThread", ".", "set", "(", "this", ",", "Looper", ".", "myLooper", "(", ")", ")", ";", "android", ".", "os", ".", "Process", ".", "setThreadPriority", "(", "android", ".", "os", ".", "Process", ".", "THREAD_PRIORITY_FOREGROUND", ")", ";", "android", ".", "os", ".", "Process", ".", "setCanSelfBackground", "(", "false", ")", ";", "mPolicy", ".", "init", "(", "mContext", ",", "mService", ",", "mService", ",", "mPM", ")", ";", "synchronized", "(", "this", ")", "{", "mRunning", "=", "true", ";", "notifyAll", "(", ")", ";", "}", "if", "(", "StrictMode", ".", "conditionallyEnableDebugLogging", "(", ")", ")", "{", "Slog", ".", "i", "(", "TAG", ",", "\"\"", ")", ";", "}", "Looper", ".", "loop", "(", ")", ";", "}", "}", "private", "WindowManagerService", "(", "Context", "context", ",", "PowerManagerService", "pm", ",", "boolean", "haveInputMethods", ",", "boolean", "showBootMsgs", ")", "{", "mContext", "=", "context", ";", "mHaveInputMethods", "=", "haveInputMethods", ";", "mAllowBootMessages", "=", "showBootMsgs", ";", "mLimitedAlphaCompositing", "=", "context", ".", "getResources", "(", ")", ".", "getBoolean", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "bool", ".", "config_sf_limitedAlpha", ")", ";", "mSetLandscapeProperty", "=", "context", ".", "getResources", "(", ")", ".", "getBoolean", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "bool", ".", "config_setLandscapeProp", ")", ";", "mPowerManager", "=", "pm", ";", "mPowerManager", ".", "setPolicy", "(", "mPolicy", ")", ";", "PowerManager", "pmc", "=", "(", "PowerManager", ")", "context", ".", "getSystemService", "(", "Context", ".", "POWER_SERVICE", ")", ";", "mScreenFrozenLock", "=", "pmc", ".", "newWakeLock", "(", "PowerManager", ".", "PARTIAL_WAKE_LOCK", ",", "\"\"", ")", ";", "mScreenFrozenLock", ".", "setReferenceCounted", "(", "false", ")", ";", "mActivityManager", "=", "ActivityManagerNative", ".", "getDefault", "(", ")", ";", "mBatteryStats", "=", "BatteryStatsService", ".", "getService", "(", ")", ";", "mWindowAnimationScale", "=", "Settings", ".", "System", ".", "getFloat", "(", "context", ".", "getContentResolver", "(", ")", ",", "Settings", ".", "System", ".", "WINDOW_ANIMATION_SCALE", ",", "mWindowAnimationScale", ")", ";", "mTransitionAnimationScale", "=", "Settings", ".", "System", ".", "getFloat", "(", "context", ".", "getContentResolver", "(", ")", ",", "Settings", ".", "System", ".", "TRANSITION_ANIMATION_SCALE", ",", "mTransitionAnimationScale", ")", ";", "IntentFilter", "filter", "=", "new", "IntentFilter", "(", ")", ";", "filter", ".", "addAction", "(", "DevicePolicyManager", ".", "ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED", ")", ";", "mContext", ".", "registerReceiver", "(", "mBroadcastReceiver", ",", "filter", ")", ";", "mHoldingScreenWakeLock", "=", "pmc", ".", "newWakeLock", "(", "PowerManager", ".", "SCREEN_BRIGHT_WAKE_LOCK", ",", "\"\"", ")", ";", "mHoldingScreenWakeLock", ".", "setReferenceCounted", "(", "false", ")", ";", "mInputManager", "=", "new", "InputManager", "(", "context", ",", "this", ")", ";", "mForceDisableHardwareKeyboard", "=", "context", ".", "getResources", "(", ")", ".", "getBoolean", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "bool", ".", "config_forceDisableHardwareKeyboard", ")", ";", "PolicyThread", "thr", "=", "new", "PolicyThread", "(", "mPolicy", ",", "this", ",", "context", ",", "pm", ")", ";", "thr", ".", "start", "(", ")", ";", "synchronized", "(", "thr", ")", "{", "while", "(", "!", "thr", ".", "mRunning", ")", "{", "try", "{", "thr", ".", "wait", "(", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "}", "}", "mInputManager", ".", "start", "(", ")", ";", "Watchdog", ".", "getInstance", "(", ")", ".", "addMonitor", "(", "this", ")", ";", "}", "@", "Override", "public", "boolean", "onTransact", "(", "int", "code", ",", "Parcel", "data", ",", "Parcel", "reply", ",", "int", "flags", ")", "throws", "RemoteException", "{", "try", "{", "return", "super", ".", "onTransact", "(", "code", ",", "data", ",", "reply", ",", "flags", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "if", "(", "!", "(", "e", "instanceof", "SecurityException", ")", ")", "{", "Log", ".", "wtf", "(", "TAG", ",", "\"\"", ",", "e", ")", ";", "}", "throw", "e", ";", "}", "}", "private", "void", "placeWindowAfter", "(", "WindowState", "pos", ",", "WindowState", "window", ")", "{", "final", "int", "i", "=", "mWindows", ".", "indexOf", "(", "pos", ")", ";", "if", "(", "DEBUG_FOCUS", "||", "DEBUG_WINDOW_MOVEMENT", "||", "DEBUG_ADD_REMOVE", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "window", "+", "\"", "at", "\"", "+", "(", "i", "+", "1", ")", "+", "\"", "of", "\"", "+", "mWindows", ".", "size", "(", ")", "+", "\"", "(after", "\"", "+", "pos", "+", "\")\"", ")", ";", "mWindows", ".", "add", "(", "i", "+", "1", ",", "window", ")", ";", "mWindowsChanged", "=", "true", ";", "}", "private", "void", "placeWindowBefore", "(", "WindowState", "pos", ",", "WindowState", "window", ")", "{", "final", "int", "i", "=", "mWindows", ".", "indexOf", "(", "pos", ")", ";", "if", "(", "DEBUG_FOCUS", "||", "DEBUG_WINDOW_MOVEMENT", "||", "DEBUG_ADD_REMOVE", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "window", "+", "\"", "at", "\"", "+", "i", "+", "\"", "of", "\"", "+", "mWindows", ".", "size", "(", ")", "+", "\"", "(before", "\"", "+", "pos", "+", "\")\"", ")", ";", "mWindows", ".", "add", "(", "i", ",", "window", ")", ";", "mWindowsChanged", "=", "true", ";", "}", "private", "int", "findIdxBasedOnAppTokens", "(", "WindowState", "win", ")", "{", "ArrayList", "<", "WindowState", ">", "localmWindows", "=", "mWindows", ";", "int", "jmax", "=", "localmWindows", ".", "size", "(", ")", ";", "if", "(", "jmax", "==", "0", ")", "{", "return", "-", "1", ";", "}", "for", "(", "int", "j", "=", "(", "jmax", "-", "1", ")", ";", "j", ">=", "0", ";", "j", "--", ")", "{", "WindowState", "wentry", "=", "localmWindows", ".", "get", "(", "j", ")", ";", "if", "(", "wentry", ".", "mAppToken", "==", "win", ".", "mAppToken", ")", "{", "return", "j", ";", "}", "}", "return", "-", "1", ";", "}", "private", "void", "addWindowToListInOrderLocked", "(", "WindowState", "win", ",", "boolean", "addToToken", ")", "{", "final", "IWindow", "client", "=", "win", ".", "mClient", ";", "final", "WindowToken", "token", "=", "win", ".", "mToken", ";", "final", "ArrayList", "<", "WindowState", ">", "localmWindows", "=", "mWindows", ";", "final", "int", "N", "=", "localmWindows", ".", "size", "(", ")", ";", "final", "WindowState", "attached", "=", "win", ".", "mAttachedWindow", ";", "int", "i", ";", "if", "(", "attached", "==", "null", ")", "{", "int", "tokenWindowsPos", "=", "token", ".", "windows", ".", "size", "(", ")", ";", "if", "(", "token", ".", "appWindowToken", "!=", "null", ")", "{", "int", "index", "=", "tokenWindowsPos", "-", "1", ";", "if", "(", "index", ">=", "0", ")", "{", "if", "(", "win", ".", "mAttrs", ".", "type", "==", "TYPE_BASE_APPLICATION", ")", "{", "placeWindowBefore", "(", "token", ".", "windows", ".", "get", "(", "0", ")", ",", "win", ")", ";", "tokenWindowsPos", "=", "0", ";", "}", "else", "{", "AppWindowToken", "atoken", "=", "win", ".", "mAppToken", ";", "if", "(", "atoken", "!=", "null", "&&", "token", ".", "windows", ".", "get", "(", "index", ")", "==", "atoken", ".", "startingWindow", ")", "{", "placeWindowBefore", "(", "token", ".", "windows", ".", "get", "(", "index", ")", ",", "win", ")", ";", "tokenWindowsPos", "--", ";", "}", "else", "{", "int", "newIdx", "=", "findIdxBasedOnAppTokens", "(", "win", ")", ";", "if", "(", "newIdx", "!=", "-", "1", ")", "{", "if", "(", "DEBUG_FOCUS", "||", "DEBUG_WINDOW_MOVEMENT", "||", "DEBUG_ADD_REMOVE", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "win", "+", "\"", "at", "\"", "+", "(", "newIdx", "+", "1", ")", "+", "\"", "of", "\"", "+", "N", ")", ";", "}", "localmWindows", ".", "add", "(", "newIdx", "+", "1", ",", "win", ")", ";", "mWindowsChanged", "=", "true", ";", "}", "}", "}", "}", "else", "{", "if", "(", "localLOGV", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "client", ".", "asBinder", "(", ")", "+", "\"", "(token=\"", "+", "token", "+", "\")\"", ")", ";", "final", "int", "NA", "=", "mAppTokens", ".", "size", "(", ")", ";", "WindowState", "pos", "=", "null", ";", "for", "(", "i", "=", "NA", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "AppWindowToken", "t", "=", "mAppTokens", ".", "get", "(", "i", ")", ";", "if", "(", "t", "==", "token", ")", "{", "i", "--", ";", "break", ";", "}", "if", "(", "!", "t", ".", "sendingToBottom", "&&", "t", ".", "windows", ".", "size", "(", ")", ">", "0", ")", "{", "pos", "=", "t", ".", "windows", ".", "get", "(", "0", ")", ";", "}", "}", "if", "(", "pos", "!=", "null", ")", "{", "WindowToken", "atoken", "=", "mTokenMap", ".", "get", "(", "pos", ".", "mClient", ".", "asBinder", "(", ")", ")", ";", "if", "(", "atoken", "!=", "null", ")", "{", "final", "int", "NC", "=", "atoken", ".", "windows", ".", "size", "(", ")", ";", "if", "(", "NC", ">", "0", ")", "{", "WindowState", "bottom", "=", "atoken", ".", "windows", ".", "get", "(", "0", ")", ";", "if", "(", "bottom", ".", "mSubLayer", "<", "0", ")", "{", "pos", "=", "bottom", ";", "}", "}", "}", "placeWindowBefore", "(", "pos", ",", "win", ")", ";", "}", "else", "{", "while", "(", "i", ">=", "0", ")", "{", "AppWindowToken", "t", "=", "mAppTokens", ".", "get", "(", "i", ")", ";", "final", "int", "NW", "=", "t", ".", "windows", ".", "size", "(", ")", ";", "if", "(", "NW", ">", "0", ")", "{", "pos", "=", "t", ".", "windows", ".", "get", "(", "NW", "-", "1", ")", ";", "break", ";", "}", "i", "--", ";", "}", "if", "(", "pos", "!=", "null", ")", "{", "WindowToken", "atoken", "=", "mTokenMap", ".", "get", "(", "pos", ".", "mClient", ".", "asBinder", "(", ")", ")", ";", "if", "(", "atoken", "!=", "null", ")", "{", "final", "int", "NC", "=", "atoken", ".", "windows", ".", "size", "(", ")", ";", "if", "(", "NC", ">", "0", ")", "{", "WindowState", "top", "=", "atoken", ".", "windows", ".", "get", "(", "NC", "-", "1", ")", ";", "if", "(", "top", ".", "mSubLayer", ">=", "0", ")", "{", "pos", "=", "top", ";", "}", "}", "}", "placeWindowAfter", "(", "pos", ",", "win", ")", ";", "}", "else", "{", "final", "int", "myLayer", "=", "win", ".", "mBaseLayer", ";", "for", "(", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "WindowState", "w", "=", "localmWindows", ".", "get", "(", "i", ")", ";", "if", "(", "w", ".", "mBaseLayer", ">", "myLayer", ")", "{", "break", ";", "}", "}", "if", "(", "DEBUG_FOCUS", "||", "DEBUG_WINDOW_MOVEMENT", "||", "DEBUG_ADD_REMOVE", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "win", "+", "\"", "at", "\"", "+", "i", "+", "\"", "of", "\"", "+", "N", ")", ";", "}", "localmWindows", ".", "add", "(", "i", ",", "win", ")", ";", "mWindowsChanged", "=", "true", ";", "}", "}", "}", "}", "else", "{", "final", "int", "myLayer", "=", "win", ".", "mBaseLayer", ";", "for", "(", "i", "=", "N", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "localmWindows", ".", "get", "(", "i", ")", ".", "mBaseLayer", "<=", "myLayer", ")", "{", "i", "++", ";", "break", ";", "}", "}", "if", "(", "i", "<", "0", ")", "i", "=", "0", ";", "if", "(", "DEBUG_FOCUS", "||", "DEBUG_WINDOW_MOVEMENT", "||", "DEBUG_ADD_REMOVE", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "win", "+", "\"", "at", "\"", "+", "i", "+", "\"", "of", "\"", "+", "N", ")", ";", "localmWindows", ".", "add", "(", "i", ",", "win", ")", ";", "mWindowsChanged", "=", "true", ";", "}", "if", "(", "addToToken", ")", "{", "if", "(", "DEBUG_ADD_REMOVE", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Adding", "\"", "+", "win", "+", "\"", "to", "\"", "+", "token", ")", ";", "token", ".", "windows", ".", "add", "(", "tokenWindowsPos", ",", "win", ")", ";", "}", "}", "else", "{", "final", "int", "NA", "=", "token", ".", "windows", ".", "size", "(", ")", ";", "final", "int", "sublayer", "=", "win", ".", "mSubLayer", ";", "int", "largestSublayer", "=", "Integer", ".", "MIN_VALUE", ";", "WindowState", "windowWithLargestSublayer", "=", "null", ";", "for", "(", "i", "=", "0", ";", "i", "<", "NA", ";", "i", "++", ")", "{", "WindowState", "w", "=", "token", ".", "windows", ".", "get", "(", "i", ")", ";", "final", "int", "wSublayer", "=", "w", ".", "mSubLayer", ";", "if", "(", "wSublayer", ">=", "largestSublayer", ")", "{", "largestSublayer", "=", "wSublayer", ";", "windowWithLargestSublayer", "=", "w", ";", "}", "if", "(", "sublayer", "<", "0", ")", "{", "if", "(", "wSublayer", ">=", "sublayer", ")", "{", "if", "(", "addToToken", ")", "{", "if", "(", "DEBUG_ADD_REMOVE", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Adding", "\"", "+", "win", "+", "\"", "to", "\"", "+", "token", ")", ";", "token", ".", "windows", ".", "add", "(", "i", ",", "win", ")", ";", "}", "placeWindowBefore", "(", "wSublayer", ">=", "0", "?", "attached", ":", "w", ",", "win", ")", ";", "break", ";", "}", "}", "else", "{", "if", "(", "wSublayer", ">", "sublayer", ")", "{", "if", "(", "addToToken", ")", "{", "if", "(", "DEBUG_ADD_REMOVE", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Adding", "\"", "+", "win", "+", "\"", "to", "\"", "+", "token", ")", ";", "token", ".", "windows", ".", "add", "(", "i", ",", "win", ")", ";", "}", "placeWindowBefore", "(", "w", ",", "win", ")", ";", "break", ";", "}", "}", "}", "if", "(", "i", ">=", "NA", ")", "{", "if", "(", "addToToken", ")", "{", "if", "(", "DEBUG_ADD_REMOVE", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Adding", "\"", "+", "win", "+", "\"", "to", "\"", "+", "token", ")", ";", "token", ".", "windows", ".", "add", "(", "win", ")", ";", "}", "if", "(", "sublayer", "<", "0", ")", "{", "placeWindowBefore", "(", "attached", ",", "win", ")", ";", "}", "else", "{", "placeWindowAfter", "(", "largestSublayer", ">=", "0", "?", "windowWithLargestSublayer", ":", "attached", ",", "win", ")", ";", "}", "}", "}", "if", "(", "win", ".", "mAppToken", "!=", "null", "&&", "addToToken", ")", "{", "win", ".", "mAppToken", ".", "allAppWindows", ".", "add", "(", "win", ")", ";", "}", "}", "static", "boolean", "canBeImeTarget", "(", "WindowState", "w", ")", "{", "final", "int", "fl", "=", "w", ".", "mAttrs", ".", "flags", "&", "(", "FLAG_NOT_FOCUSABLE", "|", "FLAG_ALT_FOCUSABLE_IM", ")", ";", "if", "(", "fl", "==", "0", "||", "fl", "==", "(", "FLAG_NOT_FOCUSABLE", "|", "FLAG_ALT_FOCUSABLE_IM", ")", "||", "w", ".", "mAttrs", ".", "type", "==", "WindowManager", ".", "LayoutParams", ".", "TYPE_APPLICATION_STARTING", ")", "{", "if", "(", "DEBUG_INPUT_METHOD", ")", "{", "Slog", ".", "i", "(", "TAG", ",", "\"\"", "+", "w", "+", "\":", "\"", "+", "w", ".", "isVisibleOrAdding", "(", ")", ")", ";", "if", "(", "!", "w", ".", "isVisibleOrAdding", "(", ")", ")", "{", "Slog", ".", "i", "(", "TAG", ",", "\"", "mSurface=\"", "+", "w", ".", "mSurface", "+", "\"\"", "+", "w", ".", "mReportDestroySurface", "+", "\"\"", "+", "w", ".", "mRelayoutCalled", "+", "\"", "viewVis=\"", "+", "w", ".", "mViewVisibility", "+", "\"", "policyVis=\"", "+", "w", ".", "mPolicyVisibility", "+", "\"", "attachHid=\"", "+", "w", ".", "mAttachedHidden", "+", "\"", "exiting=\"", "+", "w", ".", "mExiting", "+", "\"", "destroying=\"", "+", "w", ".", "mDestroying", ")", ";", "if", "(", "w", ".", "mAppToken", "!=", "null", ")", "{", "Slog", ".", "i", "(", "TAG", ",", "\"\"", "+", "w", ".", "mAppToken", ".", "hiddenRequested", ")", ";", "}", "}", "}", "return", "w", ".", "isVisibleOrAdding", "(", ")", ";", "}", "return", "false", ";", "}", "int", "findDesiredInputMethodWindowIndexLocked", "(", "boolean", "willMove", ")", "{", "final", "ArrayList", "<", "WindowState", ">", "localmWindows", "=", "mWindows", ";", "final", "int", "N", "=", "localmWindows", ".", "size", "(", ")", ";", "WindowState", "w", "=", "null", ";", "int", "i", "=", "N", ";", "while", "(", "i", ">", "0", ")", "{", "i", "--", ";", "w", "=", "localmWindows", ".", "get", "(", "i", ")", ";", "if", "(", "DEBUG_INPUT_METHOD", "&&", "willMove", ")", "Slog", ".", "i", "(", "TAG", ",", "\"\"", "+", "i", "+", "\"", "\"", "+", "w", "+", "\"", "fl=0x\"", "+", "Integer", ".", "toHexString", "(", "w", ".", "mAttrs", ".", "flags", ")", ")", ";", "if", "(", "canBeImeTarget", "(", "w", ")", ")", "{", "if", "(", "!", "willMove", "&&", "w", ".", "mAttrs", ".", "type", "==", "WindowManager", ".", "LayoutParams", ".", "TYPE_APPLICATION_STARTING", "&&", "i", ">", "0", ")", "{", "WindowState", "wb", "=", "localmWindows", ".", "get", "(", "i", "-", "1", ")", ";", "if", "(", "wb", ".", "mAppToken", "==", "w", ".", "mAppToken", "&&", "canBeImeTarget", "(", "wb", ")", ")", "{", "i", "--", ";", "w", "=", "wb", ";", "}", "}", "break", ";", "}", "}", "if", "(", "DEBUG_INPUT_METHOD", "&&", "willMove", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "w", ")", ";", "if", "(", "mInputMethodTarget", "!=", "null", "&&", "w", "!=", "null", "&&", "mInputMethodTarget", ".", "isDisplayedLw", "(", ")", "&&", "mInputMethodTarget", ".", "mExiting", ")", "{", "if", "(", "mInputMethodTarget", ".", "mAnimLayer", ">", "w", ".", "mAnimLayer", ")", "{", "w", "=", "mInputMethodTarget", ";", "i", "=", "localmWindows", ".", "indexOf", "(", "w", ")", ";", "if", "(", "DEBUG_INPUT_METHOD", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "w", ")", ";", "}", "}", "if", "(", "DEBUG_INPUT_METHOD", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "w", "+", "\"", "willMove=\"", "+", "willMove", ")", ";", "if", "(", "willMove", "&&", "w", "!=", "null", ")", "{", "final", "WindowState", "curTarget", "=", "mInputMethodTarget", ";", "if", "(", "curTarget", "!=", "null", "&&", "curTarget", ".", "mAppToken", "!=", "null", ")", "{", "AppWindowToken", "token", "=", "curTarget", ".", "mAppToken", ";", "WindowState", "highestTarget", "=", "null", ";", "int", "highestPos", "=", "0", ";", "if", "(", "token", ".", "animating", "||", "token", ".", "animation", "!=", "null", ")", "{", "int", "pos", "=", "0", ";", "pos", "=", "localmWindows", ".", "indexOf", "(", "curTarget", ")", ";", "while", "(", "pos", ">=", "0", ")", "{", "WindowState", "win", "=", "localmWindows", ".", "get", "(", "pos", ")", ";", "if", "(", "win", ".", "mAppToken", "!=", "token", ")", "{", "break", ";", "}", "if", "(", "!", "win", ".", "mRemoved", ")", "{", "if", "(", "highestTarget", "==", "null", "||", "win", ".", "mAnimLayer", ">", "highestTarget", ".", "mAnimLayer", ")", "{", "highestTarget", "=", "win", ";", "highestPos", "=", "pos", ";", "}", "}", "pos", "--", ";", "}", "}", "if", "(", "highestTarget", "!=", "null", ")", "{", "if", "(", "DEBUG_INPUT_METHOD", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "mNextAppTransition", "+", "\"", "\"", "+", "highestTarget", "+", "\"", "animating=\"", "+", "highestTarget", ".", "isAnimating", "(", ")", "+", "\"", "layer=\"", "+", "highestTarget", ".", "mAnimLayer", "+", "\"", "new", "layer=\"", "+", "w", ".", "mAnimLayer", ")", ";", "if", "(", "mNextAppTransition", "!=", "WindowManagerPolicy", ".", "TRANSIT_UNSET", ")", "{", "mInputMethodTargetWaitingAnim", "=", "true", ";", "mInputMethodTarget", "=", "highestTarget", ";", "return", "highestPos", "+", "1", ";", "}", "else", "if", "(", "highestTarget", ".", "isAnimating", "(", ")", "&&", "highestTarget", ".", "mAnimLayer", ">", "w", ".", "mAnimLayer", ")", "{", "mInputMethodTargetWaitingAnim", "=", "true", ";", "mInputMethodTarget", "=", "highestTarget", ";", "return", "highestPos", "+", "1", ";", "}", "}", "}", "}", "if", "(", "w", "!=", "null", ")", "{", "if", "(", "willMove", ")", "{", "if", "(", "DEBUG_INPUT_METHOD", ")", "{", "RuntimeException", "e", "=", "null", ";", "if", "(", "!", "HIDE_STACK_CRAWLS", ")", "{", "e", "=", "new", "RuntimeException", "(", ")", ";", "e", ".", "fillInStackTrace", "(", ")", ";", "}", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "mInputMethodTarget", "+", "\"", "to", "\"", "+", "w", ",", "e", ")", ";", "}", "mInputMethodTarget", "=", "w", ";", "mInputMethodTargetWaitingAnim", "=", "false", ";", "if", "(", "w", ".", "mAppToken", "!=", "null", ")", "{", "setInputMethodAnimLayerAdjustment", "(", "w", ".", "mAppToken", ".", "animLayerAdjustment", ")", ";", "}", "else", "{", "setInputMethodAnimLayerAdjustment", "(", "0", ")", ";", "}", "}", "return", "i", "+", "1", ";", "}", "if", "(", "willMove", ")", "{", "if", "(", "DEBUG_INPUT_METHOD", ")", "{", "RuntimeException", "e", "=", "null", ";", "if", "(", "!", "HIDE_STACK_CRAWLS", ")", "{", "e", "=", "new", "RuntimeException", "(", ")", ";", "e", ".", "fillInStackTrace", "(", ")", ";", "}", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "mInputMethodTarget", "+", "\"", "to", "null\"", ",", "e", ")", ";", "}", "mInputMethodTarget", "=", "null", ";", "setInputMethodAnimLayerAdjustment", "(", "0", ")", ";", "}", "return", "-", "1", ";", "}", "void", "addInputMethodWindowToListLocked", "(", "WindowState", "win", ")", "{", "int", "pos", "=", "findDesiredInputMethodWindowIndexLocked", "(", "true", ")", ";", "if", "(", "pos", ">=", "0", ")", "{", "win", ".", "mTargetAppToken", "=", "mInputMethodTarget", ".", "mAppToken", ";", "if", "(", "DEBUG_WINDOW_MOVEMENT", "||", "DEBUG_ADD_REMOVE", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "win", "+", "\"", "at", "\"", "+", "pos", ")", ";", "mWindows", ".", "add", "(", "pos", ",", "win", ")", ";", "mWindowsChanged", "=", "true", ";", "moveInputMethodDialogsLocked", "(", "pos", "+", "1", ")", ";", "return", ";", "}", "win", ".", "mTargetAppToken", "=", "null", ";", "addWindowToListInOrderLocked", "(", "win", ",", "true", ")", ";", "moveInputMethodDialogsLocked", "(", "pos", ")", ";", "}", "void", "setInputMethodAnimLayerAdjustment", "(", "int", "adj", ")", "{", "if", "(", "DEBUG_LAYERS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "adj", ")", ";", "mInputMethodAnimLayerAdjustment", "=", "adj", ";", "WindowState", "imw", "=", "mInputMethodWindow", ";", "if", "(", "imw", "!=", "null", ")", "{", "imw", ".", "mAnimLayer", "=", "imw", ".", "mLayer", "+", "adj", ";", "if", "(", "DEBUG_LAYERS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"IM", "win", "\"", "+", "imw", "+", "\"\"", "+", "imw", ".", "mAnimLayer", ")", ";", "int", "wi", "=", "imw", ".", "mChildWindows", ".", "size", "(", ")", ";", "while", "(", "wi", ">", "0", ")", "{", "wi", "--", ";", "WindowState", "cw", "=", "imw", ".", "mChildWindows", ".", "get", "(", "wi", ")", ";", "cw", ".", "mAnimLayer", "=", "cw", ".", "mLayer", "+", "adj", ";", "if", "(", "DEBUG_LAYERS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"IM", "win", "\"", "+", "cw", "+", "\"\"", "+", "cw", ".", "mAnimLayer", ")", ";", "}", "}", "int", "di", "=", "mInputMethodDialogs", ".", "size", "(", ")", ";", "while", "(", "di", ">", "0", ")", "{", "di", "--", ";", "imw", "=", "mInputMethodDialogs", ".", "get", "(", "di", ")", ";", "imw", ".", "mAnimLayer", "=", "imw", ".", "mLayer", "+", "adj", ";", "if", "(", "DEBUG_LAYERS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"IM", "win", "\"", "+", "imw", "+", "\"\"", "+", "imw", ".", "mAnimLayer", ")", ";", "}", "}", "private", "int", "tmpRemoveWindowLocked", "(", "int", "interestingPos", ",", "WindowState", "win", ")", "{", "int", "wpos", "=", "mWindows", ".", "indexOf", "(", "win", ")", ";", "if", "(", "wpos", ">=", "0", ")", "{", "if", "(", "wpos", "<", "interestingPos", ")", "interestingPos", "--", ";", "if", "(", "DEBUG_WINDOW_MOVEMENT", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wpos", "+", "\":", "\"", "+", "win", ")", ";", "mWindows", ".", "remove", "(", "wpos", ")", ";", "mWindowsChanged", "=", "true", ";", "int", "NC", "=", "win", ".", "mChildWindows", ".", "size", "(", ")", ";", "while", "(", "NC", ">", "0", ")", "{", "NC", "--", ";", "WindowState", "cw", "=", "win", ".", "mChildWindows", ".", "get", "(", "NC", ")", ";", "int", "cpos", "=", "mWindows", ".", "indexOf", "(", "cw", ")", ";", "if", "(", "cpos", ">=", "0", ")", "{", "if", "(", "cpos", "<", "interestingPos", ")", "interestingPos", "--", ";", "if", "(", "DEBUG_WINDOW_MOVEMENT", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "cpos", "+", "\":", "\"", "+", "cw", ")", ";", "mWindows", ".", "remove", "(", "cpos", ")", ";", "}", "}", "}", "return", "interestingPos", ";", "}", "private", "void", "reAddWindowToListInOrderLocked", "(", "WindowState", "win", ")", "{", "addWindowToListInOrderLocked", "(", "win", ",", "false", ")", ";", "int", "wpos", "=", "mWindows", ".", "indexOf", "(", "win", ")", ";", "if", "(", "wpos", ">=", "0", ")", "{", "if", "(", "DEBUG_WINDOW_MOVEMENT", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wpos", "+", "\":", "\"", "+", "win", ")", ";", "mWindows", ".", "remove", "(", "wpos", ")", ";", "mWindowsChanged", "=", "true", ";", "reAddWindowLocked", "(", "wpos", ",", "win", ")", ";", "}", "}", "void", "logWindowList", "(", "String", "prefix", ")", "{", "int", "N", "=", "mWindows", ".", "size", "(", ")", ";", "while", "(", "N", ">", "0", ")", "{", "N", "--", ";", "Slog", ".", "v", "(", "TAG", ",", "prefix", "+", "\"#\"", "+", "N", "+", "\":", "\"", "+", "mWindows", ".", "get", "(", "N", ")", ")", ";", "}", "}", "void", "moveInputMethodDialogsLocked", "(", "int", "pos", ")", "{", "ArrayList", "<", "WindowState", ">", "dialogs", "=", "mInputMethodDialogs", ";", "final", "int", "N", "=", "dialogs", ".", "size", "(", ")", ";", "if", "(", "DEBUG_INPUT_METHOD", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Removing", "\"", "+", "N", "+", "\"\"", "+", "pos", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "pos", "=", "tmpRemoveWindowLocked", "(", "pos", ",", "dialogs", ".", "get", "(", "i", ")", ")", ";", "}", "if", "(", "DEBUG_INPUT_METHOD", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "pos", ")", ";", "logWindowList", "(", "\"", "\"", ")", ";", "}", "if", "(", "pos", ">=", "0", ")", "{", "final", "AppWindowToken", "targetAppToken", "=", "mInputMethodTarget", ".", "mAppToken", ";", "if", "(", "pos", "<", "mWindows", ".", "size", "(", ")", ")", "{", "WindowState", "wp", "=", "mWindows", ".", "get", "(", "pos", ")", ";", "if", "(", "wp", "==", "mInputMethodWindow", ")", "{", "pos", "++", ";", "}", "}", "if", "(", "DEBUG_INPUT_METHOD", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Adding", "\"", "+", "N", "+", "\"\"", "+", "pos", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "WindowState", "win", "=", "dialogs", ".", "get", "(", "i", ")", ";", "win", ".", "mTargetAppToken", "=", "targetAppToken", ";", "pos", "=", "reAddWindowLocked", "(", "pos", ",", "win", ")", ";", "}", "if", "(", "DEBUG_INPUT_METHOD", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "logWindowList", "(", "\"", "\"", ")", ";", "}", "return", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "WindowState", "win", "=", "dialogs", ".", "get", "(", "i", ")", ";", "win", ".", "mTargetAppToken", "=", "null", ";", "reAddWindowToListInOrderLocked", "(", "win", ")", ";", "if", "(", "DEBUG_INPUT_METHOD", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "logWindowList", "(", "\"", "\"", ")", ";", "}", "}", "}", "boolean", "moveInputMethodWindowsIfNeededLocked", "(", "boolean", "needAssignLayers", ")", "{", "final", "WindowState", "imWin", "=", "mInputMethodWindow", ";", "final", "int", "DN", "=", "mInputMethodDialogs", ".", "size", "(", ")", ";", "if", "(", "imWin", "==", "null", "&&", "DN", "==", "0", ")", "{", "return", "false", ";", "}", "int", "imPos", "=", "findDesiredInputMethodWindowIndexLocked", "(", "true", ")", ";", "if", "(", "imPos", ">=", "0", ")", "{", "final", "int", "N", "=", "mWindows", ".", "size", "(", ")", ";", "WindowState", "firstImWin", "=", "imPos", "<", "N", "?", "mWindows", ".", "get", "(", "imPos", ")", ":", "null", ";", "WindowState", "baseImWin", "=", "imWin", "!=", "null", "?", "imWin", ":", "mInputMethodDialogs", ".", "get", "(", "0", ")", ";", "if", "(", "baseImWin", ".", "mChildWindows", ".", "size", "(", ")", ">", "0", ")", "{", "WindowState", "cw", "=", "baseImWin", ".", "mChildWindows", ".", "get", "(", "0", ")", ";", "if", "(", "cw", ".", "mSubLayer", "<", "0", ")", "baseImWin", "=", "cw", ";", "}", "if", "(", "firstImWin", "==", "baseImWin", ")", "{", "int", "pos", "=", "imPos", "+", "1", ";", "while", "(", "pos", "<", "N", ")", "{", "if", "(", "!", "(", "mWindows", ".", "get", "(", "pos", ")", ")", ".", "mIsImWindow", ")", "{", "break", ";", "}", "pos", "++", ";", "}", "pos", "++", ";", "while", "(", "pos", "<", "N", ")", "{", "if", "(", "(", "mWindows", ".", "get", "(", "pos", ")", ")", ".", "mIsImWindow", ")", "{", "break", ";", "}", "pos", "++", ";", "}", "if", "(", "pos", ">=", "N", ")", "{", "return", "false", ";", "}", "}", "if", "(", "imWin", "!=", "null", ")", "{", "if", "(", "DEBUG_INPUT_METHOD", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "imPos", ")", ";", "logWindowList", "(", "\"", "\"", ")", ";", "}", "imPos", "=", "tmpRemoveWindowLocked", "(", "imPos", ",", "imWin", ")", ";", "if", "(", "DEBUG_INPUT_METHOD", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "imPos", "+", "\":\"", ")", ";", "logWindowList", "(", "\"", "\"", ")", ";", "}", "imWin", ".", "mTargetAppToken", "=", "mInputMethodTarget", ".", "mAppToken", ";", "reAddWindowLocked", "(", "imPos", ",", "imWin", ")", ";", "if", "(", "DEBUG_INPUT_METHOD", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "imPos", "+", "\":\"", ")", ";", "logWindowList", "(", "\"", "\"", ")", ";", "}", "if", "(", "DN", ">", "0", ")", "moveInputMethodDialogsLocked", "(", "imPos", "+", "1", ")", ";", "}", "else", "{", "moveInputMethodDialogsLocked", "(", "imPos", ")", ";", "}", "}", "else", "{", "if", "(", "imWin", "!=", "null", ")", "{", "if", "(", "DEBUG_INPUT_METHOD", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "imPos", ")", ";", "tmpRemoveWindowLocked", "(", "0", ",", "imWin", ")", ";", "imWin", ".", "mTargetAppToken", "=", "null", ";", "reAddWindowToListInOrderLocked", "(", "imWin", ")", ";", "if", "(", "DEBUG_INPUT_METHOD", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "logWindowList", "(", "\"", "\"", ")", ";", "}", "if", "(", "DN", ">", "0", ")", "moveInputMethodDialogsLocked", "(", "-", "1", ")", ";", ";", "}", "else", "{", "moveInputMethodDialogsLocked", "(", "-", "1", ")", ";", ";", "}", "}", "if", "(", "needAssignLayers", ")", "{", "assignLayersLocked", "(", ")", ";", "}", "return", "true", ";", "}", "void", "adjustInputMethodDialogsLocked", "(", ")", "{", "moveInputMethodDialogsLocked", "(", "findDesiredInputMethodWindowIndexLocked", "(", "true", ")", ")", ";", "}", "final", "boolean", "isWallpaperVisible", "(", "WindowState", "wallpaperTarget", ")", "{", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "(", "wallpaperTarget", "!=", "null", "?", "Boolean", ".", "toString", "(", "wallpaperTarget", ".", "mObscured", ")", ":", "\"??\"", ")", "+", "\"", "anim=\"", "+", "(", "(", "wallpaperTarget", "!=", "null", "&&", "wallpaperTarget", ".", "mAppToken", "!=", "null", ")", "?", "wallpaperTarget", ".", "mAppToken", ".", "animation", ":", "null", ")", "+", "\"", "upper=\"", "+", "mUpperWallpaperTarget", "+", "\"", "lower=\"", "+", "mLowerWallpaperTarget", ")", ";", "return", "(", "wallpaperTarget", "!=", "null", "&&", "(", "!", "wallpaperTarget", ".", "mObscured", "||", "(", "wallpaperTarget", ".", "mAppToken", "!=", "null", "&&", "wallpaperTarget", ".", "mAppToken", ".", "animation", "!=", "null", ")", ")", ")", "||", "mUpperWallpaperTarget", "!=", "null", "||", "mLowerWallpaperTarget", "!=", "null", ";", "}", "static", "final", "int", "ADJUST_WALLPAPER_LAYERS_CHANGED", "=", "1", "<<", "1", ";", "static", "final", "int", "ADJUST_WALLPAPER_VISIBILITY_CHANGED", "=", "1", "<<", "2", ";", "int", "adjustWallpaperWindowsLocked", "(", ")", "{", "int", "changed", "=", "0", ";", "final", "int", "dw", "=", "mAppDisplayWidth", ";", "final", "int", "dh", "=", "mAppDisplayHeight", ";", "final", "ArrayList", "<", "WindowState", ">", "localmWindows", "=", "mWindows", ";", "int", "N", "=", "localmWindows", ".", "size", "(", ")", ";", "WindowState", "w", "=", "null", ";", "WindowState", "foundW", "=", "null", ";", "int", "foundI", "=", "0", ";", "WindowState", "topCurW", "=", "null", ";", "int", "topCurI", "=", "0", ";", "int", "windowDetachedI", "=", "-", "1", ";", "int", "i", "=", "N", ";", "while", "(", "i", ">", "0", ")", "{", "i", "--", ";", "w", "=", "localmWindows", ".", "get", "(", "i", ")", ";", "if", "(", "(", "w", ".", "mAttrs", ".", "type", "==", "WindowManager", ".", "LayoutParams", ".", "TYPE_WALLPAPER", ")", ")", "{", "if", "(", "topCurW", "==", "null", ")", "{", "topCurW", "=", "w", ";", "topCurI", "=", "i", ";", "}", "continue", ";", "}", "topCurW", "=", "null", ";", "if", "(", "w", "!=", "mWindowDetachedWallpaper", "&&", "w", ".", "mAppToken", "!=", "null", ")", "{", "if", "(", "w", ".", "mAppToken", ".", "hidden", "&&", "w", ".", "mAppToken", ".", "animation", "==", "null", ")", "{", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "w", ")", ";", "continue", ";", "}", "}", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Win", "\"", "+", "w", "+", "\"\"", "+", "w", ".", "isReadyForDisplay", "(", ")", "+", "\"\"", "+", "w", ".", "mDrawPending", "+", "\"\"", "+", "w", ".", "mCommitDrawPending", ")", ";", "if", "(", "(", "w", ".", "mAttrs", ".", "flags", "&", "FLAG_SHOW_WALLPAPER", ")", "!=", "0", "&&", "w", ".", "isReadyForDisplay", "(", ")", "&&", "(", "mWallpaperTarget", "==", "w", "||", "(", "!", "w", ".", "mDrawPending", "&&", "!", "w", ".", "mCommitDrawPending", ")", ")", ")", "{", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "i", "+", "\"=\"", "+", "w", ")", ";", "foundW", "=", "w", ";", "foundI", "=", "i", ";", "if", "(", "w", "==", "mWallpaperTarget", "&&", "(", "(", "w", ".", "mAppToken", "!=", "null", "&&", "w", ".", "mAppToken", ".", "animation", "!=", "null", ")", "||", "w", ".", "mAnimation", "!=", "null", ")", ")", "{", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Win", "\"", "+", "w", "+", "\"\"", ")", ";", "continue", ";", "}", "break", ";", "}", "else", "if", "(", "w", "==", "mWindowDetachedWallpaper", ")", "{", "windowDetachedI", "=", "i", ";", "}", "}", "if", "(", "foundW", "==", "null", "&&", "windowDetachedI", ">=", "0", ")", "{", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "i", "+", "\"=\"", "+", "w", ")", ";", "foundW", "=", "w", ";", "foundI", "=", "windowDetachedI", ";", "}", "if", "(", "mNextAppTransition", "!=", "WindowManagerPolicy", ".", "TRANSIT_UNSET", ")", "{", "if", "(", "mWallpaperTarget", "!=", "null", "&&", "mWallpaperTarget", ".", "mAppToken", "!=", "null", ")", "{", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "return", "0", ";", "}", "if", "(", "foundW", "!=", "null", "&&", "foundW", ".", "mAppToken", "!=", "null", ")", "{", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "return", "0", ";", "}", "}", "if", "(", "mWallpaperTarget", "!=", "foundW", ")", "{", "if", "(", "DEBUG_WALLPAPER", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "foundW", "+", "\"", "oldTarget:", "\"", "+", "mWallpaperTarget", ")", ";", "}", "mLowerWallpaperTarget", "=", "null", ";", "mUpperWallpaperTarget", "=", "null", ";", "WindowState", "oldW", "=", "mWallpaperTarget", ";", "mWallpaperTarget", "=", "foundW", ";", "if", "(", "foundW", "!=", "null", "&&", "oldW", "!=", "null", ")", "{", "boolean", "oldAnim", "=", "oldW", ".", "mAnimation", "!=", "null", "||", "(", "oldW", ".", "mAppToken", "!=", "null", "&&", "oldW", ".", "mAppToken", ".", "animation", "!=", "null", ")", ";", "boolean", "foundAnim", "=", "foundW", ".", "mAnimation", "!=", "null", "||", "(", "foundW", ".", "mAppToken", "!=", "null", "&&", "foundW", ".", "mAppToken", ".", "animation", "!=", "null", ")", ";", "if", "(", "DEBUG_WALLPAPER", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "foundAnim", "+", "\"\"", "+", "oldAnim", ")", ";", "}", "if", "(", "foundAnim", "&&", "oldAnim", ")", "{", "int", "oldI", "=", "localmWindows", ".", "indexOf", "(", "oldW", ")", ";", "if", "(", "DEBUG_WALLPAPER", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"New", "i:", "\"", "+", "foundI", "+", "\"", "old", "i:", "\"", "+", "oldI", ")", ";", "}", "if", "(", "oldI", ">=", "0", ")", "{", "if", "(", "DEBUG_WALLPAPER", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "oldI", "+", "\"=\"", "+", "oldW", "+", "\";", "new#\"", "+", "foundI", "+", "\"=\"", "+", "foundW", ")", ";", "}", "if", "(", "foundW", ".", "mAppToken", "!=", "null", "&&", "foundW", ".", "mAppToken", ".", "hiddenRequested", ")", "{", "if", "(", "DEBUG_WALLPAPER", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "}", "mWallpaperTarget", "=", "oldW", ";", "}", "if", "(", "foundI", ">", "oldI", ")", "{", "if", "(", "DEBUG_WALLPAPER", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "}", "mUpperWallpaperTarget", "=", "foundW", ";", "mLowerWallpaperTarget", "=", "oldW", ";", "foundW", "=", "oldW", ";", "foundI", "=", "oldI", ";", "}", "else", "{", "if", "(", "DEBUG_WALLPAPER", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "}", "mUpperWallpaperTarget", "=", "oldW", ";", "mLowerWallpaperTarget", "=", "foundW", ";", "}", "}", "}", "}", "}", "else", "if", "(", "mLowerWallpaperTarget", "!=", "null", ")", "{", "boolean", "lowerAnimating", "=", "mLowerWallpaperTarget", ".", "mAnimation", "!=", "null", "||", "(", "mLowerWallpaperTarget", ".", "mAppToken", "!=", "null", "&&", "mLowerWallpaperTarget", ".", "mAppToken", ".", "animation", "!=", "null", ")", ";", "boolean", "upperAnimating", "=", "mUpperWallpaperTarget", ".", "mAnimation", "!=", "null", "||", "(", "mUpperWallpaperTarget", ".", "mAppToken", "!=", "null", "&&", "mUpperWallpaperTarget", ".", "mAppToken", ".", "animation", "!=", "null", ")", ";", "if", "(", "!", "lowerAnimating", "||", "!", "upperAnimating", ")", "{", "if", "(", "DEBUG_WALLPAPER", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "}", "mLowerWallpaperTarget", "=", "null", ";", "mUpperWallpaperTarget", "=", "null", ";", "}", "}", "boolean", "visible", "=", "foundW", "!=", "null", ";", "if", "(", "visible", ")", "{", "visible", "=", "isWallpaperVisible", "(", "foundW", ")", ";", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "visible", ")", ";", "mWallpaperAnimLayerAdjustment", "=", "(", "mLowerWallpaperTarget", "==", "null", "&&", "foundW", ".", "mAppToken", "!=", "null", ")", "?", "foundW", ".", "mAppToken", ".", "animLayerAdjustment", ":", "0", ";", "final", "int", "maxLayer", "=", "mPolicy", ".", "getMaxWallpaperLayer", "(", ")", "*", "TYPE_LAYER_MULTIPLIER", "+", "TYPE_LAYER_OFFSET", ";", "while", "(", "foundI", ">", "0", ")", "{", "WindowState", "wb", "=", "localmWindows", ".", "get", "(", "foundI", "-", "1", ")", ";", "if", "(", "wb", ".", "mBaseLayer", "<", "maxLayer", "&&", "wb", ".", "mAttachedWindow", "!=", "foundW", "&&", "(", "foundW", ".", "mAttachedWindow", "==", "null", "||", "wb", ".", "mAttachedWindow", "!=", "foundW", ".", "mAttachedWindow", ")", "&&", "(", "wb", ".", "mAttrs", ".", "type", "!=", "TYPE_APPLICATION_STARTING", "||", "foundW", ".", "mToken", "==", "null", "||", "wb", ".", "mToken", "!=", "foundW", ".", "mToken", ")", ")", "{", "break", ";", "}", "foundW", "=", "wb", ";", "foundI", "--", ";", "}", "}", "else", "{", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "}", "if", "(", "foundW", "==", "null", "&&", "topCurW", "!=", "null", ")", "{", "foundW", "=", "topCurW", ";", "foundI", "=", "topCurI", "+", "1", ";", "}", "else", "{", "foundW", "=", "foundI", ">", "0", "?", "localmWindows", ".", "get", "(", "foundI", "-", "1", ")", ":", "null", ";", "}", "if", "(", "visible", ")", "{", "if", "(", "mWallpaperTarget", ".", "mWallpaperX", ">=", "0", ")", "{", "mLastWallpaperX", "=", "mWallpaperTarget", ".", "mWallpaperX", ";", "mLastWallpaperXStep", "=", "mWallpaperTarget", ".", "mWallpaperXStep", ";", "}", "if", "(", "mWallpaperTarget", ".", "mWallpaperY", ">=", "0", ")", "{", "mLastWallpaperY", "=", "mWallpaperTarget", ".", "mWallpaperY", ";", "mLastWallpaperYStep", "=", "mWallpaperTarget", ".", "mWallpaperYStep", ";", "}", "}", "int", "curTokenIndex", "=", "mWallpaperTokens", ".", "size", "(", ")", ";", "while", "(", "curTokenIndex", ">", "0", ")", "{", "curTokenIndex", "--", ";", "WindowToken", "token", "=", "mWallpaperTokens", ".", "get", "(", "curTokenIndex", ")", ";", "if", "(", "token", ".", "hidden", "==", "visible", ")", "{", "changed", "|=", "ADJUST_WALLPAPER_VISIBILITY_CHANGED", ";", "token", ".", "hidden", "=", "!", "visible", ";", "mLayoutNeeded", "=", "true", ";", "}", "int", "curWallpaperIndex", "=", "token", ".", "windows", ".", "size", "(", ")", ";", "while", "(", "curWallpaperIndex", ">", "0", ")", "{", "curWallpaperIndex", "--", ";", "WindowState", "wallpaper", "=", "token", ".", "windows", ".", "get", "(", "curWallpaperIndex", ")", ";", "if", "(", "visible", ")", "{", "updateWallpaperOffsetLocked", "(", "wallpaper", ",", "dw", ",", "dh", ",", "false", ")", ";", "}", "if", "(", "wallpaper", ".", "mWallpaperVisible", "!=", "visible", ")", "{", "wallpaper", ".", "mWallpaperVisible", "=", "visible", ";", "try", "{", "if", "(", "DEBUG_VISIBILITY", "||", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wallpaper", "+", "\":", "\"", "+", "visible", ")", ";", "wallpaper", ".", "mClient", ".", "dispatchAppVisibility", "(", "visible", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "wallpaper", ".", "mAnimLayer", "=", "wallpaper", ".", "mLayer", "+", "mWallpaperAnimLayerAdjustment", ";", "if", "(", "DEBUG_LAYERS", "||", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wallpaper", "+", "\"\"", "+", "wallpaper", ".", "mAnimLayer", ")", ";", "if", "(", "wallpaper", "==", "foundW", ")", "{", "foundI", "--", ";", "foundW", "=", "foundI", ">", "0", "?", "localmWindows", ".", "get", "(", "foundI", "-", "1", ")", ":", "null", ";", "continue", ";", "}", "int", "oldIndex", "=", "localmWindows", ".", "indexOf", "(", "wallpaper", ")", ";", "if", "(", "oldIndex", ">=", "0", ")", "{", "if", "(", "DEBUG_WINDOW_MOVEMENT", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "oldIndex", "+", "\":", "\"", "+", "wallpaper", ")", ";", "localmWindows", ".", "remove", "(", "oldIndex", ")", ";", "mWindowsChanged", "=", "true", ";", "if", "(", "oldIndex", "<", "foundI", ")", "{", "foundI", "--", ";", "}", "}", "if", "(", "DEBUG_WALLPAPER", "||", "DEBUG_WINDOW_MOVEMENT", "||", "DEBUG_ADD_REMOVE", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wallpaper", "+", "\"", "from", "\"", "+", "oldIndex", "+", "\"", "to", "\"", "+", "foundI", ")", ";", "}", "localmWindows", ".", "add", "(", "foundI", ",", "wallpaper", ")", ";", "mWindowsChanged", "=", "true", ";", "changed", "|=", "ADJUST_WALLPAPER_LAYERS_CHANGED", ";", "}", "}", "return", "changed", ";", "}", "void", "setWallpaperAnimLayerAdjustmentLocked", "(", "int", "adj", ")", "{", "if", "(", "DEBUG_LAYERS", "||", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "adj", ")", ";", "mWallpaperAnimLayerAdjustment", "=", "adj", ";", "int", "curTokenIndex", "=", "mWallpaperTokens", ".", "size", "(", ")", ";", "while", "(", "curTokenIndex", ">", "0", ")", "{", "curTokenIndex", "--", ";", "WindowToken", "token", "=", "mWallpaperTokens", ".", "get", "(", "curTokenIndex", ")", ";", "int", "curWallpaperIndex", "=", "token", ".", "windows", ".", "size", "(", ")", ";", "while", "(", "curWallpaperIndex", ">", "0", ")", "{", "curWallpaperIndex", "--", ";", "WindowState", "wallpaper", "=", "token", ".", "windows", ".", "get", "(", "curWallpaperIndex", ")", ";", "wallpaper", ".", "mAnimLayer", "=", "wallpaper", ".", "mLayer", "+", "adj", ";", "if", "(", "DEBUG_LAYERS", "||", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wallpaper", "+", "\"\"", "+", "wallpaper", ".", "mAnimLayer", ")", ";", "}", "}", "}", "boolean", "updateWallpaperOffsetLocked", "(", "WindowState", "wallpaperWin", ",", "int", "dw", ",", "int", "dh", ",", "boolean", "sync", ")", "{", "boolean", "changed", "=", "false", ";", "boolean", "rawChanged", "=", "false", ";", "float", "wpx", "=", "mLastWallpaperX", ">=", "0", "?", "mLastWallpaperX", ":", "0.5f", ";", "float", "wpxs", "=", "mLastWallpaperXStep", ">=", "0", "?", "mLastWallpaperXStep", ":", "-", "1.0f", ";", "int", "availw", "=", "wallpaperWin", ".", "mFrame", ".", "right", "-", "wallpaperWin", ".", "mFrame", ".", "left", "-", "dw", ";", "int", "offset", "=", "availw", ">", "0", "?", "-", "(", "int", ")", "(", "availw", "*", "wpx", "+", ".5f", ")", ":", "0", ";", "changed", "=", "wallpaperWin", ".", "mXOffset", "!=", "offset", ";", "if", "(", "changed", ")", "{", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wallpaperWin", "+", "\"", "x:", "\"", "+", "offset", ")", ";", "wallpaperWin", ".", "mXOffset", "=", "offset", ";", "}", "if", "(", "wallpaperWin", ".", "mWallpaperX", "!=", "wpx", "||", "wallpaperWin", ".", "mWallpaperXStep", "!=", "wpxs", ")", "{", "wallpaperWin", ".", "mWallpaperX", "=", "wpx", ";", "wallpaperWin", ".", "mWallpaperXStep", "=", "wpxs", ";", "rawChanged", "=", "true", ";", "}", "float", "wpy", "=", "mLastWallpaperY", ">=", "0", "?", "mLastWallpaperY", ":", "0.5f", ";", "float", "wpys", "=", "mLastWallpaperYStep", ">=", "0", "?", "mLastWallpaperYStep", ":", "-", "1.0f", ";", "int", "availh", "=", "wallpaperWin", ".", "mFrame", ".", "bottom", "-", "wallpaperWin", ".", "mFrame", ".", "top", "-", "dh", ";", "offset", "=", "availh", ">", "0", "?", "-", "(", "int", ")", "(", "availh", "*", "wpy", "+", ".5f", ")", ":", "0", ";", "if", "(", "wallpaperWin", ".", "mYOffset", "!=", "offset", ")", "{", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wallpaperWin", "+", "\"", "y:", "\"", "+", "offset", ")", ";", "changed", "=", "true", ";", "wallpaperWin", ".", "mYOffset", "=", "offset", ";", "}", "if", "(", "wallpaperWin", ".", "mWallpaperY", "!=", "wpy", "||", "wallpaperWin", ".", "mWallpaperYStep", "!=", "wpys", ")", "{", "wallpaperWin", ".", "mWallpaperY", "=", "wpy", ";", "wallpaperWin", ".", "mWallpaperYStep", "=", "wpys", ";", "rawChanged", "=", "true", ";", "}", "if", "(", "rawChanged", "&&", "(", "wallpaperWin", ".", "getAttrs", "(", ")", ".", "privateFlags", "&", "WindowManager", ".", "LayoutParams", ".", "PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS", ")", "!=", "0", ")", "{", "try", "{", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wallpaperWin", "+", "\"", "x=\"", "+", "wallpaperWin", ".", "mWallpaperX", "+", "\"", "y=\"", "+", "wallpaperWin", ".", "mWallpaperY", ")", ";", "if", "(", "sync", ")", "{", "mWaitingOnWallpaper", "=", "wallpaperWin", ";", "}", "wallpaperWin", ".", "mClient", ".", "dispatchWallpaperOffsets", "(", "wallpaperWin", ".", "mWallpaperX", ",", "wallpaperWin", ".", "mWallpaperY", ",", "wallpaperWin", ".", "mWallpaperXStep", ",", "wallpaperWin", ".", "mWallpaperYStep", ",", "sync", ")", ";", "if", "(", "sync", ")", "{", "if", "(", "mWaitingOnWallpaper", "!=", "null", ")", "{", "long", "start", "=", "SystemClock", ".", "uptimeMillis", "(", ")", ";", "if", "(", "(", "mLastWallpaperTimeoutTime", "+", "WALLPAPER_TIMEOUT_RECOVERY", ")", "<", "start", ")", "{", "try", "{", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "mWindowMap", ".", "wait", "(", "WALLPAPER_TIMEOUT", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "if", "(", "(", "start", "+", "WALLPAPER_TIMEOUT", ")", "<", "SystemClock", ".", "uptimeMillis", "(", ")", ")", "{", "Slog", ".", "i", "(", "TAG", ",", "\"\"", "+", "wallpaperWin", ")", ";", "mLastWallpaperTimeoutTime", "=", "start", ";", "}", "}", "mWaitingOnWallpaper", "=", "null", ";", "}", "}", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "return", "changed", ";", "}", "void", "wallpaperOffsetsComplete", "(", "IBinder", "window", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "mWaitingOnWallpaper", "!=", "null", "&&", "mWaitingOnWallpaper", ".", "mClient", ".", "asBinder", "(", ")", "==", "window", ")", "{", "mWaitingOnWallpaper", "=", "null", ";", "mWindowMap", ".", "notifyAll", "(", ")", ";", "}", "}", "}", "void", "updateWallpaperOffsetLocked", "(", "WindowState", "changingTarget", ",", "boolean", "sync", ")", "{", "final", "int", "dw", "=", "mAppDisplayWidth", ";", "final", "int", "dh", "=", "mAppDisplayHeight", ";", "WindowState", "target", "=", "mWallpaperTarget", ";", "if", "(", "target", "!=", "null", ")", "{", "if", "(", "target", ".", "mWallpaperX", ">=", "0", ")", "{", "mLastWallpaperX", "=", "target", ".", "mWallpaperX", ";", "}", "else", "if", "(", "changingTarget", ".", "mWallpaperX", ">=", "0", ")", "{", "mLastWallpaperX", "=", "changingTarget", ".", "mWallpaperX", ";", "}", "if", "(", "target", ".", "mWallpaperY", ">=", "0", ")", "{", "mLastWallpaperY", "=", "target", ".", "mWallpaperY", ";", "}", "else", "if", "(", "changingTarget", ".", "mWallpaperY", ">=", "0", ")", "{", "mLastWallpaperY", "=", "changingTarget", ".", "mWallpaperY", ";", "}", "}", "int", "curTokenIndex", "=", "mWallpaperTokens", ".", "size", "(", ")", ";", "while", "(", "curTokenIndex", ">", "0", ")", "{", "curTokenIndex", "--", ";", "WindowToken", "token", "=", "mWallpaperTokens", ".", "get", "(", "curTokenIndex", ")", ";", "int", "curWallpaperIndex", "=", "token", ".", "windows", ".", "size", "(", ")", ";", "while", "(", "curWallpaperIndex", ">", "0", ")", "{", "curWallpaperIndex", "--", ";", "WindowState", "wallpaper", "=", "token", ".", "windows", ".", "get", "(", "curWallpaperIndex", ")", ";", "if", "(", "updateWallpaperOffsetLocked", "(", "wallpaper", ",", "dw", ",", "dh", ",", "sync", ")", ")", "{", "wallpaper", ".", "computeShownFrameLocked", "(", ")", ";", "if", "(", "wallpaper", ".", "mSurfaceX", "!=", "wallpaper", ".", "mShownFrame", ".", "left", "||", "wallpaper", ".", "mSurfaceY", "!=", "wallpaper", ".", "mShownFrame", ".", "top", ")", "{", "Surface", ".", "openTransaction", "(", ")", ";", "try", "{", "if", "(", "SHOW_TRANSACTIONS", ")", "logSurface", "(", "wallpaper", ",", "\"POS", "\"", "+", "wallpaper", ".", "mShownFrame", ".", "left", "+", "\",", "\"", "+", "wallpaper", ".", "mShownFrame", ".", "top", ",", "null", ")", ";", "wallpaper", ".", "mSurfaceX", "=", "wallpaper", ".", "mShownFrame", ".", "left", ";", "wallpaper", ".", "mSurfaceY", "=", "wallpaper", ".", "mShownFrame", ".", "top", ";", "wallpaper", ".", "mSurface", ".", "setPosition", "(", "wallpaper", ".", "mShownFrame", ".", "left", ",", "wallpaper", ".", "mShownFrame", ".", "top", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "wallpaper", "+", "\"", "pos=(\"", "+", "wallpaper", ".", "mShownFrame", ".", "left", "+", "\",\"", "+", "wallpaper", ".", "mShownFrame", ".", "top", "+", "\")\"", ",", "e", ")", ";", "}", "Surface", ".", "closeTransaction", "(", ")", ";", "}", "sync", "=", "false", ";", "}", "}", "}", "}", "void", "updateWallpaperVisibilityLocked", "(", ")", "{", "final", "boolean", "visible", "=", "isWallpaperVisible", "(", "mWallpaperTarget", ")", ";", "final", "int", "dw", "=", "mAppDisplayWidth", ";", "final", "int", "dh", "=", "mAppDisplayHeight", ";", "int", "curTokenIndex", "=", "mWallpaperTokens", ".", "size", "(", ")", ";", "while", "(", "curTokenIndex", ">", "0", ")", "{", "curTokenIndex", "--", ";", "WindowToken", "token", "=", "mWallpaperTokens", ".", "get", "(", "curTokenIndex", ")", ";", "if", "(", "token", ".", "hidden", "==", "visible", ")", "{", "token", ".", "hidden", "=", "!", "visible", ";", "mLayoutNeeded", "=", "true", ";", "}", "int", "curWallpaperIndex", "=", "token", ".", "windows", ".", "size", "(", ")", ";", "while", "(", "curWallpaperIndex", ">", "0", ")", "{", "curWallpaperIndex", "--", ";", "WindowState", "wallpaper", "=", "token", ".", "windows", ".", "get", "(", "curWallpaperIndex", ")", ";", "if", "(", "visible", ")", "{", "updateWallpaperOffsetLocked", "(", "wallpaper", ",", "dw", ",", "dh", ",", "false", ")", ";", "}", "if", "(", "wallpaper", ".", "mWallpaperVisible", "!=", "visible", ")", "{", "wallpaper", ".", "mWallpaperVisible", "=", "visible", ";", "try", "{", "if", "(", "DEBUG_VISIBILITY", "||", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wallpaper", "+", "\":", "\"", "+", "visible", ")", ";", "wallpaper", ".", "mClient", ".", "dispatchAppVisibility", "(", "visible", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "}", "}", "}", "public", "int", "addWindow", "(", "Session", "session", ",", "IWindow", "client", ",", "int", "seq", ",", "WindowManager", ".", "LayoutParams", "attrs", ",", "int", "viewVisibility", ",", "Rect", "outContentInsets", ",", "InputChannel", "outInputChannel", ")", "{", "int", "res", "=", "mPolicy", ".", "checkAddPermission", "(", "attrs", ")", ";", "if", "(", "res", "!=", "WindowManagerImpl", ".", "ADD_OKAY", ")", "{", "return", "res", ";", "}", "boolean", "reportNewConfig", "=", "false", ";", "WindowState", "attachedWindow", "=", "null", ";", "WindowState", "win", "=", "null", ";", "long", "origId", ";", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "mDisplay", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"\"", ")", ";", "}", "if", "(", "mWindowMap", ".", "containsKey", "(", "client", ".", "asBinder", "(", ")", ")", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"Window", "\"", "+", "client", "+", "\"\"", ")", ";", "return", "WindowManagerImpl", ".", "ADD_DUPLICATE_ADD", ";", "}", "if", "(", "attrs", ".", "type", ">=", "FIRST_SUB_WINDOW", "&&", "attrs", ".", "type", "<=", "LAST_SUB_WINDOW", ")", "{", "attachedWindow", "=", "windowForClientLocked", "(", "null", ",", "attrs", ".", "token", ",", "false", ")", ";", "if", "(", "attachedWindow", "==", "null", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "attrs", ".", "token", "+", "\".", "Aborting.\"", ")", ";", "return", "WindowManagerImpl", ".", "ADD_BAD_SUBWINDOW_TOKEN", ";", "}", "if", "(", "attachedWindow", ".", "mAttrs", ".", "type", ">=", "FIRST_SUB_WINDOW", "&&", "attachedWindow", ".", "mAttrs", ".", "type", "<=", "LAST_SUB_WINDOW", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "attrs", ".", "token", "+", "\".", "Aborting.\"", ")", ";", "return", "WindowManagerImpl", ".", "ADD_BAD_SUBWINDOW_TOKEN", ";", "}", "}", "boolean", "addToken", "=", "false", ";", "WindowToken", "token", "=", "mTokenMap", ".", "get", "(", "attrs", ".", "token", ")", ";", "if", "(", "token", "==", "null", ")", "{", "if", "(", "attrs", ".", "type", ">=", "FIRST_APPLICATION_WINDOW", "&&", "attrs", ".", "type", "<=", "LAST_APPLICATION_WINDOW", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "attrs", ".", "token", "+", "\".", "Aborting.\"", ")", ";", "return", "WindowManagerImpl", ".", "ADD_BAD_APP_TOKEN", ";", "}", "if", "(", "attrs", ".", "type", "==", "TYPE_INPUT_METHOD", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "attrs", ".", "token", "+", "\".", "Aborting.\"", ")", ";", "return", "WindowManagerImpl", ".", "ADD_BAD_APP_TOKEN", ";", "}", "if", "(", "attrs", ".", "type", "==", "TYPE_WALLPAPER", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "attrs", ".", "token", "+", "\".", "Aborting.\"", ")", ";", "return", "WindowManagerImpl", ".", "ADD_BAD_APP_TOKEN", ";", "}", "token", "=", "new", "WindowToken", "(", "this", ",", "attrs", ".", "token", ",", "-", "1", ",", "false", ")", ";", "addToken", "=", "true", ";", "}", "else", "if", "(", "attrs", ".", "type", ">=", "FIRST_APPLICATION_WINDOW", "&&", "attrs", ".", "type", "<=", "LAST_APPLICATION_WINDOW", ")", "{", "AppWindowToken", "atoken", "=", "token", ".", "appWindowToken", ";", "if", "(", "atoken", "==", "null", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "token", "+", "\".", "Aborting.\"", ")", ";", "return", "WindowManagerImpl", ".", "ADD_NOT_APP_TOKEN", ";", "}", "else", "if", "(", "atoken", ".", "removed", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "token", "+", "\".", "Aborting.\"", ")", ";", "return", "WindowManagerImpl", ".", "ADD_APP_EXITING", ";", "}", "if", "(", "attrs", ".", "type", "==", "TYPE_APPLICATION_STARTING", "&&", "atoken", ".", "firstWindowDrawn", ")", "{", "if", "(", "localLOGV", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "attrs", ".", "getTitle", "(", ")", ")", ";", "return", "WindowManagerImpl", ".", "ADD_STARTING_NOT_NEEDED", ";", "}", "}", "else", "if", "(", "attrs", ".", "type", "==", "TYPE_INPUT_METHOD", ")", "{", "if", "(", "token", ".", "windowType", "!=", "TYPE_INPUT_METHOD", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "attrs", ".", "token", "+", "\".", "Aborting.\"", ")", ";", "return", "WindowManagerImpl", ".", "ADD_BAD_APP_TOKEN", ";", "}", "}", "else", "if", "(", "attrs", ".", "type", "==", "TYPE_WALLPAPER", ")", "{", "if", "(", "token", ".", "windowType", "!=", "TYPE_WALLPAPER", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "attrs", ".", "token", "+", "\".", "Aborting.\"", ")", ";", "return", "WindowManagerImpl", ".", "ADD_BAD_APP_TOKEN", ";", "}", "}", "win", "=", "new", "WindowState", "(", "this", ",", "session", ",", "client", ",", "token", ",", "attachedWindow", ",", "seq", ",", "attrs", ",", "viewVisibility", ")", ";", "if", "(", "win", ".", "mDeathRecipient", "==", "null", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "client", ".", "asBinder", "(", ")", "+", "\"\"", ")", ";", "return", "WindowManagerImpl", ".", "ADD_APP_EXITING", ";", "}", "mPolicy", ".", "adjustWindowParamsLw", "(", "win", ".", "mAttrs", ")", ";", "res", "=", "mPolicy", ".", "prepareAddWindowLw", "(", "win", ",", "attrs", ")", ";", "if", "(", "res", "!=", "WindowManagerImpl", ".", "ADD_OKAY", ")", "{", "return", "res", ";", "}", "if", "(", "outInputChannel", "!=", "null", "&&", "(", "attrs", ".", "inputFeatures", "&", "WindowManager", ".", "LayoutParams", ".", "INPUT_FEATURE_NO_INPUT_CHANNEL", ")", "==", "0", ")", "{", "String", "name", "=", "win", ".", "makeInputChannelName", "(", ")", ";", "InputChannel", "[", "]", "inputChannels", "=", "InputChannel", ".", "openInputChannelPair", "(", "name", ")", ";", "win", ".", "setInputChannel", "(", "inputChannels", "[", "0", "]", ")", ";", "inputChannels", "[", "1", "]", ".", "transferTo", "(", "outInputChannel", ")", ";", "mInputManager", ".", "registerInputChannel", "(", "win", ".", "mInputChannel", ",", "win", ".", "mInputWindowHandle", ")", ";", "}", "res", "=", "WindowManagerImpl", ".", "ADD_OKAY", ";", "origId", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "if", "(", "addToken", ")", "{", "mTokenMap", ".", "put", "(", "attrs", ".", "token", ",", "token", ")", ";", "}", "win", ".", "attach", "(", ")", ";", "mWindowMap", ".", "put", "(", "client", ".", "asBinder", "(", ")", ",", "win", ")", ";", "if", "(", "attrs", ".", "type", "==", "TYPE_APPLICATION_STARTING", "&&", "token", ".", "appWindowToken", "!=", "null", ")", "{", "token", ".", "appWindowToken", ".", "startingWindow", "=", "win", ";", "}", "boolean", "imMayMove", "=", "true", ";", "if", "(", "attrs", ".", "type", "==", "TYPE_INPUT_METHOD", ")", "{", "mInputMethodWindow", "=", "win", ";", "addInputMethodWindowToListLocked", "(", "win", ")", ";", "imMayMove", "=", "false", ";", "}", "else", "if", "(", "attrs", ".", "type", "==", "TYPE_INPUT_METHOD_DIALOG", ")", "{", "mInputMethodDialogs", ".", "add", "(", "win", ")", ";", "addWindowToListInOrderLocked", "(", "win", ",", "true", ")", ";", "adjustInputMethodDialogsLocked", "(", ")", ";", "imMayMove", "=", "false", ";", "}", "else", "{", "addWindowToListInOrderLocked", "(", "win", ",", "true", ")", ";", "if", "(", "attrs", ".", "type", "==", "TYPE_WALLPAPER", ")", "{", "mLastWallpaperTimeoutTime", "=", "0", ";", "adjustWallpaperWindowsLocked", "(", ")", ";", "}", "else", "if", "(", "(", "attrs", ".", "flags", "&", "FLAG_SHOW_WALLPAPER", ")", "!=", "0", ")", "{", "adjustWallpaperWindowsLocked", "(", ")", ";", "}", "}", "win", ".", "mEnterAnimationPending", "=", "true", ";", "mPolicy", ".", "getContentInsetHintLw", "(", "attrs", ",", "outContentInsets", ")", ";", "if", "(", "mInTouchMode", ")", "{", "res", "|=", "WindowManagerImpl", ".", "ADD_FLAG_IN_TOUCH_MODE", ";", "}", "if", "(", "win", "==", "null", "||", "win", ".", "mAppToken", "==", "null", "||", "!", "win", ".", "mAppToken", ".", "clientHidden", ")", "{", "res", "|=", "WindowManagerImpl", ".", "ADD_FLAG_APP_VISIBLE", ";", "}", "mInputMonitor", ".", "setUpdateInputWindowsNeededLw", "(", ")", ";", "boolean", "focusChanged", "=", "false", ";", "if", "(", "win", ".", "canReceiveKeys", "(", ")", ")", "{", "focusChanged", "=", "updateFocusedWindowLocked", "(", "UPDATE_FOCUS_WILL_ASSIGN_LAYERS", ",", "false", ")", ";", "if", "(", "focusChanged", ")", "{", "imMayMove", "=", "false", ";", "}", "}", "if", "(", "imMayMove", ")", "{", "moveInputMethodWindowsIfNeededLocked", "(", "false", ")", ";", "}", "assignLayersLocked", "(", ")", ";", "if", "(", "focusChanged", ")", "{", "finishUpdateFocusedWindowAfterAssignLayersLocked", "(", "false", ")", ";", "}", "mInputMonitor", ".", "updateInputWindowsLw", "(", "false", ")", ";", "if", "(", "localLOGV", ")", "Slog", ".", "v", "(", "TAG", ",", "\"New", "client", "\"", "+", "client", ".", "asBinder", "(", ")", "+", "\":", "window=\"", "+", "win", ")", ";", "if", "(", "win", ".", "isVisibleOrAdding", "(", ")", "&&", "updateOrientationFromAppTokensLocked", "(", "false", ")", ")", "{", "reportNewConfig", "=", "true", ";", "}", "}", "if", "(", "reportNewConfig", ")", "{", "sendNewConfiguration", "(", ")", ";", "}", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "return", "res", ";", "}", "public", "void", "removeWindow", "(", "Session", "session", ",", "IWindow", "client", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "WindowState", "win", "=", "windowForClientLocked", "(", "session", ",", "client", ",", "false", ")", ";", "if", "(", "win", "==", "null", ")", "{", "return", ";", "}", "removeWindowLocked", "(", "session", ",", "win", ")", ";", "}", "}", "public", "void", "removeWindowLocked", "(", "Session", "session", ",", "WindowState", "win", ")", "{", "if", "(", "localLOGV", "||", "DEBUG_FOCUS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Remove", "\"", "+", "win", "+", "\"", "client=\"", "+", "Integer", ".", "toHexString", "(", "System", ".", "identityHashCode", "(", "win", ".", "mClient", ".", "asBinder", "(", ")", ")", ")", "+", "\",", "surface=\"", "+", "win", ".", "mSurface", ")", ";", "final", "long", "origId", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "win", ".", "disposeInputChannel", "(", ")", ";", "if", "(", "DEBUG_APP_TRANSITIONS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Remove", "\"", "+", "win", "+", "\":", "mSurface=\"", "+", "win", ".", "mSurface", "+", "\"", "mExiting=\"", "+", "win", ".", "mExiting", "+", "\"\"", "+", "win", ".", "isAnimating", "(", ")", "+", "\"\"", "+", "(", "win", ".", "mAppToken", "!=", "null", "?", "win", ".", "mAppToken", ".", "animation", ":", "null", ")", "+", "\"\"", "+", "(", "win", ".", "mAppToken", "!=", "null", "?", "win", ".", "mAppToken", ".", "inPendingTransaction", ":", "false", ")", "+", "\"\"", "+", "mDisplayFrozen", ")", ";", "boolean", "wasVisible", "=", "false", ";", "if", "(", "win", ".", "mSurface", "!=", "null", "&&", "!", "mDisplayFrozen", "&&", "mDisplayEnabled", "&&", "mPolicy", ".", "isScreenOnFully", "(", ")", ")", "{", "if", "(", "wasVisible", "=", "win", ".", "isWinVisibleLw", "(", ")", ")", "{", "int", "transit", "=", "WindowManagerPolicy", ".", "TRANSIT_EXIT", ";", "if", "(", "win", ".", "getAttrs", "(", ")", ".", "type", "==", "TYPE_APPLICATION_STARTING", ")", "{", "transit", "=", "WindowManagerPolicy", ".", "TRANSIT_PREVIEW_DONE", ";", "}", "if", "(", "applyAnimationLocked", "(", "win", ",", "transit", ",", "false", ")", ")", "{", "win", ".", "mExiting", "=", "true", ";", "}", "}", "if", "(", "win", ".", "mExiting", "||", "win", ".", "isAnimating", "(", ")", ")", "{", "win", ".", "mExiting", "=", "true", ";", "win", ".", "mRemoveOnExit", "=", "true", ";", "mLayoutNeeded", "=", "true", ";", "updateFocusedWindowLocked", "(", "UPDATE_FOCUS_WILL_PLACE_SURFACES", ",", "false", ")", ";", "performLayoutAndPlaceSurfacesLocked", "(", ")", ";", "mInputMonitor", ".", "updateInputWindowsLw", "(", "false", ")", ";", "if", "(", "win", ".", "mAppToken", "!=", "null", ")", "{", "win", ".", "mAppToken", ".", "updateReportedVisibilityLocked", "(", ")", ";", "}", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "return", ";", "}", "}", "removeWindowInnerLocked", "(", "session", ",", "win", ")", ";", "if", "(", "wasVisible", "&&", "computeForcedAppOrientationLocked", "(", ")", "!=", "mForcedAppOrientation", "&&", "updateOrientationFromAppTokensLocked", "(", "false", ")", ")", "{", "mH", ".", "sendEmptyMessage", "(", "H", ".", "SEND_NEW_CONFIGURATION", ")", ";", "}", "updateFocusedWindowLocked", "(", "UPDATE_FOCUS_NORMAL", ",", "true", ")", ";", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "}", "private", "void", "removeWindowInnerLocked", "(", "Session", "session", ",", "WindowState", "win", ")", "{", "if", "(", "win", ".", "mRemoved", ")", "{", "return", ";", "}", "for", "(", "int", "i", "=", "win", ".", "mChildWindows", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowState", "cwin", "=", "win", ".", "mChildWindows", ".", "get", "(", "i", ")", ";", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "cwin", "+", "\"\"", "+", "win", ")", ";", "removeWindowInnerLocked", "(", "cwin", ".", "mSession", ",", "cwin", ")", ";", "}", "win", ".", "mRemoved", "=", "true", ";", "if", "(", "mInputMethodTarget", "==", "win", ")", "{", "moveInputMethodWindowsIfNeededLocked", "(", "false", ")", ";", "}", "if", "(", "false", ")", "{", "RuntimeException", "e", "=", "new", "RuntimeException", "(", "\"here\"", ")", ";", "e", ".", "fillInStackTrace", "(", ")", ";", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "win", ",", "e", ")", ";", "}", "mPolicy", ".", "removeWindowLw", "(", "win", ")", ";", "win", ".", "removeLocked", "(", ")", ";", "if", "(", "DEBUG_ADD_REMOVE", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "win", ")", ";", "mWindowMap", ".", "remove", "(", "win", ".", "mClient", ".", "asBinder", "(", ")", ")", ";", "mWindows", ".", "remove", "(", "win", ")", ";", "mPendingRemove", ".", "remove", "(", "win", ")", ";", "mWindowsChanged", "=", "true", ";", "if", "(", "DEBUG_WINDOW_MOVEMENT", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "win", ")", ";", "if", "(", "mInputMethodWindow", "==", "win", ")", "{", "mInputMethodWindow", "=", "null", ";", "}", "else", "if", "(", "win", ".", "mAttrs", ".", "type", "==", "TYPE_INPUT_METHOD_DIALOG", ")", "{", "mInputMethodDialogs", ".", "remove", "(", "win", ")", ";", "}", "final", "WindowToken", "token", "=", "win", ".", "mToken", ";", "final", "AppWindowToken", "atoken", "=", "win", ".", "mAppToken", ";", "if", "(", "DEBUG_ADD_REMOVE", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Removing", "\"", "+", "win", "+", "\"", "from", "\"", "+", "token", ")", ";", "token", ".", "windows", ".", "remove", "(", "win", ")", ";", "if", "(", "atoken", "!=", "null", ")", "{", "atoken", ".", "allAppWindows", ".", "remove", "(", "win", ")", ";", "}", "if", "(", "localLOGV", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "win", "+", "\":", "count=\"", "+", "token", ".", "windows", ".", "size", "(", ")", ")", ";", "if", "(", "token", ".", "windows", ".", "size", "(", ")", "==", "0", ")", "{", "if", "(", "!", "token", ".", "explicit", ")", "{", "mTokenMap", ".", "remove", "(", "token", ".", "token", ")", ";", "}", "else", "if", "(", "atoken", "!=", "null", ")", "{", "atoken", ".", "firstWindowDrawn", "=", "false", ";", "}", "}", "if", "(", "atoken", "!=", "null", ")", "{", "if", "(", "atoken", ".", "startingWindow", "==", "win", ")", "{", "atoken", ".", "startingWindow", "=", "null", ";", "}", "else", "if", "(", "atoken", ".", "allAppWindows", ".", "size", "(", ")", "==", "0", "&&", "atoken", ".", "startingData", "!=", "null", ")", "{", "atoken", ".", "startingData", "=", "null", ";", "}", "else", "if", "(", "atoken", ".", "allAppWindows", ".", "size", "(", ")", "==", "1", "&&", "atoken", ".", "startingView", "!=", "null", ")", "{", "if", "(", "DEBUG_STARTING_WINDOW", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "token", "+", "\"\"", ")", ";", "}", "Message", "m", "=", "mH", ".", "obtainMessage", "(", "H", ".", "REMOVE_STARTING", ",", "atoken", ")", ";", "mH", ".", "sendMessage", "(", "m", ")", ";", "}", "}", "if", "(", "win", ".", "mAttrs", ".", "type", "==", "TYPE_WALLPAPER", ")", "{", "mLastWallpaperTimeoutTime", "=", "0", ";", "adjustWallpaperWindowsLocked", "(", ")", ";", "}", "else", "if", "(", "(", "win", ".", "mAttrs", ".", "flags", "&", "FLAG_SHOW_WALLPAPER", ")", "!=", "0", ")", "{", "adjustWallpaperWindowsLocked", "(", ")", ";", "}", "if", "(", "!", "mInLayout", ")", "{", "assignLayersLocked", "(", ")", ";", "mLayoutNeeded", "=", "true", ";", "performLayoutAndPlaceSurfacesLocked", "(", ")", ";", "if", "(", "win", ".", "mAppToken", "!=", "null", ")", "{", "win", ".", "mAppToken", ".", "updateReportedVisibilityLocked", "(", ")", ";", "}", "}", "mInputMonitor", ".", "updateInputWindowsLw", "(", "true", ")", ";", "}", "static", "void", "logSurface", "(", "WindowState", "w", ",", "String", "msg", ",", "RuntimeException", "where", ")", "{", "String", "str", "=", "\"", "SURFACE", "\"", "+", "Integer", ".", "toHexString", "(", "w", ".", "hashCode", "(", ")", ")", "+", "\":", "\"", "+", "msg", "+", "\"", "/", "\"", "+", "w", ".", "mAttrs", ".", "getTitle", "(", ")", ";", "if", "(", "where", "!=", "null", ")", "{", "Slog", ".", "i", "(", "TAG", ",", "str", ",", "where", ")", ";", "}", "else", "{", "Slog", ".", "i", "(", "TAG", ",", "str", ")", ";", "}", "}", "void", "setTransparentRegionWindow", "(", "Session", "session", ",", "IWindow", "client", ",", "Region", "region", ")", "{", "long", "origId", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "try", "{", "synchronized", "(", "mWindowMap", ")", "{", "WindowState", "w", "=", "windowForClientLocked", "(", "session", ",", "client", ",", "false", ")", ";", "if", "(", "(", "w", "!=", "null", ")", "&&", "(", "w", ".", "mSurface", "!=", "null", ")", ")", "{", "if", "(", "SHOW_LIGHT_TRANSACTIONS", ")", "Slog", ".", "i", "(", "TAG", ",", "\"\"", ")", ";", "Surface", ".", "openTransaction", "(", ")", ";", "try", "{", "if", "(", "SHOW_TRANSACTIONS", ")", "logSurface", "(", "w", ",", "\"\"", "+", "region", ",", "null", ")", ";", "w", ".", "mSurface", ".", "setTransparentRegionHint", "(", "region", ")", ";", "}", "finally", "{", "Surface", ".", "closeTransaction", "(", ")", ";", "if", "(", "SHOW_LIGHT_TRANSACTIONS", ")", "Slog", ".", "i", "(", "TAG", ",", "\"\"", ")", ";", "}", "}", "}", "}", "finally", "{", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "}", "}", "void", "setInsetsWindow", "(", "Session", "session", ",", "IWindow", "client", ",", "int", "touchableInsets", ",", "Rect", "contentInsets", ",", "Rect", "visibleInsets", ",", "Region", "touchableRegion", ")", "{", "long", "origId", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "try", "{", "synchronized", "(", "mWindowMap", ")", "{", "WindowState", "w", "=", "windowForClientLocked", "(", "session", ",", "client", ",", "false", ")", ";", "if", "(", "w", "!=", "null", ")", "{", "w", ".", "mGivenInsetsPending", "=", "false", ";", "w", ".", "mGivenContentInsets", ".", "set", "(", "contentInsets", ")", ";", "w", ".", "mGivenVisibleInsets", ".", "set", "(", "visibleInsets", ")", ";", "w", ".", "mGivenTouchableRegion", ".", "set", "(", "touchableRegion", ")", ";", "w", ".", "mTouchableInsets", "=", "touchableInsets", ";", "if", "(", "w", ".", "mGlobalScale", "!=", "1", ")", "{", "w", ".", "mGivenContentInsets", ".", "scale", "(", "w", ".", "mGlobalScale", ")", ";", "w", ".", "mGivenVisibleInsets", ".", "scale", "(", "w", ".", "mGlobalScale", ")", ";", "w", ".", "mGivenTouchableRegion", ".", "scale", "(", "w", ".", "mGlobalScale", ")", ";", "}", "mLayoutNeeded", "=", "true", ";", "performLayoutAndPlaceSurfacesLocked", "(", ")", ";", "}", "}", "}", "finally", "{", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "}", "}", "public", "void", "getWindowDisplayFrame", "(", "Session", "session", ",", "IWindow", "client", ",", "Rect", "outDisplayFrame", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "WindowState", "win", "=", "windowForClientLocked", "(", "session", ",", "client", ",", "false", ")", ";", "if", "(", "win", "==", "null", ")", "{", "outDisplayFrame", ".", "setEmpty", "(", ")", ";", "return", ";", "}", "outDisplayFrame", ".", "set", "(", "win", ".", "mDisplayFrame", ")", ";", "}", "}", "public", "void", "setWindowWallpaperPositionLocked", "(", "WindowState", "window", ",", "float", "x", ",", "float", "y", ",", "float", "xStep", ",", "float", "yStep", ")", "{", "if", "(", "window", ".", "mWallpaperX", "!=", "x", "||", "window", ".", "mWallpaperY", "!=", "y", ")", "{", "window", ".", "mWallpaperX", "=", "x", ";", "window", ".", "mWallpaperY", "=", "y", ";", "window", ".", "mWallpaperXStep", "=", "xStep", ";", "window", ".", "mWallpaperYStep", "=", "yStep", ";", "updateWallpaperOffsetLocked", "(", "window", ",", "true", ")", ";", "}", "}", "void", "wallpaperCommandComplete", "(", "IBinder", "window", ",", "Bundle", "result", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "mWaitingOnWallpaper", "!=", "null", "&&", "mWaitingOnWallpaper", ".", "mClient", ".", "asBinder", "(", ")", "==", "window", ")", "{", "mWaitingOnWallpaper", "=", "null", ";", "mWindowMap", ".", "notifyAll", "(", ")", ";", "}", "}", "}", "public", "Bundle", "sendWindowWallpaperCommandLocked", "(", "WindowState", "window", ",", "String", "action", ",", "int", "x", ",", "int", "y", ",", "int", "z", ",", "Bundle", "extras", ",", "boolean", "sync", ")", "{", "if", "(", "window", "==", "mWallpaperTarget", "||", "window", "==", "mLowerWallpaperTarget", "||", "window", "==", "mUpperWallpaperTarget", ")", "{", "boolean", "doWait", "=", "sync", ";", "int", "curTokenIndex", "=", "mWallpaperTokens", ".", "size", "(", ")", ";", "while", "(", "curTokenIndex", ">", "0", ")", "{", "curTokenIndex", "--", ";", "WindowToken", "token", "=", "mWallpaperTokens", ".", "get", "(", "curTokenIndex", ")", ";", "int", "curWallpaperIndex", "=", "token", ".", "windows", ".", "size", "(", ")", ";", "while", "(", "curWallpaperIndex", ">", "0", ")", "{", "curWallpaperIndex", "--", ";", "WindowState", "wallpaper", "=", "token", ".", "windows", ".", "get", "(", "curWallpaperIndex", ")", ";", "try", "{", "wallpaper", ".", "mClient", ".", "dispatchWallpaperCommand", "(", "action", ",", "x", ",", "y", ",", "z", ",", "extras", ",", "sync", ")", ";", "sync", "=", "false", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "}", "if", "(", "doWait", ")", "{", "}", "}", "return", "null", ";", "}", "public", "int", "relayoutWindow", "(", "Session", "session", ",", "IWindow", "client", ",", "int", "seq", ",", "WindowManager", ".", "LayoutParams", "attrs", ",", "int", "requestedWidth", ",", "int", "requestedHeight", ",", "int", "viewVisibility", ",", "int", "flags", ",", "Rect", "outFrame", ",", "Rect", "outContentInsets", ",", "Rect", "outVisibleInsets", ",", "Configuration", "outConfig", ",", "Surface", "outSurface", ")", "{", "boolean", "displayed", "=", "false", ";", "boolean", "inTouchMode", ";", "boolean", "configChanged", ";", "boolean", "surfaceChanged", "=", "false", ";", "int", "systemUiVisibility", "=", "0", ";", "if", "(", "attrs", "!=", "null", ")", "{", "systemUiVisibility", "=", "(", "attrs", ".", "systemUiVisibility", "|", "attrs", ".", "subtreeSystemUiVisibility", ")", ";", "if", "(", "(", "systemUiVisibility", "&", "StatusBarManager", ".", "DISABLE_MASK", ")", "!=", "0", ")", "{", "if", "(", "mContext", ".", "checkCallingOrSelfPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "STATUS_BAR", ")", "!=", "PackageManager", ".", "PERMISSION_GRANTED", ")", "{", "systemUiVisibility", "&=", "~", "StatusBarManager", ".", "DISABLE_MASK", ";", "}", "}", "}", "long", "origId", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "synchronized", "(", "mWindowMap", ")", "{", "WindowState", "win", "=", "windowForClientLocked", "(", "session", ",", "client", ",", "false", ")", ";", "if", "(", "win", "==", "null", ")", "{", "return", "0", ";", "}", "if", "(", "win", ".", "mRequestedWidth", "!=", "requestedWidth", "||", "win", ".", "mRequestedHeight", "!=", "requestedHeight", ")", "{", "win", ".", "mLayoutNeeded", "=", "true", ";", "win", ".", "mRequestedWidth", "=", "requestedWidth", ";", "win", ".", "mRequestedHeight", "=", "requestedHeight", ";", "}", "if", "(", "attrs", "!=", "null", "&&", "seq", "==", "win", ".", "mSeq", ")", "{", "win", ".", "mSystemUiVisibility", "=", "systemUiVisibility", ";", "}", "if", "(", "attrs", "!=", "null", ")", "{", "mPolicy", ".", "adjustWindowParamsLw", "(", "attrs", ")", ";", "}", "win", ".", "mSurfaceDestroyDeferred", "=", "(", "flags", "&", "WindowManagerImpl", ".", "RELAYOUT_DEFER_SURFACE_DESTROY", ")", "!=", "0", ";", "int", "attrChanges", "=", "0", ";", "int", "flagChanges", "=", "0", ";", "if", "(", "attrs", "!=", "null", ")", "{", "if", "(", "win", ".", "mAttrs", ".", "type", "!=", "attrs", ".", "type", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "}", "flagChanges", "=", "win", ".", "mAttrs", ".", "flags", "^=", "attrs", ".", "flags", ";", "attrChanges", "=", "win", ".", "mAttrs", ".", "copyFrom", "(", "attrs", ")", ";", "if", "(", "(", "attrChanges", "&", "WindowManager", ".", "LayoutParams", ".", "LAYOUT_CHANGED", ")", "!=", "0", ")", "{", "win", ".", "mLayoutNeeded", "=", "true", ";", "}", "}", "if", "(", "DEBUG_LAYOUT", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Relayout", "\"", "+", "win", "+", "\":", "\"", "+", "win", ".", "mAttrs", ")", ";", "win", ".", "mEnforceSizeCompat", "=", "(", "win", ".", "mAttrs", ".", "flags", "&", "FLAG_COMPATIBLE_WINDOW", ")", "!=", "0", ";", "if", "(", "(", "attrChanges", "&", "WindowManager", ".", "LayoutParams", ".", "ALPHA_CHANGED", ")", "!=", "0", ")", "{", "win", ".", "mAlpha", "=", "attrs", ".", "alpha", ";", "}", "final", "boolean", "scaledWindow", "=", "(", "(", "win", ".", "mAttrs", ".", "flags", "&", "WindowManager", ".", "LayoutParams", ".", "FLAG_SCALED", ")", "!=", "0", ")", ";", "if", "(", "scaledWindow", ")", "{", "win", ".", "mHScale", "=", "(", "attrs", ".", "width", "!=", "requestedWidth", ")", "?", "(", "attrs", ".", "width", "/", "(", "float", ")", "requestedWidth", ")", ":", "1.0f", ";", "win", ".", "mVScale", "=", "(", "attrs", ".", "height", "!=", "requestedHeight", ")", "?", "(", "attrs", ".", "height", "/", "(", "float", ")", "requestedHeight", ")", ":", "1.0f", ";", "}", "else", "{", "win", ".", "mHScale", "=", "win", ".", "mVScale", "=", "1", ";", "}", "boolean", "imMayMove", "=", "(", "flagChanges", "&", "(", "WindowManager", ".", "LayoutParams", ".", "FLAG_ALT_FOCUSABLE_IM", "|", "WindowManager", ".", "LayoutParams", ".", "FLAG_NOT_FOCUSABLE", ")", ")", "!=", "0", ";", "boolean", "focusMayChange", "=", "win", ".", "mViewVisibility", "!=", "viewVisibility", "||", "(", "(", "flagChanges", "&", "WindowManager", ".", "LayoutParams", ".", "FLAG_NOT_FOCUSABLE", ")", "!=", "0", ")", "||", "(", "!", "win", ".", "mRelayoutCalled", ")", ";", "boolean", "wallpaperMayMove", "=", "win", ".", "mViewVisibility", "!=", "viewVisibility", "&&", "(", "win", ".", "mAttrs", ".", "flags", "&", "FLAG_SHOW_WALLPAPER", ")", "!=", "0", ";", "wallpaperMayMove", "|=", "(", "flagChanges", "&", "FLAG_SHOW_WALLPAPER", ")", "!=", "0", ";", "win", ".", "mRelayoutCalled", "=", "true", ";", "final", "int", "oldVisibility", "=", "win", ".", "mViewVisibility", ";", "win", ".", "mViewVisibility", "=", "viewVisibility", ";", "if", "(", "DEBUG_SCREEN_ON", ")", "{", "RuntimeException", "stack", "=", "new", "RuntimeException", "(", ")", ";", "stack", ".", "fillInStackTrace", "(", ")", ";", "Slog", ".", "i", "(", "TAG", ",", "\"Relayout", "\"", "+", "win", "+", "\":", "oldVis=\"", "+", "oldVisibility", "+", "\"", "newVis=\"", "+", "viewVisibility", ",", "stack", ")", ";", "}", "if", "(", "viewVisibility", "==", "View", ".", "VISIBLE", "&&", "(", "win", ".", "mAppToken", "==", "null", "||", "!", "win", ".", "mAppToken", ".", "clientHidden", ")", ")", "{", "displayed", "=", "!", "win", ".", "isVisibleLw", "(", ")", ";", "if", "(", "win", ".", "mExiting", ")", "{", "win", ".", "cancelExitAnimationForNextAnimationLocked", "(", ")", ";", "}", "if", "(", "win", ".", "mDestroying", ")", "{", "win", ".", "mDestroying", "=", "false", ";", "mDestroySurface", ".", "remove", "(", "win", ")", ";", "}", "if", "(", "oldVisibility", "==", "View", ".", "GONE", ")", "{", "win", ".", "mEnterAnimationPending", "=", "true", ";", "}", "if", "(", "displayed", ")", "{", "if", "(", "win", ".", "mSurface", "!=", "null", "&&", "!", "win", ".", "mDrawPending", "&&", "!", "win", ".", "mCommitDrawPending", "&&", "!", "mDisplayFrozen", "&&", "mDisplayEnabled", "&&", "mPolicy", ".", "isScreenOnFully", "(", ")", ")", "{", "applyEnterAnimationLocked", "(", "win", ")", ";", "}", "if", "(", "(", "win", ".", "mAttrs", ".", "flags", "&", "WindowManager", ".", "LayoutParams", ".", "FLAG_TURN_SCREEN_ON", ")", "!=", "0", ")", "{", "if", "(", "DEBUG_VISIBILITY", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "win", ")", ";", "win", ".", "mTurnOnScreen", "=", "true", ";", "}", "int", "diff", "=", "0", ";", "if", "(", "win", ".", "mConfiguration", "!=", "mCurConfiguration", "&&", "(", "win", ".", "mConfiguration", "==", "null", "||", "(", "diff", "=", "mCurConfiguration", ".", "diff", "(", "win", ".", "mConfiguration", ")", ")", "!=", "0", ")", ")", "{", "win", ".", "mConfiguration", "=", "mCurConfiguration", ";", "if", "(", "DEBUG_CONFIGURATION", ")", "{", "Slog", ".", "i", "(", "TAG", ",", "\"Window", "\"", "+", "win", "+", "\"\"", "+", "win", ".", "mConfiguration", "+", "\"", "/", "0x\"", "+", "Integer", ".", "toHexString", "(", "diff", ")", ")", ";", "}", "outConfig", ".", "setTo", "(", "mCurConfiguration", ")", ";", "}", "}", "if", "(", "(", "attrChanges", "&", "WindowManager", ".", "LayoutParams", ".", "FORMAT_CHANGED", ")", "!=", "0", ")", "{", "win", ".", "destroySurfaceLocked", "(", ")", ";", "displayed", "=", "true", ";", "surfaceChanged", "=", "true", ";", "}", "try", "{", "if", "(", "win", ".", "mSurface", "==", "null", ")", "{", "surfaceChanged", "=", "true", ";", "}", "Surface", "surface", "=", "win", ".", "createSurfaceLocked", "(", ")", ";", "if", "(", "surface", "!=", "null", ")", "{", "outSurface", ".", "copyFrom", "(", "surface", ")", ";", "win", ".", "mReportDestroySurface", "=", "false", ";", "win", ".", "mSurfacePendingDestroy", "=", "false", ";", "if", "(", "SHOW_TRANSACTIONS", ")", "Slog", ".", "i", "(", "TAG", ",", "\"\"", "+", "outSurface", "+", "\":", "copied\"", ")", ";", "}", "else", "{", "outSurface", ".", "release", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "mInputMonitor", ".", "updateInputWindowsLw", "(", "true", ")", ";", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "client", "+", "\"", "(\"", "+", "win", ".", "mAttrs", ".", "getTitle", "(", ")", "+", "\")\"", ",", "e", ")", ";", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "return", "0", ";", "}", "if", "(", "displayed", ")", "{", "focusMayChange", "=", "true", ";", "}", "if", "(", "win", ".", "mAttrs", ".", "type", "==", "TYPE_INPUT_METHOD", "&&", "mInputMethodWindow", "==", "null", ")", "{", "mInputMethodWindow", "=", "win", ";", "imMayMove", "=", "true", ";", "}", "if", "(", "win", ".", "mAttrs", ".", "type", "==", "TYPE_BASE_APPLICATION", "&&", "win", ".", "mAppToken", "!=", "null", "&&", "win", ".", "mAppToken", ".", "startingWindow", "!=", "null", ")", "{", "final", "int", "mask", "=", "WindowManager", ".", "LayoutParams", ".", "FLAG_SHOW_WHEN_LOCKED", "|", "WindowManager", ".", "LayoutParams", ".", "FLAG_DISMISS_KEYGUARD", "|", "WindowManager", ".", "LayoutParams", ".", "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON", ";", "WindowManager", ".", "LayoutParams", "sa", "=", "win", ".", "mAppToken", ".", "startingWindow", ".", "mAttrs", ";", "sa", ".", "flags", "=", "(", "sa", ".", "flags", "&", "~", "mask", ")", "|", "(", "win", ".", "mAttrs", ".", "flags", "&", "mask", ")", ";", "}", "}", "else", "{", "win", ".", "mEnterAnimationPending", "=", "false", ";", "if", "(", "win", ".", "mSurface", "!=", "null", ")", "{", "if", "(", "DEBUG_VISIBILITY", ")", "Slog", ".", "i", "(", "TAG", ",", "\"\"", "+", "win", "+", "\":", "mExiting=\"", "+", "win", ".", "mExiting", "+", "\"\"", "+", "win", ".", "mSurfacePendingDestroy", ")", ";", "if", "(", "!", "win", ".", "mExiting", "||", "win", ".", "mSurfacePendingDestroy", ")", "{", "surfaceChanged", "=", "true", ";", "int", "transit", "=", "WindowManagerPolicy", ".", "TRANSIT_EXIT", ";", "if", "(", "win", ".", "getAttrs", "(", ")", ".", "type", "==", "TYPE_APPLICATION_STARTING", ")", "{", "transit", "=", "WindowManagerPolicy", ".", "TRANSIT_PREVIEW_DONE", ";", "}", "if", "(", "!", "win", ".", "mSurfacePendingDestroy", "&&", "win", ".", "isWinVisibleLw", "(", ")", "&&", "applyAnimationLocked", "(", "win", ",", "transit", ",", "false", ")", ")", "{", "focusMayChange", "=", "true", ";", "win", ".", "mExiting", "=", "true", ";", "}", "else", "if", "(", "win", ".", "isAnimating", "(", ")", ")", "{", "win", ".", "mExiting", "=", "true", ";", "}", "else", "if", "(", "win", "==", "mWallpaperTarget", ")", "{", "win", ".", "mExiting", "=", "true", ";", "win", ".", "mAnimating", "=", "true", ";", "}", "else", "{", "if", "(", "mInputMethodWindow", "==", "win", ")", "{", "mInputMethodWindow", "=", "null", ";", "}", "win", ".", "destroySurfaceLocked", "(", ")", ";", "}", "}", "}", "if", "(", "win", ".", "mSurface", "==", "null", "||", "(", "win", ".", "getAttrs", "(", ")", ".", "flags", "&", "WindowManager", ".", "LayoutParams", ".", "FLAG_KEEP_SURFACE_WHILE_ANIMATING", ")", "==", "0", "||", "win", ".", "mSurfacePendingDestroy", ")", "{", "win", ".", "mSurfacePendingDestroy", "=", "false", ";", "outSurface", ".", "release", "(", ")", ";", "if", "(", "DEBUG_VISIBILITY", ")", "Slog", ".", "i", "(", "TAG", ",", "\"\"", "+", "win", ")", ";", "}", "else", "if", "(", "win", ".", "mSurface", "!=", "null", ")", "{", "if", "(", "DEBUG_VISIBILITY", ")", "Slog", ".", "i", "(", "TAG", ",", "\"\"", "+", "win", ")", ";", "win", ".", "mReportDestroySurface", "=", "true", ";", "outSurface", ".", "copyFrom", "(", "win", ".", "mSurface", ")", ";", "}", "}", "if", "(", "focusMayChange", ")", "{", "if", "(", "updateFocusedWindowLocked", "(", "UPDATE_FOCUS_WILL_PLACE_SURFACES", ",", "false", ")", ")", "{", "imMayMove", "=", "false", ";", "}", "}", "boolean", "assignLayers", "=", "false", ";", "if", "(", "imMayMove", ")", "{", "if", "(", "moveInputMethodWindowsIfNeededLocked", "(", "false", ")", "||", "displayed", ")", "{", "assignLayers", "=", "true", ";", "}", "}", "if", "(", "wallpaperMayMove", ")", "{", "if", "(", "(", "adjustWallpaperWindowsLocked", "(", ")", "&", "ADJUST_WALLPAPER_LAYERS_CHANGED", ")", "!=", "0", ")", "{", "assignLayers", "=", "true", ";", "}", "}", "mLayoutNeeded", "=", "true", ";", "win", ".", "mGivenInsetsPending", "=", "(", "flags", "&", "WindowManagerImpl", ".", "RELAYOUT_INSETS_PENDING", ")", "!=", "0", ";", "if", "(", "assignLayers", ")", "{", "assignLayersLocked", "(", ")", ";", "}", "configChanged", "=", "updateOrientationFromAppTokensLocked", "(", "false", ")", ";", "performLayoutAndPlaceSurfacesLocked", "(", ")", ";", "if", "(", "displayed", "&&", "win", ".", "mIsWallpaper", ")", "{", "updateWallpaperOffsetLocked", "(", "win", ",", "mAppDisplayWidth", ",", "mAppDisplayHeight", ",", "false", ")", ";", "}", "if", "(", "win", ".", "mAppToken", "!=", "null", ")", "{", "win", ".", "mAppToken", ".", "updateReportedVisibilityLocked", "(", ")", ";", "}", "outFrame", ".", "set", "(", "win", ".", "mCompatFrame", ")", ";", "outContentInsets", ".", "set", "(", "win", ".", "mContentInsets", ")", ";", "outVisibleInsets", ".", "set", "(", "win", ".", "mVisibleInsets", ")", ";", "if", "(", "localLOGV", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "client", ".", "asBinder", "(", ")", "+", "\"\"", "+", "requestedWidth", "+", "\"\"", "+", "requestedHeight", "+", "\"\"", "+", "viewVisibility", "+", "\"\"", "+", "outFrame", "+", "\",", "surface=\"", "+", "outSurface", ")", ";", "if", "(", "localLOGV", "||", "DEBUG_FOCUS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Relayout", "of", "\"", "+", "win", "+", "\"\"", "+", "focusMayChange", ")", ";", "inTouchMode", "=", "mInTouchMode", ";", "mInputMonitor", ".", "updateInputWindowsLw", "(", "true", ")", ";", "}", "if", "(", "configChanged", ")", "{", "sendNewConfiguration", "(", ")", ";", "}", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "return", "(", "inTouchMode", "?", "WindowManagerImpl", ".", "RELAYOUT_RES_IN_TOUCH_MODE", ":", "0", ")", "|", "(", "displayed", "?", "WindowManagerImpl", ".", "RELAYOUT_RES_FIRST_TIME", ":", "0", ")", "|", "(", "surfaceChanged", "?", "WindowManagerImpl", ".", "RELAYOUT_RES_SURFACE_CHANGED", ":", "0", ")", ";", "}", "public", "void", "performDeferredDestroyWindow", "(", "Session", "session", ",", "IWindow", "client", ")", "{", "long", "origId", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "try", "{", "synchronized", "(", "mWindowMap", ")", "{", "WindowState", "win", "=", "windowForClientLocked", "(", "session", ",", "client", ",", "false", ")", ";", "if", "(", "win", "==", "null", ")", "{", "return", ";", "}", "win", ".", "destroyDeferredSurfaceLocked", "(", ")", ";", "}", "}", "finally", "{", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "}", "}", "public", "boolean", "outOfMemoryWindow", "(", "Session", "session", ",", "IWindow", "client", ")", "{", "long", "origId", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "try", "{", "synchronized", "(", "mWindowMap", ")", "{", "WindowState", "win", "=", "windowForClientLocked", "(", "session", ",", "client", ",", "false", ")", ";", "if", "(", "win", "==", "null", ")", "{", "return", "false", ";", "}", "return", "reclaimSomeSurfaceMemoryLocked", "(", "win", ",", "\"from-client\"", ",", "false", ")", ";", "}", "}", "finally", "{", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "}", "}", "public", "void", "finishDrawingWindow", "(", "Session", "session", ",", "IWindow", "client", ")", "{", "final", "long", "origId", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "synchronized", "(", "mWindowMap", ")", "{", "WindowState", "win", "=", "windowForClientLocked", "(", "session", ",", "client", ",", "false", ")", ";", "if", "(", "win", "!=", "null", "&&", "win", ".", "finishDrawingLocked", "(", ")", ")", "{", "if", "(", "(", "win", ".", "mAttrs", ".", "flags", "&", "FLAG_SHOW_WALLPAPER", ")", "!=", "0", ")", "{", "adjustWallpaperWindowsLocked", "(", ")", ";", "}", "mLayoutNeeded", "=", "true", ";", "performLayoutAndPlaceSurfacesLocked", "(", ")", ";", "}", "}", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "}", "public", "float", "getWindowCompatibilityScale", "(", "IBinder", "windowToken", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "WindowState", "windowState", "=", "mWindowMap", ".", "get", "(", "windowToken", ")", ";", "return", "(", "windowState", "!=", "null", ")", "?", "windowState", ".", "mGlobalScale", ":", "1.0f", ";", "}", "}", "private", "AttributeCache", ".", "Entry", "getCachedAnimations", "(", "WindowManager", ".", "LayoutParams", "lp", ")", "{", "if", "(", "DEBUG_ANIM", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "(", "lp", "!=", "null", "?", "lp", ".", "packageName", ":", "null", ")", "+", "\"", "resId=0x\"", "+", "(", "lp", "!=", "null", "?", "Integer", ".", "toHexString", "(", "lp", ".", "windowAnimations", ")", ":", "null", ")", ")", ";", "if", "(", "lp", "!=", "null", "&&", "lp", ".", "windowAnimations", "!=", "0", ")", "{", "String", "packageName", "=", "lp", ".", "packageName", "!=", "null", "?", "lp", ".", "packageName", ":", "\"android\"", ";", "int", "resId", "=", "lp", ".", "windowAnimations", ";", "if", "(", "(", "resId", "&", "0xFF000000", ")", "==", "0x01000000", ")", "{", "packageName", "=", "\"android\"", ";", "}", "if", "(", "DEBUG_ANIM", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "packageName", ")", ";", "return", "AttributeCache", ".", "instance", "(", ")", ".", "get", "(", "packageName", ",", "resId", ",", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation", ")", ";", "}", "return", "null", ";", "}", "private", "AttributeCache", ".", "Entry", "getCachedAnimations", "(", "String", "packageName", ",", "int", "resId", ")", "{", "if", "(", "DEBUG_ANIM", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "packageName", "+", "\"", "resId=0x\"", "+", "Integer", ".", "toHexString", "(", "resId", ")", ")", ";", "if", "(", "packageName", "!=", "null", ")", "{", "if", "(", "(", "resId", "&", "0xFF000000", ")", "==", "0x01000000", ")", "{", "packageName", "=", "\"android\"", ";", "}", "if", "(", "DEBUG_ANIM", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "packageName", ")", ";", "return", "AttributeCache", ".", "instance", "(", ")", ".", "get", "(", "packageName", ",", "resId", ",", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation", ")", ";", "}", "return", "null", ";", "}", "void", "applyEnterAnimationLocked", "(", "WindowState", "win", ")", "{", "int", "transit", "=", "WindowManagerPolicy", ".", "TRANSIT_SHOW", ";", "if", "(", "win", ".", "mEnterAnimationPending", ")", "{", "win", ".", "mEnterAnimationPending", "=", "false", ";", "transit", "=", "WindowManagerPolicy", ".", "TRANSIT_ENTER", ";", "}", "applyAnimationLocked", "(", "win", ",", "transit", ",", "true", ")", ";", "}", "boolean", "applyAnimationLocked", "(", "WindowState", "win", ",", "int", "transit", ",", "boolean", "isEntrance", ")", "{", "if", "(", "win", ".", "mLocalAnimating", "&&", "win", ".", "mAnimationIsEntrance", "==", "isEntrance", ")", "{", "return", "true", ";", "}", "if", "(", "!", "mDisplayFrozen", "&&", "mDisplayEnabled", "&&", "mPolicy", ".", "isScreenOnFully", "(", ")", ")", "{", "int", "anim", "=", "mPolicy", ".", "selectAnimationLw", "(", "win", ",", "transit", ")", ";", "int", "attr", "=", "-", "1", ";", "Animation", "a", "=", "null", ";", "if", "(", "anim", "!=", "0", ")", "{", "a", "=", "AnimationUtils", ".", "loadAnimation", "(", "mContext", ",", "anim", ")", ";", "}", "else", "{", "switch", "(", "transit", ")", "{", "case", "WindowManagerPolicy", ".", "TRANSIT_ENTER", ":", "attr", "=", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_windowEnterAnimation", ";", "break", ";", "case", "WindowManagerPolicy", ".", "TRANSIT_EXIT", ":", "attr", "=", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_windowExitAnimation", ";", "break", ";", "case", "WindowManagerPolicy", ".", "TRANSIT_SHOW", ":", "attr", "=", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_windowShowAnimation", ";", "break", ";", "case", "WindowManagerPolicy", ".", "TRANSIT_HIDE", ":", "attr", "=", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_windowHideAnimation", ";", "break", ";", "}", "if", "(", "attr", ">=", "0", ")", "{", "a", "=", "loadAnimation", "(", "win", ".", "mAttrs", ",", "attr", ")", ";", "}", "}", "if", "(", "DEBUG_ANIM", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "win", "+", "\"", "anim=\"", "+", "anim", "+", "\"", "attr=0x\"", "+", "Integer", ".", "toHexString", "(", "attr", ")", "+", "\"", "mAnimation=\"", "+", "win", ".", "mAnimation", "+", "\"", "isEntrance=\"", "+", "isEntrance", ")", ";", "if", "(", "a", "!=", "null", ")", "{", "if", "(", "DEBUG_ANIM", ")", "{", "RuntimeException", "e", "=", "null", ";", "if", "(", "!", "HIDE_STACK_CRAWLS", ")", "{", "e", "=", "new", "RuntimeException", "(", ")", ";", "e", ".", "fillInStackTrace", "(", ")", ";", "}", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "a", "+", "\"", "for", "\"", "+", "win", ",", "e", ")", ";", "}", "win", ".", "setAnimation", "(", "a", ")", ";", "win", ".", "mAnimationIsEntrance", "=", "isEntrance", ";", "}", "}", "else", "{", "win", ".", "clearAnimation", "(", ")", ";", "}", "return", "win", ".", "mAnimation", "!=", "null", ";", "}", "private", "Animation", "loadAnimation", "(", "WindowManager", ".", "LayoutParams", "lp", ",", "int", "animAttr", ")", "{", "int", "anim", "=", "0", ";", "Context", "context", "=", "mContext", ";", "if", "(", "animAttr", ">=", "0", ")", "{", "AttributeCache", ".", "Entry", "ent", "=", "getCachedAnimations", "(", "lp", ")", ";", "if", "(", "ent", "!=", "null", ")", "{", "context", "=", "ent", ".", "context", ";", "anim", "=", "ent", ".", "array", ".", "getResourceId", "(", "animAttr", ",", "0", ")", ";", "}", "}", "if", "(", "anim", "!=", "0", ")", "{", "return", "AnimationUtils", ".", "loadAnimation", "(", "context", ",", "anim", ")", ";", "}", "return", "null", ";", "}", "private", "Animation", "loadAnimation", "(", "String", "packageName", ",", "int", "resId", ")", "{", "int", "anim", "=", "0", ";", "Context", "context", "=", "mContext", ";", "if", "(", "resId", ">=", "0", ")", "{", "AttributeCache", ".", "Entry", "ent", "=", "getCachedAnimations", "(", "packageName", ",", "resId", ")", ";", "if", "(", "ent", "!=", "null", ")", "{", "context", "=", "ent", ".", "context", ";", "anim", "=", "resId", ";", "}", "}", "if", "(", "anim", "!=", "0", ")", "{", "return", "AnimationUtils", ".", "loadAnimation", "(", "context", ",", "anim", ")", ";", "}", "return", "null", ";", "}", "private", "boolean", "applyAnimationLocked", "(", "AppWindowToken", "wtoken", ",", "WindowManager", ".", "LayoutParams", "lp", ",", "int", "transit", ",", "boolean", "enter", ")", "{", "if", "(", "!", "mDisplayFrozen", "&&", "mDisplayEnabled", "&&", "mPolicy", ".", "isScreenOnFully", "(", ")", ")", "{", "Animation", "a", ";", "if", "(", "mNextAppTransitionPackage", "!=", "null", ")", "{", "a", "=", "loadAnimation", "(", "mNextAppTransitionPackage", ",", "enter", "?", "mNextAppTransitionEnter", ":", "mNextAppTransitionExit", ")", ";", "}", "else", "{", "int", "animAttr", "=", "0", ";", "switch", "(", "transit", ")", "{", "case", "WindowManagerPolicy", ".", "TRANSIT_ACTIVITY_OPEN", ":", "animAttr", "=", "enter", "?", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_activityOpenEnterAnimation", ":", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_activityOpenExitAnimation", ";", "break", ";", "case", "WindowManagerPolicy", ".", "TRANSIT_ACTIVITY_CLOSE", ":", "animAttr", "=", "enter", "?", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_activityCloseEnterAnimation", ":", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_activityCloseExitAnimation", ";", "break", ";", "case", "WindowManagerPolicy", ".", "TRANSIT_TASK_OPEN", ":", "animAttr", "=", "enter", "?", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_taskOpenEnterAnimation", ":", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_taskOpenExitAnimation", ";", "break", ";", "case", "WindowManagerPolicy", ".", "TRANSIT_TASK_CLOSE", ":", "animAttr", "=", "enter", "?", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_taskCloseEnterAnimation", ":", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_taskCloseExitAnimation", ";", "break", ";", "case", "WindowManagerPolicy", ".", "TRANSIT_TASK_TO_FRONT", ":", "animAttr", "=", "enter", "?", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_taskToFrontEnterAnimation", ":", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_taskToFrontExitAnimation", ";", "break", ";", "case", "WindowManagerPolicy", ".", "TRANSIT_TASK_TO_BACK", ":", "animAttr", "=", "enter", "?", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_taskToBackEnterAnimation", ":", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_taskToBackExitAnimation", ";", "break", ";", "case", "WindowManagerPolicy", ".", "TRANSIT_WALLPAPER_OPEN", ":", "animAttr", "=", "enter", "?", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_wallpaperOpenEnterAnimation", ":", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_wallpaperOpenExitAnimation", ";", "break", ";", "case", "WindowManagerPolicy", ".", "TRANSIT_WALLPAPER_CLOSE", ":", "animAttr", "=", "enter", "?", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_wallpaperCloseEnterAnimation", ":", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_wallpaperCloseExitAnimation", ";", "break", ";", "case", "WindowManagerPolicy", ".", "TRANSIT_WALLPAPER_INTRA_OPEN", ":", "animAttr", "=", "enter", "?", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_wallpaperIntraOpenEnterAnimation", ":", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_wallpaperIntraOpenExitAnimation", ";", "break", ";", "case", "WindowManagerPolicy", ".", "TRANSIT_WALLPAPER_INTRA_CLOSE", ":", "animAttr", "=", "enter", "?", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_wallpaperIntraCloseEnterAnimation", ":", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "WindowAnimation_wallpaperIntraCloseExitAnimation", ";", "break", ";", "}", "a", "=", "animAttr", "!=", "0", "?", "loadAnimation", "(", "lp", ",", "animAttr", ")", ":", "null", ";", "if", "(", "DEBUG_ANIM", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", "+", "\"", "anim=\"", "+", "a", "+", "\"", "animAttr=0x\"", "+", "Integer", ".", "toHexString", "(", "animAttr", ")", "+", "\"", "transit=\"", "+", "transit", ")", ";", "}", "if", "(", "a", "!=", "null", ")", "{", "if", "(", "DEBUG_ANIM", ")", "{", "RuntimeException", "e", "=", "null", ";", "if", "(", "!", "HIDE_STACK_CRAWLS", ")", "{", "e", "=", "new", "RuntimeException", "(", ")", ";", "e", ".", "fillInStackTrace", "(", ")", ";", "}", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "a", "+", "\"", "for", "\"", "+", "wtoken", ",", "e", ")", ";", "}", "wtoken", ".", "setAnimation", "(", "a", ")", ";", "}", "}", "else", "{", "wtoken", ".", "clearAnimation", "(", ")", ";", "}", "return", "wtoken", ".", "animation", "!=", "null", ";", "}", "public", "void", "validateAppTokens", "(", "List", "<", "IBinder", ">", "tokens", ")", "{", "int", "v", "=", "tokens", ".", "size", "(", ")", "-", "1", ";", "int", "m", "=", "mAppTokens", ".", "size", "(", ")", "-", "1", ";", "while", "(", "v", ">=", "0", "&&", "m", ">=", "0", ")", "{", "AppWindowToken", "wtoken", "=", "mAppTokens", ".", "get", "(", "m", ")", ";", "if", "(", "wtoken", ".", "removed", ")", "{", "m", "--", ";", "continue", ";", "}", "if", "(", "tokens", ".", "get", "(", "v", ")", "!=", "wtoken", ".", "token", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "tokens", ".", "get", "(", "v", ")", "+", "\"", "@", "\"", "+", "v", "+", "\"\"", "+", "wtoken", ".", "token", "+", "\"", "@", "\"", "+", "m", ")", ";", "}", "v", "--", ";", "m", "--", ";", "}", "while", "(", "v", ">=", "0", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "tokens", ".", "get", "(", "v", ")", "+", "\"", "@", "\"", "+", "v", ")", ";", "v", "--", ";", "}", "while", "(", "m", ">=", "0", ")", "{", "AppWindowToken", "wtoken", "=", "mAppTokens", ".", "get", "(", "m", ")", ";", "if", "(", "!", "wtoken", ".", "removed", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "wtoken", ".", "token", "+", "\"", "@", "\"", "+", "m", ")", ";", "}", "m", "--", ";", "}", "}", "boolean", "checkCallingPermission", "(", "String", "permission", ",", "String", "func", ")", "{", "if", "(", "Binder", ".", "getCallingPid", "(", ")", "==", "Process", ".", "myPid", "(", ")", ")", "{", "return", "true", ";", "}", "if", "(", "mContext", ".", "checkCallingPermission", "(", "permission", ")", "==", "PackageManager", ".", "PERMISSION_GRANTED", ")", "{", "return", "true", ";", "}", "String", "msg", "=", "\"\"", "+", "func", "+", "\"", "from", "pid=\"", "+", "Binder", ".", "getCallingPid", "(", ")", "+", "\",", "uid=\"", "+", "Binder", ".", "getCallingUid", "(", ")", "+", "\"", "requires", "\"", "+", "permission", ";", "Slog", ".", "w", "(", "TAG", ",", "msg", ")", ";", "return", "false", ";", "}", "AppWindowToken", "findAppWindowToken", "(", "IBinder", "token", ")", "{", "WindowToken", "wtoken", "=", "mTokenMap", ".", "get", "(", "token", ")", ";", "if", "(", "wtoken", "==", "null", ")", "{", "return", "null", ";", "}", "return", "wtoken", ".", "appWindowToken", ";", "}", "public", "void", "addWindowToken", "(", "IBinder", "token", ",", "int", "type", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "MANAGE_APP_TOKENS", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "synchronized", "(", "mWindowMap", ")", "{", "WindowToken", "wtoken", "=", "mTokenMap", ".", "get", "(", "token", ")", ";", "if", "(", "wtoken", "!=", "null", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "token", ")", ";", "return", ";", "}", "wtoken", "=", "new", "WindowToken", "(", "this", ",", "token", ",", "type", ",", "true", ")", ";", "mTokenMap", ".", "put", "(", "token", ",", "wtoken", ")", ";", "if", "(", "type", "==", "TYPE_WALLPAPER", ")", "{", "mWallpaperTokens", ".", "add", "(", "wtoken", ")", ";", "}", "}", "}", "public", "void", "removeWindowToken", "(", "IBinder", "token", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "MANAGE_APP_TOKENS", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "final", "long", "origId", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "synchronized", "(", "mWindowMap", ")", "{", "WindowToken", "wtoken", "=", "mTokenMap", ".", "remove", "(", "token", ")", ";", "if", "(", "wtoken", "!=", "null", ")", "{", "boolean", "delayed", "=", "false", ";", "if", "(", "!", "wtoken", ".", "hidden", ")", "{", "wtoken", ".", "hidden", "=", "true", ";", "final", "int", "N", "=", "wtoken", ".", "windows", ".", "size", "(", ")", ";", "boolean", "changed", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "WindowState", "win", "=", "wtoken", ".", "windows", ".", "get", "(", "i", ")", ";", "if", "(", "win", ".", "isAnimating", "(", ")", ")", "{", "delayed", "=", "true", ";", "}", "if", "(", "win", ".", "isVisibleNow", "(", ")", ")", "{", "applyAnimationLocked", "(", "win", ",", "WindowManagerPolicy", ".", "TRANSIT_EXIT", ",", "false", ")", ";", "changed", "=", "true", ";", "}", "}", "if", "(", "changed", ")", "{", "mLayoutNeeded", "=", "true", ";", "performLayoutAndPlaceSurfacesLocked", "(", ")", ";", "updateFocusedWindowLocked", "(", "UPDATE_FOCUS_NORMAL", ",", "false", ")", ";", "}", "if", "(", "delayed", ")", "{", "mExitingTokens", ".", "add", "(", "wtoken", ")", ";", "}", "else", "if", "(", "wtoken", ".", "windowType", "==", "TYPE_WALLPAPER", ")", "{", "mWallpaperTokens", ".", "remove", "(", "wtoken", ")", ";", "}", "}", "mInputMonitor", ".", "updateInputWindowsLw", "(", "true", ")", ";", "}", "else", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "token", ")", ";", "}", "}", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "}", "public", "void", "addAppToken", "(", "int", "addPos", ",", "IApplicationToken", "token", ",", "int", "groupId", ",", "int", "requestedOrientation", ",", "boolean", "fullscreen", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "MANAGE_APP_TOKENS", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "long", "inputDispatchingTimeoutNanos", ";", "try", "{", "inputDispatchingTimeoutNanos", "=", "token", ".", "getKeyDispatchingTimeout", "(", ")", "*", "1000000L", ";", "}", "catch", "(", "RemoteException", "ex", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ",", "ex", ")", ";", "inputDispatchingTimeoutNanos", "=", "DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS", ";", "}", "synchronized", "(", "mWindowMap", ")", "{", "AppWindowToken", "wtoken", "=", "findAppWindowToken", "(", "token", ".", "asBinder", "(", ")", ")", ";", "if", "(", "wtoken", "!=", "null", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "token", ")", ";", "return", ";", "}", "wtoken", "=", "new", "AppWindowToken", "(", "this", ",", "token", ")", ";", "wtoken", ".", "inputDispatchingTimeoutNanos", "=", "inputDispatchingTimeoutNanos", ";", "wtoken", ".", "groupId", "=", "groupId", ";", "wtoken", ".", "appFullscreen", "=", "fullscreen", ";", "wtoken", ".", "requestedOrientation", "=", "requestedOrientation", ";", "if", "(", "DEBUG_TOKEN_MOVEMENT", "||", "DEBUG_ADD_REMOVE", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", ")", ";", "mAppTokens", ".", "add", "(", "addPos", ",", "wtoken", ")", ";", "mTokenMap", ".", "put", "(", "token", ".", "asBinder", "(", ")", ",", "wtoken", ")", ";", "wtoken", ".", "hidden", "=", "true", ";", "wtoken", ".", "hiddenRequested", "=", "true", ";", "}", "}", "public", "void", "setAppGroupId", "(", "IBinder", "token", ",", "int", "groupId", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "MANAGE_APP_TOKENS", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "synchronized", "(", "mWindowMap", ")", "{", "AppWindowToken", "wtoken", "=", "findAppWindowToken", "(", "token", ")", ";", "if", "(", "wtoken", "==", "null", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "token", ")", ";", "return", ";", "}", "wtoken", ".", "groupId", "=", "groupId", ";", "}", "}", "public", "int", "getOrientationFromWindowsLocked", "(", ")", "{", "if", "(", "mDisplayFrozen", "||", "mOpeningApps", ".", "size", "(", ")", ">", "0", "||", "mClosingApps", ".", "size", "(", ")", ">", "0", ")", "{", "return", "mLastWindowForcedOrientation", ";", "}", "int", "pos", "=", "mWindows", ".", "size", "(", ")", "-", "1", ";", "while", "(", "pos", ">=", "0", ")", "{", "WindowState", "wtoken", "=", "mWindows", ".", "get", "(", "pos", ")", ";", "pos", "--", ";", "if", "(", "wtoken", ".", "mAppToken", "!=", "null", ")", "{", "return", "(", "mLastWindowForcedOrientation", "=", "ActivityInfo", ".", "SCREEN_ORIENTATION_UNSPECIFIED", ")", ";", "}", "if", "(", "!", "wtoken", ".", "isVisibleLw", "(", ")", "||", "!", "wtoken", ".", "mPolicyVisibilityAfterAnim", ")", "{", "continue", ";", "}", "int", "req", "=", "wtoken", ".", "mAttrs", ".", "screenOrientation", ";", "if", "(", "(", "req", "==", "ActivityInfo", ".", "SCREEN_ORIENTATION_UNSPECIFIED", ")", "||", "(", "req", "==", "ActivityInfo", ".", "SCREEN_ORIENTATION_BEHIND", ")", ")", "{", "continue", ";", "}", "else", "{", "return", "(", "mLastWindowForcedOrientation", "=", "req", ")", ";", "}", "}", "return", "(", "mLastWindowForcedOrientation", "=", "ActivityInfo", ".", "SCREEN_ORIENTATION_UNSPECIFIED", ")", ";", "}", "public", "int", "getOrientationFromAppTokensLocked", "(", ")", "{", "int", "pos", "=", "mAppTokens", ".", "size", "(", ")", "-", "1", ";", "int", "curGroup", "=", "0", ";", "int", "lastOrientation", "=", "ActivityInfo", ".", "SCREEN_ORIENTATION_UNSPECIFIED", ";", "boolean", "findingBehind", "=", "false", ";", "boolean", "haveGroup", "=", "false", ";", "boolean", "lastFullscreen", "=", "false", ";", "while", "(", "pos", ">=", "0", ")", "{", "AppWindowToken", "wtoken", "=", "mAppTokens", ".", "get", "(", "pos", ")", ";", "pos", "--", ";", "if", "(", "DEBUG_APP_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", ")", ";", "if", "(", "!", "findingBehind", "&&", "(", "!", "wtoken", ".", "hidden", "&&", "wtoken", ".", "hiddenRequested", ")", ")", "{", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Skipping", "\"", "+", "wtoken", "+", "\"\"", ")", ";", "continue", ";", "}", "if", "(", "!", "haveGroup", ")", "{", "if", "(", "wtoken", ".", "hiddenRequested", "||", "wtoken", ".", "willBeHidden", ")", "{", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Skipping", "\"", "+", "wtoken", "+", "\"\"", ")", ";", "continue", ";", "}", "haveGroup", "=", "true", ";", "curGroup", "=", "wtoken", ".", "groupId", ";", "lastOrientation", "=", "wtoken", ".", "requestedOrientation", ";", "}", "else", "if", "(", "curGroup", "!=", "wtoken", ".", "groupId", ")", "{", "if", "(", "lastOrientation", "!=", "ActivityInfo", ".", "SCREEN_ORIENTATION_BEHIND", "&&", "lastFullscreen", ")", "{", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Done", "at", "\"", "+", "wtoken", "+", "\"\"", "+", "lastOrientation", ")", ";", "return", "lastOrientation", ";", "}", "}", "int", "or", "=", "wtoken", ".", "requestedOrientation", ";", "lastFullscreen", "=", "wtoken", ".", "appFullscreen", ";", "if", "(", "lastFullscreen", "&&", "or", "!=", "ActivityInfo", ".", "SCREEN_ORIENTATION_BEHIND", ")", "{", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Done", "at", "\"", "+", "wtoken", "+", "\"\"", "+", "or", ")", ";", "return", "or", ";", "}", "if", "(", "or", "!=", "ActivityInfo", ".", "SCREEN_ORIENTATION_UNSPECIFIED", "&&", "or", "!=", "ActivityInfo", ".", "SCREEN_ORIENTATION_BEHIND", ")", "{", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Done", "at", "\"", "+", "wtoken", "+", "\"\"", "+", "or", ")", ";", "return", "or", ";", "}", "findingBehind", "|=", "(", "or", "==", "ActivityInfo", ".", "SCREEN_ORIENTATION_BEHIND", ")", ";", "}", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "return", "ActivityInfo", ".", "SCREEN_ORIENTATION_UNSPECIFIED", ";", "}", "public", "Configuration", "updateOrientationFromAppTokens", "(", "Configuration", "currentConfig", ",", "IBinder", "freezeThisOneIfNeeded", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "MANAGE_APP_TOKENS", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "Configuration", "config", "=", "null", ";", "long", "ident", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "synchronized", "(", "mWindowMap", ")", "{", "config", "=", "updateOrientationFromAppTokensLocked", "(", "currentConfig", ",", "freezeThisOneIfNeeded", ")", ";", "}", "Binder", ".", "restoreCallingIdentity", "(", "ident", ")", ";", "return", "config", ";", "}", "private", "Configuration", "updateOrientationFromAppTokensLocked", "(", "Configuration", "currentConfig", ",", "IBinder", "freezeThisOneIfNeeded", ")", "{", "Configuration", "config", "=", "null", ";", "if", "(", "updateOrientationFromAppTokensLocked", "(", "false", ")", ")", "{", "if", "(", "freezeThisOneIfNeeded", "!=", "null", ")", "{", "AppWindowToken", "wtoken", "=", "findAppWindowToken", "(", "freezeThisOneIfNeeded", ")", ";", "if", "(", "wtoken", "!=", "null", ")", "{", "startAppFreezingScreenLocked", "(", "wtoken", ",", "ActivityInfo", ".", "CONFIG_ORIENTATION", ")", ";", "}", "}", "config", "=", "computeNewConfigurationLocked", "(", ")", ";", "}", "else", "if", "(", "currentConfig", "!=", "null", ")", "{", "mTempConfiguration", ".", "setToDefaults", "(", ")", ";", "mTempConfiguration", ".", "fontScale", "=", "currentConfig", ".", "fontScale", ";", "if", "(", "computeNewConfigurationLocked", "(", "mTempConfiguration", ")", ")", "{", "if", "(", "currentConfig", ".", "diff", "(", "mTempConfiguration", ")", "!=", "0", ")", "{", "mWaitingForConfig", "=", "true", ";", "mLayoutNeeded", "=", "true", ";", "startFreezingDisplayLocked", "(", "false", ")", ";", "config", "=", "new", "Configuration", "(", "mTempConfiguration", ")", ";", "}", "}", "}", "return", "config", ";", "}", "boolean", "updateOrientationFromAppTokensLocked", "(", "boolean", "inTransaction", ")", "{", "boolean", "changed", "=", "false", ";", "long", "ident", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "try", "{", "int", "req", "=", "computeForcedAppOrientationLocked", "(", ")", ";", "if", "(", "req", "!=", "mForcedAppOrientation", ")", "{", "mForcedAppOrientation", "=", "req", ";", "mPolicy", ".", "setCurrentOrientationLw", "(", "req", ")", ";", "if", "(", "updateRotationUncheckedLocked", "(", "inTransaction", ")", ")", "{", "changed", "=", "true", ";", "}", "}", "return", "changed", ";", "}", "finally", "{", "Binder", ".", "restoreCallingIdentity", "(", "ident", ")", ";", "}", "}", "int", "computeForcedAppOrientationLocked", "(", ")", "{", "int", "req", "=", "getOrientationFromWindowsLocked", "(", ")", ";", "if", "(", "req", "==", "ActivityInfo", ".", "SCREEN_ORIENTATION_UNSPECIFIED", ")", "{", "req", "=", "getOrientationFromAppTokensLocked", "(", ")", ";", "}", "return", "req", ";", "}", "public", "void", "setNewConfiguration", "(", "Configuration", "config", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "MANAGE_APP_TOKENS", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "synchronized", "(", "mWindowMap", ")", "{", "mCurConfiguration", "=", "new", "Configuration", "(", "config", ")", ";", "mWaitingForConfig", "=", "false", ";", "performLayoutAndPlaceSurfacesLocked", "(", ")", ";", "}", "}", "public", "void", "setAppOrientation", "(", "IApplicationToken", "token", ",", "int", "requestedOrientation", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "MANAGE_APP_TOKENS", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "synchronized", "(", "mWindowMap", ")", "{", "AppWindowToken", "wtoken", "=", "findAppWindowToken", "(", "token", ".", "asBinder", "(", ")", ")", ";", "if", "(", "wtoken", "==", "null", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "token", ")", ";", "return", ";", "}", "wtoken", ".", "requestedOrientation", "=", "requestedOrientation", ";", "}", "}", "public", "int", "getAppOrientation", "(", "IApplicationToken", "token", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "AppWindowToken", "wtoken", "=", "findAppWindowToken", "(", "token", ".", "asBinder", "(", ")", ")", ";", "if", "(", "wtoken", "==", "null", ")", "{", "return", "ActivityInfo", ".", "SCREEN_ORIENTATION_UNSPECIFIED", ";", "}", "return", "wtoken", ".", "requestedOrientation", ";", "}", "}", "public", "void", "setFocusedApp", "(", "IBinder", "token", ",", "boolean", "moveFocusNow", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "MANAGE_APP_TOKENS", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "synchronized", "(", "mWindowMap", ")", "{", "boolean", "changed", "=", "false", ";", "if", "(", "token", "==", "null", ")", "{", "if", "(", "DEBUG_FOCUS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "mFocusedApp", ")", ";", "changed", "=", "mFocusedApp", "!=", "null", ";", "mFocusedApp", "=", "null", ";", "if", "(", "changed", ")", "{", "mInputMonitor", ".", "setFocusedAppLw", "(", "null", ")", ";", "}", "}", "else", "{", "AppWindowToken", "newFocus", "=", "findAppWindowToken", "(", "token", ")", ";", "if", "(", "newFocus", "==", "null", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "token", ")", ";", "return", ";", "}", "changed", "=", "mFocusedApp", "!=", "newFocus", ";", "mFocusedApp", "=", "newFocus", ";", "if", "(", "DEBUG_FOCUS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "mFocusedApp", ")", ";", "if", "(", "changed", ")", "{", "mInputMonitor", ".", "setFocusedAppLw", "(", "newFocus", ")", ";", "}", "}", "if", "(", "moveFocusNow", "&&", "changed", ")", "{", "final", "long", "origId", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "updateFocusedWindowLocked", "(", "UPDATE_FOCUS_NORMAL", ",", "true", ")", ";", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "}", "}", "}", "public", "void", "prepareAppTransition", "(", "int", "transit", ",", "boolean", "alwaysKeepCurrent", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "MANAGE_APP_TOKENS", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "DEBUG_APP_TRANSITIONS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "transit", "+", "\"\"", "+", "mNextAppTransition", ")", ";", "if", "(", "!", "mDisplayFrozen", "&&", "mDisplayEnabled", "&&", "mPolicy", ".", "isScreenOnFully", "(", ")", ")", "{", "if", "(", "mNextAppTransition", "==", "WindowManagerPolicy", ".", "TRANSIT_UNSET", "||", "mNextAppTransition", "==", "WindowManagerPolicy", ".", "TRANSIT_NONE", ")", "{", "mNextAppTransition", "=", "transit", ";", "}", "else", "if", "(", "!", "alwaysKeepCurrent", ")", "{", "if", "(", "transit", "==", "WindowManagerPolicy", ".", "TRANSIT_TASK_OPEN", "&&", "mNextAppTransition", "==", "WindowManagerPolicy", ".", "TRANSIT_TASK_CLOSE", ")", "{", "mNextAppTransition", "=", "transit", ";", "}", "else", "if", "(", "transit", "==", "WindowManagerPolicy", ".", "TRANSIT_ACTIVITY_OPEN", "&&", "mNextAppTransition", "==", "WindowManagerPolicy", ".", "TRANSIT_ACTIVITY_CLOSE", ")", "{", "mNextAppTransition", "=", "transit", ";", "}", "}", "mAppTransitionReady", "=", "false", ";", "mAppTransitionTimeout", "=", "false", ";", "mStartingIconInTransition", "=", "false", ";", "mSkipAppTransitionAnimation", "=", "false", ";", "mH", ".", "removeMessages", "(", "H", ".", "APP_TRANSITION_TIMEOUT", ")", ";", "mH", ".", "sendMessageDelayed", "(", "mH", ".", "obtainMessage", "(", "H", ".", "APP_TRANSITION_TIMEOUT", ")", ",", "5000", ")", ";", "}", "}", "}", "public", "int", "getPendingAppTransition", "(", ")", "{", "return", "mNextAppTransition", ";", "}", "public", "void", "overridePendingAppTransition", "(", "String", "packageName", ",", "int", "enterAnim", ",", "int", "exitAnim", ")", "{", "if", "(", "mNextAppTransition", "!=", "WindowManagerPolicy", ".", "TRANSIT_UNSET", ")", "{", "mNextAppTransitionPackage", "=", "packageName", ";", "mNextAppTransitionEnter", "=", "enterAnim", ";", "mNextAppTransitionExit", "=", "exitAnim", ";", "}", "}", "public", "void", "executeAppTransition", "(", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "MANAGE_APP_TOKENS", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "DEBUG_APP_TRANSITIONS", ")", "{", "RuntimeException", "e", "=", "new", "RuntimeException", "(", "\"here\"", ")", ";", "e", ".", "fillInStackTrace", "(", ")", ";", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "mNextAppTransition", ",", "e", ")", ";", "}", "if", "(", "mNextAppTransition", "!=", "WindowManagerPolicy", ".", "TRANSIT_UNSET", ")", "{", "mAppTransitionReady", "=", "true", ";", "final", "long", "origId", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "performLayoutAndPlaceSurfacesLocked", "(", ")", ";", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "}", "}", "}", "public", "void", "setAppStartingWindow", "(", "IBinder", "token", ",", "String", "pkg", ",", "int", "theme", ",", "CompatibilityInfo", "compatInfo", ",", "CharSequence", "nonLocalizedLabel", ",", "int", "labelRes", ",", "int", "icon", ",", "int", "windowFlags", ",", "IBinder", "transferFrom", ",", "boolean", "createIfNeeded", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "MANAGE_APP_TOKENS", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "DEBUG_STARTING_WINDOW", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "token", "+", "\"", "pkg=\"", "+", "pkg", "+", "\"\"", "+", "transferFrom", ")", ";", "AppWindowToken", "wtoken", "=", "findAppWindowToken", "(", "token", ")", ";", "if", "(", "wtoken", "==", "null", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "token", ")", ";", "return", ";", "}", "if", "(", "mDisplayFrozen", "||", "!", "mDisplayEnabled", "||", "!", "mPolicy", ".", "isScreenOnFully", "(", ")", ")", "{", "return", ";", "}", "if", "(", "wtoken", ".", "startingData", "!=", "null", ")", "{", "return", ";", "}", "if", "(", "transferFrom", "!=", "null", ")", "{", "AppWindowToken", "ttoken", "=", "findAppWindowToken", "(", "transferFrom", ")", ";", "if", "(", "ttoken", "!=", "null", ")", "{", "WindowState", "startingWindow", "=", "ttoken", ".", "startingWindow", ";", "if", "(", "startingWindow", "!=", "null", ")", "{", "if", "(", "mStartingIconInTransition", ")", "{", "mSkipAppTransitionAnimation", "=", "true", ";", "}", "if", "(", "DEBUG_STARTING_WINDOW", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "ttoken", "+", "\"", "to", "\"", "+", "wtoken", ")", ";", "final", "long", "origId", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "wtoken", ".", "startingData", "=", "ttoken", ".", "startingData", ";", "wtoken", ".", "startingView", "=", "ttoken", ".", "startingView", ";", "wtoken", ".", "startingWindow", "=", "startingWindow", ";", "ttoken", ".", "startingData", "=", "null", ";", "ttoken", ".", "startingView", "=", "null", ";", "ttoken", ".", "startingWindow", "=", "null", ";", "ttoken", ".", "startingMoved", "=", "true", ";", "startingWindow", ".", "mToken", "=", "wtoken", ";", "startingWindow", ".", "mRootToken", "=", "wtoken", ";", "startingWindow", ".", "mAppToken", "=", "wtoken", ";", "if", "(", "DEBUG_WINDOW_MOVEMENT", "||", "DEBUG_ADD_REMOVE", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "startingWindow", ")", ";", "mWindows", ".", "remove", "(", "startingWindow", ")", ";", "mWindowsChanged", "=", "true", ";", "if", "(", "DEBUG_ADD_REMOVE", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "startingWindow", "+", "\"", "from", "\"", "+", "ttoken", ")", ";", "ttoken", ".", "windows", ".", "remove", "(", "startingWindow", ")", ";", "ttoken", ".", "allAppWindows", ".", "remove", "(", "startingWindow", ")", ";", "addWindowToListInOrderLocked", "(", "startingWindow", ",", "true", ")", ";", "if", "(", "ttoken", ".", "allDrawn", ")", "{", "wtoken", ".", "allDrawn", "=", "true", ";", "}", "if", "(", "ttoken", ".", "firstWindowDrawn", ")", "{", "wtoken", ".", "firstWindowDrawn", "=", "true", ";", "}", "if", "(", "!", "ttoken", ".", "hidden", ")", "{", "wtoken", ".", "hidden", "=", "false", ";", "wtoken", ".", "hiddenRequested", "=", "false", ";", "wtoken", ".", "willBeHidden", "=", "false", ";", "}", "if", "(", "wtoken", ".", "clientHidden", "!=", "ttoken", ".", "clientHidden", ")", "{", "wtoken", ".", "clientHidden", "=", "ttoken", ".", "clientHidden", ";", "wtoken", ".", "sendAppVisibilityToClients", "(", ")", ";", "}", "if", "(", "ttoken", ".", "animation", "!=", "null", ")", "{", "wtoken", ".", "animation", "=", "ttoken", ".", "animation", ";", "wtoken", ".", "animating", "=", "ttoken", ".", "animating", ";", "wtoken", ".", "animLayerAdjustment", "=", "ttoken", ".", "animLayerAdjustment", ";", "ttoken", ".", "animation", "=", "null", ";", "ttoken", ".", "animLayerAdjustment", "=", "0", ";", "wtoken", ".", "updateLayers", "(", ")", ";", "ttoken", ".", "updateLayers", "(", ")", ";", "}", "updateFocusedWindowLocked", "(", "UPDATE_FOCUS_WILL_PLACE_SURFACES", ",", "true", ")", ";", "mLayoutNeeded", "=", "true", ";", "performLayoutAndPlaceSurfacesLocked", "(", ")", ";", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "return", ";", "}", "else", "if", "(", "ttoken", ".", "startingData", "!=", "null", ")", "{", "if", "(", "DEBUG_STARTING_WINDOW", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "ttoken", "+", "\"", "to", "\"", "+", "wtoken", ")", ";", "wtoken", ".", "startingData", "=", "ttoken", ".", "startingData", ";", "ttoken", ".", "startingData", "=", "null", ";", "ttoken", ".", "startingMoved", "=", "true", ";", "Message", "m", "=", "mH", ".", "obtainMessage", "(", "H", ".", "ADD_STARTING", ",", "wtoken", ")", ";", "mH", ".", "sendMessageAtFrontOfQueue", "(", "m", ")", ";", "return", ";", "}", "}", "}", "if", "(", "!", "createIfNeeded", ")", "{", "return", ";", "}", "if", "(", "theme", "!=", "0", ")", "{", "AttributeCache", ".", "Entry", "ent", "=", "AttributeCache", ".", "instance", "(", ")", ".", "get", "(", "pkg", ",", "theme", ",", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "Window", ")", ";", "if", "(", "ent", ".", "array", ".", "getBoolean", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "Window_windowIsTranslucent", ",", "false", ")", ")", "{", "return", ";", "}", "if", "(", "ent", ".", "array", ".", "getBoolean", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "Window_windowIsFloating", ",", "false", ")", ")", "{", "return", ";", "}", "if", "(", "ent", ".", "array", ".", "getBoolean", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "Window_windowShowWallpaper", ",", "false", ")", ")", "{", "if", "(", "mWallpaperTarget", "==", "null", ")", "{", "windowFlags", "|=", "WindowManager", ".", "LayoutParams", ".", "FLAG_SHOW_WALLPAPER", ";", "}", "else", "{", "return", ";", "}", "}", "}", "mStartingIconInTransition", "=", "true", ";", "wtoken", ".", "startingData", "=", "new", "StartingData", "(", "pkg", ",", "theme", ",", "compatInfo", ",", "nonLocalizedLabel", ",", "labelRes", ",", "icon", ",", "windowFlags", ")", ";", "Message", "m", "=", "mH", ".", "obtainMessage", "(", "H", ".", "ADD_STARTING", ",", "wtoken", ")", ";", "mH", ".", "sendMessageAtFrontOfQueue", "(", "m", ")", ";", "}", "}", "public", "void", "setAppWillBeHidden", "(", "IBinder", "token", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "MANAGE_APP_TOKENS", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "AppWindowToken", "wtoken", ";", "synchronized", "(", "mWindowMap", ")", "{", "wtoken", "=", "findAppWindowToken", "(", "token", ")", ";", "if", "(", "wtoken", "==", "null", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "token", ")", ";", "return", ";", "}", "wtoken", ".", "willBeHidden", "=", "true", ";", "}", "}", "boolean", "setTokenVisibilityLocked", "(", "AppWindowToken", "wtoken", ",", "WindowManager", ".", "LayoutParams", "lp", ",", "boolean", "visible", ",", "int", "transit", ",", "boolean", "performLayout", ")", "{", "boolean", "delayed", "=", "false", ";", "if", "(", "wtoken", ".", "clientHidden", "==", "visible", ")", "{", "wtoken", ".", "clientHidden", "=", "!", "visible", ";", "wtoken", ".", "sendAppVisibilityToClients", "(", ")", ";", "}", "wtoken", ".", "willBeHidden", "=", "false", ";", "if", "(", "wtoken", ".", "hidden", "==", "visible", ")", "{", "final", "int", "N", "=", "wtoken", ".", "allAppWindows", ".", "size", "(", ")", ";", "boolean", "changed", "=", "false", ";", "if", "(", "DEBUG_APP_TRANSITIONS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", "+", "\"", "hidden=\"", "+", "wtoken", ".", "hidden", "+", "\"\"", "+", "performLayout", ")", ";", "boolean", "runningAppAnimation", "=", "false", ";", "if", "(", "transit", "!=", "WindowManagerPolicy", ".", "TRANSIT_UNSET", ")", "{", "if", "(", "wtoken", ".", "animation", "==", "sDummyAnimation", ")", "{", "wtoken", ".", "animation", "=", "null", ";", "}", "applyAnimationLocked", "(", "wtoken", ",", "lp", ",", "transit", ",", "visible", ")", ";", "changed", "=", "true", ";", "if", "(", "wtoken", ".", "animation", "!=", "null", ")", "{", "delayed", "=", "runningAppAnimation", "=", "true", ";", "}", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "WindowState", "win", "=", "wtoken", ".", "allAppWindows", ".", "get", "(", "i", ")", ";", "if", "(", "win", "==", "wtoken", ".", "startingWindow", ")", "{", "continue", ";", "}", "if", "(", "win", ".", "isAnimating", "(", ")", ")", "{", "delayed", "=", "true", ";", "}", "if", "(", "visible", ")", "{", "if", "(", "!", "win", ".", "isVisibleNow", "(", ")", ")", "{", "if", "(", "!", "runningAppAnimation", ")", "{", "applyAnimationLocked", "(", "win", ",", "WindowManagerPolicy", ".", "TRANSIT_ENTER", ",", "true", ")", ";", "}", "changed", "=", "true", ";", "}", "}", "else", "if", "(", "win", ".", "isVisibleNow", "(", ")", ")", "{", "if", "(", "!", "runningAppAnimation", ")", "{", "applyAnimationLocked", "(", "win", ",", "WindowManagerPolicy", ".", "TRANSIT_EXIT", ",", "false", ")", ";", "}", "changed", "=", "true", ";", "}", "}", "wtoken", ".", "hidden", "=", "wtoken", ".", "hiddenRequested", "=", "!", "visible", ";", "if", "(", "!", "visible", ")", "{", "unsetAppFreezingScreenLocked", "(", "wtoken", ",", "true", ",", "true", ")", ";", "}", "else", "{", "WindowState", "swin", "=", "wtoken", ".", "startingWindow", ";", "if", "(", "swin", "!=", "null", "&&", "(", "swin", ".", "mDrawPending", "||", "swin", ".", "mCommitDrawPending", ")", ")", "{", "swin", ".", "mPolicyVisibility", "=", "false", ";", "swin", ".", "mPolicyVisibilityAfterAnim", "=", "false", ";", "}", "}", "if", "(", "DEBUG_APP_TRANSITIONS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", "+", "\":", "hidden=\"", "+", "wtoken", ".", "hidden", "+", "\"\"", "+", "wtoken", ".", "hiddenRequested", ")", ";", "if", "(", "changed", ")", "{", "mLayoutNeeded", "=", "true", ";", "mInputMonitor", ".", "setUpdateInputWindowsNeededLw", "(", ")", ";", "if", "(", "performLayout", ")", "{", "updateFocusedWindowLocked", "(", "UPDATE_FOCUS_WILL_PLACE_SURFACES", ",", "false", ")", ";", "performLayoutAndPlaceSurfacesLocked", "(", ")", ";", "}", "mInputMonitor", ".", "updateInputWindowsLw", "(", "false", ")", ";", "}", "}", "if", "(", "wtoken", ".", "animation", "!=", "null", ")", "{", "delayed", "=", "true", ";", "}", "return", "delayed", ";", "}", "public", "void", "setAppVisibility", "(", "IBinder", "token", ",", "boolean", "visible", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "MANAGE_APP_TOKENS", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "AppWindowToken", "wtoken", ";", "synchronized", "(", "mWindowMap", ")", "{", "wtoken", "=", "findAppWindowToken", "(", "token", ")", ";", "if", "(", "wtoken", "==", "null", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "token", ")", ";", "return", ";", "}", "if", "(", "DEBUG_APP_TRANSITIONS", "||", "DEBUG_ORIENTATION", ")", "{", "RuntimeException", "e", "=", "null", ";", "if", "(", "!", "HIDE_STACK_CRAWLS", ")", "{", "e", "=", "new", "RuntimeException", "(", ")", ";", "e", ".", "fillInStackTrace", "(", ")", ";", "}", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "token", "+", "\",", "\"", "+", "visible", "+", "\"\"", "+", "mNextAppTransition", "+", "\"", "hidden=\"", "+", "wtoken", ".", "hidden", "+", "\"\"", "+", "wtoken", ".", "hiddenRequested", ",", "e", ")", ";", "}", "if", "(", "!", "mDisplayFrozen", "&&", "mDisplayEnabled", "&&", "mPolicy", ".", "isScreenOnFully", "(", ")", "&&", "mNextAppTransition", "!=", "WindowManagerPolicy", ".", "TRANSIT_UNSET", ")", "{", "if", "(", "wtoken", ".", "hiddenRequested", "!=", "visible", ")", "{", "return", ";", "}", "wtoken", ".", "hiddenRequested", "=", "!", "visible", ";", "if", "(", "DEBUG_APP_TRANSITIONS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", ")", ";", "wtoken", ".", "setDummyAnimation", "(", ")", ";", "mOpeningApps", ".", "remove", "(", "wtoken", ")", ";", "mClosingApps", ".", "remove", "(", "wtoken", ")", ";", "wtoken", ".", "waitingToShow", "=", "wtoken", ".", "waitingToHide", "=", "false", ";", "wtoken", ".", "inPendingTransaction", "=", "true", ";", "if", "(", "visible", ")", "{", "mOpeningApps", ".", "add", "(", "wtoken", ")", ";", "wtoken", ".", "startingDisplayed", "=", "false", ";", "wtoken", ".", "startingMoved", "=", "false", ";", "if", "(", "wtoken", ".", "hidden", ")", "{", "wtoken", ".", "allDrawn", "=", "false", ";", "wtoken", ".", "waitingToShow", "=", "true", ";", "if", "(", "wtoken", ".", "clientHidden", ")", "{", "wtoken", ".", "clientHidden", "=", "false", ";", "wtoken", ".", "sendAppVisibilityToClients", "(", ")", ";", "}", "}", "}", "else", "{", "mClosingApps", ".", "add", "(", "wtoken", ")", ";", "if", "(", "!", "wtoken", ".", "hidden", ")", "{", "wtoken", ".", "waitingToHide", "=", "true", ";", "}", "}", "return", ";", "}", "final", "long", "origId", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "setTokenVisibilityLocked", "(", "wtoken", ",", "null", ",", "visible", ",", "WindowManagerPolicy", ".", "TRANSIT_UNSET", ",", "true", ")", ";", "wtoken", ".", "updateReportedVisibilityLocked", "(", ")", ";", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "}", "}", "void", "unsetAppFreezingScreenLocked", "(", "AppWindowToken", "wtoken", ",", "boolean", "unfreezeSurfaceNow", ",", "boolean", "force", ")", "{", "if", "(", "wtoken", ".", "freezingScreen", ")", "{", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", "+", "\"", "force=\"", "+", "force", ")", ";", "final", "int", "N", "=", "wtoken", ".", "allAppWindows", ".", "size", "(", ")", ";", "boolean", "unfrozeWindows", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "WindowState", "w", "=", "wtoken", ".", "allAppWindows", ".", "get", "(", "i", ")", ";", "if", "(", "w", ".", "mAppFreezing", ")", "{", "w", ".", "mAppFreezing", "=", "false", ";", "if", "(", "w", ".", "mSurface", "!=", "null", "&&", "!", "w", ".", "mOrientationChanging", ")", "{", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "w", ")", ";", "w", ".", "mOrientationChanging", "=", "true", ";", "}", "unfrozeWindows", "=", "true", ";", "}", "}", "if", "(", "force", "||", "unfrozeWindows", ")", "{", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", ")", ";", "wtoken", ".", "freezingScreen", "=", "false", ";", "mAppsFreezingScreen", "--", ";", "}", "if", "(", "unfreezeSurfaceNow", ")", "{", "if", "(", "unfrozeWindows", ")", "{", "mLayoutNeeded", "=", "true", ";", "performLayoutAndPlaceSurfacesLocked", "(", ")", ";", "}", "stopFreezingDisplayLocked", "(", ")", ";", "}", "}", "}", "public", "void", "startAppFreezingScreenLocked", "(", "AppWindowToken", "wtoken", ",", "int", "configChanges", ")", "{", "if", "(", "DEBUG_ORIENTATION", ")", "{", "RuntimeException", "e", "=", "null", ";", "if", "(", "!", "HIDE_STACK_CRAWLS", ")", "{", "e", "=", "new", "RuntimeException", "(", ")", ";", "e", ".", "fillInStackTrace", "(", ")", ";", "}", "Slog", ".", "i", "(", "TAG", ",", "\"\"", "+", "wtoken", ".", "appToken", "+", "\":", "hidden=\"", "+", "wtoken", ".", "hidden", "+", "\"", "freezing=\"", "+", "wtoken", ".", "freezingScreen", ",", "e", ")", ";", "}", "if", "(", "!", "wtoken", ".", "hiddenRequested", ")", "{", "if", "(", "!", "wtoken", ".", "freezingScreen", ")", "{", "wtoken", ".", "freezingScreen", "=", "true", ";", "mAppsFreezingScreen", "++", ";", "if", "(", "mAppsFreezingScreen", "==", "1", ")", "{", "startFreezingDisplayLocked", "(", "false", ")", ";", "mH", ".", "removeMessages", "(", "H", ".", "APP_FREEZE_TIMEOUT", ")", ";", "mH", ".", "sendMessageDelayed", "(", "mH", ".", "obtainMessage", "(", "H", ".", "APP_FREEZE_TIMEOUT", ")", ",", "5000", ")", ";", "}", "}", "final", "int", "N", "=", "wtoken", ".", "allAppWindows", ".", "size", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "WindowState", "w", "=", "wtoken", ".", "allAppWindows", ".", "get", "(", "i", ")", ";", "w", ".", "mAppFreezing", "=", "true", ";", "}", "}", "}", "public", "void", "startAppFreezingScreen", "(", "IBinder", "token", ",", "int", "configChanges", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "MANAGE_APP_TOKENS", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "configChanges", "==", "0", "&&", "!", "mDisplayFrozen", "&&", "mPolicy", ".", "isScreenOnFully", "(", ")", ")", "{", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "token", ")", ";", "return", ";", "}", "AppWindowToken", "wtoken", "=", "findAppWindowToken", "(", "token", ")", ";", "if", "(", "wtoken", "==", "null", "||", "wtoken", ".", "appToken", "==", "null", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "wtoken", ")", ";", "return", ";", "}", "final", "long", "origId", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "startAppFreezingScreenLocked", "(", "wtoken", ",", "configChanges", ")", ";", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "}", "}", "public", "void", "stopAppFreezingScreen", "(", "IBinder", "token", ",", "boolean", "force", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "MANAGE_APP_TOKENS", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "synchronized", "(", "mWindowMap", ")", "{", "AppWindowToken", "wtoken", "=", "findAppWindowToken", "(", "token", ")", ";", "if", "(", "wtoken", "==", "null", "||", "wtoken", ".", "appToken", "==", "null", ")", "{", "return", ";", "}", "final", "long", "origId", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "token", "+", "\":", "hidden=\"", "+", "wtoken", ".", "hidden", "+", "\"", "freezing=\"", "+", "wtoken", ".", "freezingScreen", ")", ";", "unsetAppFreezingScreenLocked", "(", "wtoken", ",", "true", ",", "force", ")", ";", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "}", "}", "public", "void", "removeAppToken", "(", "IBinder", "token", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "MANAGE_APP_TOKENS", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "AppWindowToken", "wtoken", "=", "null", ";", "AppWindowToken", "startingToken", "=", "null", ";", "boolean", "delayed", "=", "false", ";", "final", "long", "origId", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "synchronized", "(", "mWindowMap", ")", "{", "WindowToken", "basewtoken", "=", "mTokenMap", ".", "remove", "(", "token", ")", ";", "if", "(", "basewtoken", "!=", "null", "&&", "(", "wtoken", "=", "basewtoken", ".", "appWindowToken", ")", "!=", "null", ")", "{", "if", "(", "DEBUG_APP_TRANSITIONS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", ")", ";", "delayed", "=", "setTokenVisibilityLocked", "(", "wtoken", ",", "null", ",", "false", ",", "WindowManagerPolicy", ".", "TRANSIT_UNSET", ",", "true", ")", ";", "wtoken", ".", "inPendingTransaction", "=", "false", ";", "mOpeningApps", ".", "remove", "(", "wtoken", ")", ";", "wtoken", ".", "waitingToShow", "=", "false", ";", "if", "(", "mClosingApps", ".", "contains", "(", "wtoken", ")", ")", "{", "delayed", "=", "true", ";", "}", "else", "if", "(", "mNextAppTransition", "!=", "WindowManagerPolicy", ".", "TRANSIT_UNSET", ")", "{", "mClosingApps", ".", "add", "(", "wtoken", ")", ";", "wtoken", ".", "waitingToHide", "=", "true", ";", "delayed", "=", "true", ";", "}", "if", "(", "DEBUG_APP_TRANSITIONS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", "+", "\"", "delayed=\"", "+", "delayed", "+", "\"", "animation=\"", "+", "wtoken", ".", "animation", "+", "\"", "animating=\"", "+", "wtoken", ".", "animating", ")", ";", "if", "(", "delayed", ")", "{", "if", "(", "DEBUG_ADD_REMOVE", "||", "DEBUG_TOKEN_MOVEMENT", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", ")", ";", "mExitingAppTokens", ".", "add", "(", "wtoken", ")", ";", "}", "else", "{", "wtoken", ".", "animation", "=", "null", ";", "wtoken", ".", "animating", "=", "false", ";", "}", "if", "(", "DEBUG_ADD_REMOVE", "||", "DEBUG_TOKEN_MOVEMENT", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", ")", ";", "mAppTokens", ".", "remove", "(", "wtoken", ")", ";", "wtoken", ".", "removed", "=", "true", ";", "if", "(", "wtoken", ".", "startingData", "!=", "null", ")", "{", "startingToken", "=", "wtoken", ";", "}", "unsetAppFreezingScreenLocked", "(", "wtoken", ",", "true", ",", "true", ")", ";", "if", "(", "mFocusedApp", "==", "wtoken", ")", "{", "if", "(", "DEBUG_FOCUS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", ")", ";", "mFocusedApp", "=", "null", ";", "updateFocusedWindowLocked", "(", "UPDATE_FOCUS_NORMAL", ",", "true", ")", ";", "mInputMonitor", ".", "setFocusedAppLw", "(", "null", ")", ";", "}", "}", "else", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "token", ")", ";", "}", "if", "(", "!", "delayed", "&&", "wtoken", "!=", "null", ")", "{", "wtoken", ".", "updateReportedVisibilityLocked", "(", ")", ";", "}", "}", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "if", "(", "startingToken", "!=", "null", ")", "{", "if", "(", "DEBUG_STARTING_WINDOW", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "startingToken", "+", "\"\"", ")", ";", "Message", "m", "=", "mH", ".", "obtainMessage", "(", "H", ".", "REMOVE_STARTING", ",", "startingToken", ")", ";", "mH", ".", "sendMessage", "(", "m", ")", ";", "}", "}", "private", "boolean", "tmpRemoveAppWindowsLocked", "(", "WindowToken", "token", ")", "{", "final", "int", "NW", "=", "token", ".", "windows", ".", "size", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "NW", ";", "i", "++", ")", "{", "WindowState", "win", "=", "token", ".", "windows", ".", "get", "(", "i", ")", ";", "if", "(", "DEBUG_WINDOW_MOVEMENT", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "win", ")", ";", "mWindows", ".", "remove", "(", "win", ")", ";", "mWindowsChanged", "=", "true", ";", "int", "j", "=", "win", ".", "mChildWindows", ".", "size", "(", ")", ";", "while", "(", "j", ">", "0", ")", "{", "j", "--", ";", "WindowState", "cwin", "=", "win", ".", "mChildWindows", ".", "get", "(", "j", ")", ";", "if", "(", "DEBUG_WINDOW_MOVEMENT", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "cwin", ")", ";", "mWindows", ".", "remove", "(", "cwin", ")", ";", "}", "}", "return", "NW", ">", "0", ";", "}", "void", "dumpAppTokensLocked", "(", ")", "{", "for", "(", "int", "i", "=", "mAppTokens", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"", "#\"", "+", "i", "+", "\":", "\"", "+", "mAppTokens", ".", "get", "(", "i", ")", ".", "token", ")", ";", "}", "}", "void", "dumpWindowsLocked", "(", ")", "{", "for", "(", "int", "i", "=", "mWindows", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"", "#\"", "+", "i", "+", "\":", "\"", "+", "mWindows", ".", "get", "(", "i", ")", ")", ";", "}", "}", "private", "int", "findWindowOffsetLocked", "(", "int", "tokenPos", ")", "{", "final", "int", "NW", "=", "mWindows", ".", "size", "(", ")", ";", "if", "(", "tokenPos", ">=", "mAppTokens", ".", "size", "(", ")", ")", "{", "int", "i", "=", "NW", ";", "while", "(", "i", ">", "0", ")", "{", "i", "--", ";", "WindowState", "win", "=", "mWindows", ".", "get", "(", "i", ")", ";", "if", "(", "win", ".", "getAppToken", "(", ")", "!=", "null", ")", "{", "return", "i", "+", "1", ";", "}", "}", "}", "while", "(", "tokenPos", ">", "0", ")", "{", "final", "AppWindowToken", "wtoken", "=", "mAppTokens", ".", "get", "(", "tokenPos", "-", "1", ")", ";", "if", "(", "DEBUG_REORDER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "tokenPos", "+", "\"", "--", "\"", "+", "wtoken", ".", "token", ")", ";", "if", "(", "wtoken", ".", "sendingToBottom", ")", "{", "if", "(", "DEBUG_REORDER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "tokenPos", "--", ";", "continue", ";", "}", "int", "i", "=", "wtoken", ".", "windows", ".", "size", "(", ")", ";", "while", "(", "i", ">", "0", ")", "{", "i", "--", ";", "WindowState", "win", "=", "wtoken", ".", "windows", ".", "get", "(", "i", ")", ";", "int", "j", "=", "win", ".", "mChildWindows", ".", "size", "(", ")", ";", "while", "(", "j", ">", "0", ")", "{", "j", "--", ";", "WindowState", "cwin", "=", "win", ".", "mChildWindows", ".", "get", "(", "j", ")", ";", "if", "(", "cwin", ".", "mSubLayer", ">=", "0", ")", "{", "for", "(", "int", "pos", "=", "NW", "-", "1", ";", "pos", ">=", "0", ";", "pos", "--", ")", "{", "if", "(", "mWindows", ".", "get", "(", "pos", ")", "==", "cwin", ")", "{", "if", "(", "DEBUG_REORDER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "(", "pos", "+", "1", ")", ")", ";", "return", "pos", "+", "1", ";", "}", "}", "}", "}", "for", "(", "int", "pos", "=", "NW", "-", "1", ";", "pos", ">=", "0", ";", "pos", "--", ")", "{", "if", "(", "mWindows", ".", "get", "(", "pos", ")", "==", "win", ")", "{", "if", "(", "DEBUG_REORDER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Found", "win", "@\"", "+", "(", "pos", "+", "1", ")", ")", ";", "return", "pos", "+", "1", ";", "}", "}", "}", "tokenPos", "--", ";", "}", "return", "0", ";", "}", "private", "final", "int", "reAddWindowLocked", "(", "int", "index", ",", "WindowState", "win", ")", "{", "final", "int", "NCW", "=", "win", ".", "mChildWindows", ".", "size", "(", ")", ";", "boolean", "added", "=", "false", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "NCW", ";", "j", "++", ")", "{", "WindowState", "cwin", "=", "win", ".", "mChildWindows", ".", "get", "(", "j", ")", ";", "if", "(", "!", "added", "&&", "cwin", ".", "mSubLayer", ">=", "0", ")", "{", "if", "(", "DEBUG_WINDOW_MOVEMENT", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "index", "+", "\":", "\"", "+", "cwin", ")", ";", "win", ".", "mRebuilding", "=", "false", ";", "mWindows", ".", "add", "(", "index", ",", "win", ")", ";", "index", "++", ";", "added", "=", "true", ";", "}", "if", "(", "DEBUG_WINDOW_MOVEMENT", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "index", "+", "\":", "\"", "+", "cwin", ")", ";", "cwin", ".", "mRebuilding", "=", "false", ";", "mWindows", ".", "add", "(", "index", ",", "cwin", ")", ";", "index", "++", ";", "}", "if", "(", "!", "added", ")", "{", "if", "(", "DEBUG_WINDOW_MOVEMENT", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "index", "+", "\":", "\"", "+", "win", ")", ";", "win", ".", "mRebuilding", "=", "false", ";", "mWindows", ".", "add", "(", "index", ",", "win", ")", ";", "index", "++", ";", "}", "mWindowsChanged", "=", "true", ";", "return", "index", ";", "}", "private", "final", "int", "reAddAppWindowsLocked", "(", "int", "index", ",", "WindowToken", "token", ")", "{", "final", "int", "NW", "=", "token", ".", "windows", ".", "size", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "NW", ";", "i", "++", ")", "{", "index", "=", "reAddWindowLocked", "(", "index", ",", "token", ".", "windows", ".", "get", "(", "i", ")", ")", ";", "}", "return", "index", ";", "}", "public", "void", "moveAppToken", "(", "int", "index", ",", "IBinder", "token", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "MANAGE_APP_TOKENS", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "DEBUG_REORDER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "if", "(", "DEBUG_REORDER", ")", "dumpAppTokensLocked", "(", ")", ";", "final", "AppWindowToken", "wtoken", "=", "findAppWindowToken", "(", "token", ")", ";", "if", "(", "DEBUG_TOKEN_MOVEMENT", "||", "DEBUG_REORDER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", "+", "\"\"", "+", "mAppTokens", ".", "indexOf", "(", "wtoken", ")", ")", ";", "if", "(", "wtoken", "==", "null", "||", "!", "mAppTokens", ".", "remove", "(", "wtoken", ")", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "token", "+", "\"", "(\"", "+", "wtoken", "+", "\")\"", ")", ";", "return", ";", "}", "mAppTokens", ".", "add", "(", "index", ",", "wtoken", ")", ";", "if", "(", "DEBUG_REORDER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Moved", "\"", "+", "token", "+", "\"", "to", "\"", "+", "index", "+", "\":\"", ")", ";", "else", "if", "(", "DEBUG_TOKEN_MOVEMENT", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Moved", "\"", "+", "token", "+", "\"", "to", "\"", "+", "index", ")", ";", "if", "(", "DEBUG_REORDER", ")", "dumpAppTokensLocked", "(", ")", ";", "final", "long", "origId", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "if", "(", "DEBUG_REORDER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "token", "+", "\":\"", ")", ";", "if", "(", "DEBUG_REORDER", ")", "dumpWindowsLocked", "(", ")", ";", "if", "(", "tmpRemoveAppWindowsLocked", "(", "wtoken", ")", ")", "{", "if", "(", "DEBUG_REORDER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "if", "(", "DEBUG_REORDER", ")", "dumpWindowsLocked", "(", ")", ";", "reAddAppWindowsLocked", "(", "findWindowOffsetLocked", "(", "index", ")", ",", "wtoken", ")", ";", "if", "(", "DEBUG_REORDER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "if", "(", "DEBUG_REORDER", ")", "dumpWindowsLocked", "(", ")", ";", "updateFocusedWindowLocked", "(", "UPDATE_FOCUS_WILL_PLACE_SURFACES", ",", "false", ")", ";", "mLayoutNeeded", "=", "true", ";", "mInputMonitor", ".", "setUpdateInputWindowsNeededLw", "(", ")", ";", "performLayoutAndPlaceSurfacesLocked", "(", ")", ";", "mInputMonitor", ".", "updateInputWindowsLw", "(", "false", ")", ";", "}", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "}", "}", "private", "void", "removeAppTokensLocked", "(", "List", "<", "IBinder", ">", "tokens", ")", "{", "int", "N", "=", "tokens", ".", "size", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "IBinder", "token", "=", "tokens", ".", "get", "(", "i", ")", ";", "final", "AppWindowToken", "wtoken", "=", "findAppWindowToken", "(", "token", ")", ";", "if", "(", "DEBUG_REORDER", "||", "DEBUG_TOKEN_MOVEMENT", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", "+", "\"", "from", "\"", "+", "mAppTokens", ".", "indexOf", "(", "wtoken", ")", ")", ";", "if", "(", "!", "mAppTokens", ".", "remove", "(", "wtoken", ")", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "token", "+", "\"", "(\"", "+", "wtoken", "+", "\")\"", ")", ";", "i", "--", ";", "N", "--", ";", "}", "}", "}", "private", "void", "moveAppWindowsLocked", "(", "AppWindowToken", "wtoken", ",", "int", "tokenPos", ",", "boolean", "updateFocusAndLayout", ")", "{", "tmpRemoveAppWindowsLocked", "(", "wtoken", ")", ";", "int", "pos", "=", "findWindowOffsetLocked", "(", "tokenPos", ")", ";", "pos", "=", "reAddAppWindowsLocked", "(", "pos", ",", "wtoken", ")", ";", "if", "(", "updateFocusAndLayout", ")", "{", "mInputMonitor", ".", "setUpdateInputWindowsNeededLw", "(", ")", ";", "if", "(", "!", "updateFocusedWindowLocked", "(", "UPDATE_FOCUS_WILL_PLACE_SURFACES", ",", "false", ")", ")", "{", "assignLayersLocked", "(", ")", ";", "}", "mLayoutNeeded", "=", "true", ";", "performLayoutAndPlaceSurfacesLocked", "(", ")", ";", "mInputMonitor", ".", "updateInputWindowsLw", "(", "false", ")", ";", "}", "}", "private", "void", "moveAppWindowsLocked", "(", "List", "<", "IBinder", ">", "tokens", ",", "int", "tokenPos", ")", "{", "final", "int", "N", "=", "tokens", ".", "size", "(", ")", ";", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "WindowToken", "token", "=", "mTokenMap", ".", "get", "(", "tokens", ".", "get", "(", "i", ")", ")", ";", "if", "(", "token", "!=", "null", ")", "{", "tmpRemoveAppWindowsLocked", "(", "token", ")", ";", "}", "}", "int", "pos", "=", "findWindowOffsetLocked", "(", "tokenPos", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "WindowToken", "token", "=", "mTokenMap", ".", "get", "(", "tokens", ".", "get", "(", "i", ")", ")", ";", "if", "(", "token", "!=", "null", ")", "{", "pos", "=", "reAddAppWindowsLocked", "(", "pos", ",", "token", ")", ";", "}", "}", "mInputMonitor", ".", "setUpdateInputWindowsNeededLw", "(", ")", ";", "if", "(", "!", "updateFocusedWindowLocked", "(", "UPDATE_FOCUS_WILL_PLACE_SURFACES", ",", "false", ")", ")", "{", "assignLayersLocked", "(", ")", ";", "}", "mLayoutNeeded", "=", "true", ";", "performLayoutAndPlaceSurfacesLocked", "(", ")", ";", "mInputMonitor", ".", "updateInputWindowsLw", "(", "false", ")", ";", "}", "public", "void", "moveAppTokensToTop", "(", "List", "<", "IBinder", ">", "tokens", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "MANAGE_APP_TOKENS", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "final", "long", "origId", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "synchronized", "(", "mWindowMap", ")", "{", "removeAppTokensLocked", "(", "tokens", ")", ";", "final", "int", "N", "=", "tokens", ".", "size", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "AppWindowToken", "wt", "=", "findAppWindowToken", "(", "tokens", ".", "get", "(", "i", ")", ")", ";", "if", "(", "wt", "!=", "null", ")", "{", "if", "(", "DEBUG_TOKEN_MOVEMENT", "||", "DEBUG_REORDER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wt", ")", ";", "mAppTokens", ".", "add", "(", "wt", ")", ";", "if", "(", "mNextAppTransition", "!=", "WindowManagerPolicy", ".", "TRANSIT_UNSET", ")", "{", "mToTopApps", ".", "remove", "(", "wt", ")", ";", "mToBottomApps", ".", "remove", "(", "wt", ")", ";", "mToTopApps", ".", "add", "(", "wt", ")", ";", "wt", ".", "sendingToBottom", "=", "false", ";", "wt", ".", "sendingToTop", "=", "true", ";", "}", "}", "}", "if", "(", "mNextAppTransition", "==", "WindowManagerPolicy", ".", "TRANSIT_UNSET", ")", "{", "moveAppWindowsLocked", "(", "tokens", ",", "mAppTokens", ".", "size", "(", ")", ")", ";", "}", "}", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "}", "public", "void", "moveAppTokensToBottom", "(", "List", "<", "IBinder", ">", "tokens", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "MANAGE_APP_TOKENS", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "final", "long", "origId", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "synchronized", "(", "mWindowMap", ")", "{", "removeAppTokensLocked", "(", "tokens", ")", ";", "final", "int", "N", "=", "tokens", ".", "size", "(", ")", ";", "int", "pos", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "AppWindowToken", "wt", "=", "findAppWindowToken", "(", "tokens", ".", "get", "(", "i", ")", ")", ";", "if", "(", "wt", "!=", "null", ")", "{", "if", "(", "DEBUG_TOKEN_MOVEMENT", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wt", "+", "\"", "at", "\"", "+", "pos", ")", ";", "mAppTokens", ".", "add", "(", "pos", ",", "wt", ")", ";", "if", "(", "mNextAppTransition", "!=", "WindowManagerPolicy", ".", "TRANSIT_UNSET", ")", "{", "mToTopApps", ".", "remove", "(", "wt", ")", ";", "mToBottomApps", ".", "remove", "(", "wt", ")", ";", "mToBottomApps", ".", "add", "(", "i", ",", "wt", ")", ";", "wt", ".", "sendingToTop", "=", "false", ";", "wt", ".", "sendingToBottom", "=", "true", ";", "}", "pos", "++", ";", "}", "}", "if", "(", "mNextAppTransition", "==", "WindowManagerPolicy", ".", "TRANSIT_UNSET", ")", "{", "moveAppWindowsLocked", "(", "tokens", ",", "0", ")", ";", "}", "}", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "}", "private", "boolean", "shouldAllowDisableKeyguard", "(", ")", "{", "if", "(", "mAllowDisableKeyguard", "==", "ALLOW_DISABLE_UNKNOWN", ")", "{", "DevicePolicyManager", "dpm", "=", "(", "DevicePolicyManager", ")", "mContext", ".", "getSystemService", "(", "Context", ".", "DEVICE_POLICY_SERVICE", ")", ";", "if", "(", "dpm", "!=", "null", ")", "{", "mAllowDisableKeyguard", "=", "dpm", ".", "getPasswordQuality", "(", "null", ")", "==", "DevicePolicyManager", ".", "PASSWORD_QUALITY_UNSPECIFIED", "?", "ALLOW_DISABLE_YES", ":", "ALLOW_DISABLE_NO", ";", "}", "}", "return", "mAllowDisableKeyguard", "==", "ALLOW_DISABLE_YES", ";", "}", "public", "void", "disableKeyguard", "(", "IBinder", "token", ",", "String", "tag", ")", "{", "if", "(", "mContext", ".", "checkCallingOrSelfPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "DISABLE_KEYGUARD", ")", "!=", "PackageManager", ".", "PERMISSION_GRANTED", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "synchronized", "(", "mKeyguardTokenWatcher", ")", "{", "mKeyguardTokenWatcher", ".", "acquire", "(", "token", ",", "tag", ")", ";", "}", "}", "public", "void", "reenableKeyguard", "(", "IBinder", "token", ")", "{", "if", "(", "mContext", ".", "checkCallingOrSelfPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "DISABLE_KEYGUARD", ")", "!=", "PackageManager", ".", "PERMISSION_GRANTED", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "synchronized", "(", "mKeyguardTokenWatcher", ")", "{", "mKeyguardTokenWatcher", ".", "release", "(", "token", ")", ";", "if", "(", "!", "mKeyguardTokenWatcher", ".", "isAcquired", "(", ")", ")", "{", "while", "(", "mKeyguardDisabled", ")", "{", "try", "{", "mKeyguardTokenWatcher", ".", "wait", "(", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "Thread", ".", "currentThread", "(", ")", ".", "interrupt", "(", ")", ";", "}", "}", "}", "}", "}", "public", "void", "exitKeyguardSecurely", "(", "final", "IOnKeyguardExitResult", "callback", ")", "{", "if", "(", "mContext", ".", "checkCallingOrSelfPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "DISABLE_KEYGUARD", ")", "!=", "PackageManager", ".", "PERMISSION_GRANTED", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "mPolicy", ".", "exitKeyguardSecurely", "(", "new", "WindowManagerPolicy", ".", "OnKeyguardExitResult", "(", ")", "{", "public", "void", "onKeyguardExitResult", "(", "boolean", "success", ")", "{", "try", "{", "callback", ".", "onKeyguardExitResult", "(", "success", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "}", ")", ";", "}", "public", "boolean", "inKeyguardRestrictedInputMode", "(", ")", "{", "return", "mPolicy", ".", "inKeyguardRestrictedKeyInputMode", "(", ")", ";", "}", "public", "boolean", "isKeyguardLocked", "(", ")", "{", "return", "mPolicy", ".", "isKeyguardLocked", "(", ")", ";", "}", "public", "boolean", "isKeyguardSecure", "(", ")", "{", "return", "mPolicy", ".", "isKeyguardSecure", "(", ")", ";", "}", "public", "void", "dismissKeyguard", "(", ")", "{", "if", "(", "mContext", ".", "checkCallingOrSelfPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "DISABLE_KEYGUARD", ")", "!=", "PackageManager", ".", "PERMISSION_GRANTED", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "synchronized", "(", "mWindowMap", ")", "{", "mPolicy", ".", "dismissKeyguardLw", "(", ")", ";", "}", "}", "public", "void", "closeSystemDialogs", "(", "String", "reason", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "for", "(", "int", "i", "=", "mWindows", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowState", "w", "=", "mWindows", ".", "get", "(", "i", ")", ";", "if", "(", "w", ".", "mSurface", "!=", "null", ")", "{", "try", "{", "w", ".", "mClient", ".", "closeSystemDialogs", "(", "reason", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "}", "}", "}", "static", "float", "fixScale", "(", "float", "scale", ")", "{", "if", "(", "scale", "<", "0", ")", "scale", "=", "0", ";", "else", "if", "(", "scale", ">", "20", ")", "scale", "=", "20", ";", "return", "Math", ".", "abs", "(", "scale", ")", ";", "}", "public", "void", "setAnimationScale", "(", "int", "which", ",", "float", "scale", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "SET_ANIMATION_SCALE", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "if", "(", "scale", "<", "0", ")", "scale", "=", "0", ";", "else", "if", "(", "scale", ">", "20", ")", "scale", "=", "20", ";", "scale", "=", "Math", ".", "abs", "(", "scale", ")", ";", "switch", "(", "which", ")", "{", "case", "0", ":", "mWindowAnimationScale", "=", "fixScale", "(", "scale", ")", ";", "break", ";", "case", "1", ":", "mTransitionAnimationScale", "=", "fixScale", "(", "scale", ")", ";", "break", ";", "}", "mH", ".", "obtainMessage", "(", "H", ".", "PERSIST_ANIMATION_SCALE", ")", ".", "sendToTarget", "(", ")", ";", "}", "public", "void", "setAnimationScales", "(", "float", "[", "]", "scales", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "SET_ANIMATION_SCALE", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "if", "(", "scales", "!=", "null", ")", "{", "if", "(", "scales", ".", "length", ">=", "1", ")", "{", "mWindowAnimationScale", "=", "fixScale", "(", "scales", "[", "0", "]", ")", ";", "}", "if", "(", "scales", ".", "length", ">=", "2", ")", "{", "mTransitionAnimationScale", "=", "fixScale", "(", "scales", "[", "1", "]", ")", ";", "}", "}", "mH", ".", "obtainMessage", "(", "H", ".", "PERSIST_ANIMATION_SCALE", ")", ".", "sendToTarget", "(", ")", ";", "}", "public", "float", "getAnimationScale", "(", "int", "which", ")", "{", "switch", "(", "which", ")", "{", "case", "0", ":", "return", "mWindowAnimationScale", ";", "case", "1", ":", "return", "mTransitionAnimationScale", ";", "}", "return", "0", ";", "}", "public", "float", "[", "]", "getAnimationScales", "(", ")", "{", "return", "new", "float", "[", "]", "{", "mWindowAnimationScale", ",", "mTransitionAnimationScale", "}", ";", "}", "public", "int", "getSwitchState", "(", "int", "sw", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "READ_INPUT_STATE", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "return", "mInputManager", ".", "getSwitchState", "(", "-", "1", ",", "InputDevice", ".", "SOURCE_ANY", ",", "sw", ")", ";", "}", "public", "int", "getSwitchStateForDevice", "(", "int", "devid", ",", "int", "sw", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "READ_INPUT_STATE", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "return", "mInputManager", ".", "getSwitchState", "(", "devid", ",", "InputDevice", ".", "SOURCE_ANY", ",", "sw", ")", ";", "}", "public", "int", "getScancodeState", "(", "int", "sw", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "READ_INPUT_STATE", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "return", "mInputManager", ".", "getScanCodeState", "(", "-", "1", ",", "InputDevice", ".", "SOURCE_ANY", ",", "sw", ")", ";", "}", "public", "int", "getScancodeStateForDevice", "(", "int", "devid", ",", "int", "sw", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "READ_INPUT_STATE", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "return", "mInputManager", ".", "getScanCodeState", "(", "devid", ",", "InputDevice", ".", "SOURCE_ANY", ",", "sw", ")", ";", "}", "public", "int", "getTrackballScancodeState", "(", "int", "sw", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "READ_INPUT_STATE", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "return", "mInputManager", ".", "getScanCodeState", "(", "-", "1", ",", "InputDevice", ".", "SOURCE_TRACKBALL", ",", "sw", ")", ";", "}", "public", "int", "getDPadScancodeState", "(", "int", "sw", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "READ_INPUT_STATE", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "return", "mInputManager", ".", "getScanCodeState", "(", "-", "1", ",", "InputDevice", ".", "SOURCE_DPAD", ",", "sw", ")", ";", "}", "public", "int", "getKeycodeState", "(", "int", "sw", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "READ_INPUT_STATE", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "return", "mInputManager", ".", "getKeyCodeState", "(", "-", "1", ",", "InputDevice", ".", "SOURCE_ANY", ",", "sw", ")", ";", "}", "public", "int", "getKeycodeStateForDevice", "(", "int", "devid", ",", "int", "sw", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "READ_INPUT_STATE", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "return", "mInputManager", ".", "getKeyCodeState", "(", "devid", ",", "InputDevice", ".", "SOURCE_ANY", ",", "sw", ")", ";", "}", "public", "int", "getTrackballKeycodeState", "(", "int", "sw", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "READ_INPUT_STATE", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "return", "mInputManager", ".", "getKeyCodeState", "(", "-", "1", ",", "InputDevice", ".", "SOURCE_TRACKBALL", ",", "sw", ")", ";", "}", "public", "int", "getDPadKeycodeState", "(", "int", "sw", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "READ_INPUT_STATE", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "return", "mInputManager", ".", "getKeyCodeState", "(", "-", "1", ",", "InputDevice", ".", "SOURCE_DPAD", ",", "sw", ")", ";", "}", "public", "boolean", "hasKeys", "(", "int", "[", "]", "keycodes", ",", "boolean", "[", "]", "keyExists", ")", "{", "return", "mInputManager", ".", "hasKeys", "(", "-", "1", ",", "InputDevice", ".", "SOURCE_ANY", ",", "keycodes", ",", "keyExists", ")", ";", "}", "public", "InputChannel", "monitorInput", "(", "String", "inputChannelName", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "READ_INPUT_STATE", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "return", "mInputManager", ".", "monitorInput", "(", "inputChannelName", ")", ";", "}", "public", "void", "setInputFilter", "(", "InputFilter", "filter", ")", "{", "mInputManager", ".", "setInputFilter", "(", "filter", ")", ";", "}", "public", "InputDevice", "getInputDevice", "(", "int", "deviceId", ")", "{", "return", "mInputManager", ".", "getInputDevice", "(", "deviceId", ")", ";", "}", "public", "int", "[", "]", "getInputDeviceIds", "(", ")", "{", "return", "mInputManager", ".", "getInputDeviceIds", "(", ")", ";", "}", "public", "void", "enableScreenAfterBoot", "(", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "DEBUG_BOOT", ")", "{", "RuntimeException", "here", "=", "new", "RuntimeException", "(", "\"here\"", ")", ";", "here", ".", "fillInStackTrace", "(", ")", ";", "Slog", ".", "i", "(", "TAG", ",", "\"\"", "+", "mDisplayEnabled", "+", "\"\"", "+", "mForceDisplayEnabled", "+", "\"\"", "+", "mShowingBootMessages", "+", "\"\"", "+", "mSystemBooted", ",", "here", ")", ";", "}", "if", "(", "mSystemBooted", ")", "{", "return", ";", "}", "mSystemBooted", "=", "true", ";", "hideBootMessagesLocked", "(", ")", ";", "Message", "msg", "=", "mH", ".", "obtainMessage", "(", "H", ".", "BOOT_TIMEOUT", ")", ";", "mH", ".", "sendMessageDelayed", "(", "msg", ",", "30", "*", "1000", ")", ";", "}", "mPolicy", ".", "systemBooted", "(", ")", ";", "performEnableScreen", "(", ")", ";", "}", "void", "enableScreenIfNeededLocked", "(", ")", "{", "if", "(", "DEBUG_BOOT", ")", "{", "RuntimeException", "here", "=", "new", "RuntimeException", "(", "\"here\"", ")", ";", "here", ".", "fillInStackTrace", "(", ")", ";", "Slog", ".", "i", "(", "TAG", ",", "\"\"", "+", "mDisplayEnabled", "+", "\"\"", "+", "mForceDisplayEnabled", "+", "\"\"", "+", "mShowingBootMessages", "+", "\"\"", "+", "mSystemBooted", ",", "here", ")", ";", "}", "if", "(", "mDisplayEnabled", ")", "{", "return", ";", "}", "if", "(", "!", "mSystemBooted", "&&", "!", "mShowingBootMessages", ")", "{", "return", ";", "}", "mH", ".", "sendMessage", "(", "mH", ".", "obtainMessage", "(", "H", ".", "ENABLE_SCREEN", ")", ")", ";", "}", "public", "void", "performBootTimeout", "(", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "mDisplayEnabled", ")", "{", "return", ";", "}", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "mForceDisplayEnabled", "=", "true", ";", "}", "performEnableScreen", "(", ")", ";", "}", "public", "void", "performEnableScreen", "(", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "DEBUG_BOOT", ")", "{", "RuntimeException", "here", "=", "new", "RuntimeException", "(", "\"here\"", ")", ";", "here", ".", "fillInStackTrace", "(", ")", ";", "Slog", ".", "i", "(", "TAG", ",", "\"\"", "+", "mDisplayEnabled", "+", "\"\"", "+", "mForceDisplayEnabled", "+", "\"\"", "+", "mShowingBootMessages", "+", "\"\"", "+", "mSystemBooted", ",", "here", ")", ";", "}", "if", "(", "mDisplayEnabled", ")", "{", "return", ";", "}", "if", "(", "!", "mSystemBooted", "&&", "!", "mShowingBootMessages", ")", "{", "return", ";", "}", "if", "(", "!", "mForceDisplayEnabled", ")", "{", "boolean", "haveBootMsg", "=", "false", ";", "boolean", "haveApp", "=", "false", ";", "boolean", "haveWallpaper", "=", "false", ";", "boolean", "haveKeyguard", "=", "true", ";", "final", "int", "N", "=", "mWindows", ".", "size", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "WindowState", "w", "=", "mWindows", ".", "get", "(", "i", ")", ";", "if", "(", "w", ".", "mAttrs", ".", "type", "==", "WindowManager", ".", "LayoutParams", ".", "TYPE_KEYGUARD", ")", "{", "boolean", "vis", "=", "w", ".", "mViewVisibility", "==", "View", ".", "VISIBLE", "&&", "w", ".", "mPolicyVisibility", ";", "haveKeyguard", "=", "!", "vis", ";", "}", "if", "(", "w", ".", "isVisibleLw", "(", ")", "&&", "!", "w", ".", "mObscured", "&&", "!", "w", ".", "isDrawnLw", "(", ")", ")", "{", "return", ";", "}", "if", "(", "w", ".", "isDrawnLw", "(", ")", ")", "{", "if", "(", "w", ".", "mAttrs", ".", "type", "==", "WindowManager", ".", "LayoutParams", ".", "TYPE_BOOT_PROGRESS", ")", "{", "haveBootMsg", "=", "true", ";", "}", "else", "if", "(", "w", ".", "mAttrs", ".", "type", "==", "WindowManager", ".", "LayoutParams", ".", "TYPE_APPLICATION", ")", "{", "haveApp", "=", "true", ";", "}", "else", "if", "(", "w", ".", "mAttrs", ".", "type", "==", "WindowManager", ".", "LayoutParams", ".", "TYPE_WALLPAPER", ")", "{", "haveWallpaper", "=", "true", ";", "}", "else", "if", "(", "w", ".", "mAttrs", ".", "type", "==", "WindowManager", ".", "LayoutParams", ".", "TYPE_KEYGUARD", ")", "{", "haveKeyguard", "=", "true", ";", "}", "}", "}", "if", "(", "DEBUG_SCREEN_ON", "||", "DEBUG_BOOT", ")", "{", "Slog", ".", "i", "(", "TAG", ",", "\"\"", "+", "mSystemBooted", "+", "\"", "msg=\"", "+", "mShowingBootMessages", "+", "\"", "haveBoot=\"", "+", "haveBootMsg", "+", "\"", "haveApp=\"", "+", "haveApp", "+", "\"", "haveWall=\"", "+", "haveWallpaper", "+", "\"\"", "+", "haveKeyguard", ")", ";", "}", "if", "(", "!", "mSystemBooted", "&&", "!", "haveBootMsg", ")", "{", "return", ";", "}", "if", "(", "mSystemBooted", "&&", "(", "(", "!", "haveApp", "&&", "!", "haveKeyguard", ")", "||", "!", "haveWallpaper", ")", ")", "{", "return", ";", "}", "}", "mDisplayEnabled", "=", "true", ";", "if", "(", "DEBUG_SCREEN_ON", "||", "DEBUG_BOOT", ")", "Slog", ".", "i", "(", "TAG", ",", "\"\"", ")", ";", "if", "(", "false", ")", "{", "StringWriter", "sw", "=", "new", "StringWriter", "(", ")", ";", "PrintWriter", "pw", "=", "new", "PrintWriter", "(", "sw", ")", ";", "this", ".", "dump", "(", "null", ",", "pw", ",", "null", ")", ";", "Slog", ".", "i", "(", "TAG", ",", "sw", ".", "toString", "(", ")", ")", ";", "}", "try", "{", "IBinder", "surfaceFlinger", "=", "ServiceManager", ".", "getService", "(", "\"\"", ")", ";", "if", "(", "surfaceFlinger", "!=", "null", ")", "{", "Parcel", "data", "=", "Parcel", ".", "obtain", "(", ")", ";", "data", ".", "writeInterfaceToken", "(", "\"\"", ")", ";", "surfaceFlinger", ".", "transact", "(", "IBinder", ".", "FIRST_CALL_TRANSACTION", ",", "data", ",", "null", ",", "0", ")", ";", "data", ".", "recycle", "(", ")", ";", "}", "}", "catch", "(", "RemoteException", "ex", ")", "{", "Slog", ".", "e", "(", "TAG", ",", "\"\"", ")", ";", "}", "}", "mPolicy", ".", "enableScreenAfterBoot", "(", ")", ";", "updateRotationUnchecked", "(", "false", ")", ";", "}", "public", "void", "showBootMessage", "(", "final", "CharSequence", "msg", ",", "final", "boolean", "always", ")", "{", "boolean", "first", "=", "false", ";", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "DEBUG_BOOT", ")", "{", "RuntimeException", "here", "=", "new", "RuntimeException", "(", "\"here\"", ")", ";", "here", ".", "fillInStackTrace", "(", ")", ";", "Slog", ".", "i", "(", "TAG", ",", "\"\"", "+", "msg", "+", "\"", "always=\"", "+", "always", "+", "\"\"", "+", "mAllowBootMessages", "+", "\"\"", "+", "mShowingBootMessages", "+", "\"\"", "+", "mSystemBooted", ",", "here", ")", ";", "}", "if", "(", "!", "mAllowBootMessages", ")", "{", "return", ";", "}", "if", "(", "!", "mShowingBootMessages", ")", "{", "if", "(", "!", "always", ")", "{", "return", ";", "}", "first", "=", "true", ";", "}", "if", "(", "mSystemBooted", ")", "{", "return", ";", "}", "mShowingBootMessages", "=", "true", ";", "mPolicy", ".", "showBootMessage", "(", "msg", ",", "always", ")", ";", "}", "if", "(", "first", ")", "{", "performEnableScreen", "(", ")", ";", "}", "}", "public", "void", "hideBootMessagesLocked", "(", ")", "{", "if", "(", "DEBUG_BOOT", ")", "{", "RuntimeException", "here", "=", "new", "RuntimeException", "(", "\"here\"", ")", ";", "here", ".", "fillInStackTrace", "(", ")", ";", "Slog", ".", "i", "(", "TAG", ",", "\"\"", "+", "mDisplayEnabled", "+", "\"\"", "+", "mForceDisplayEnabled", "+", "\"\"", "+", "mShowingBootMessages", "+", "\"\"", "+", "mSystemBooted", ",", "here", ")", ";", "}", "if", "(", "mShowingBootMessages", ")", "{", "mShowingBootMessages", "=", "false", ";", "mPolicy", ".", "hideBootMessages", "(", ")", ";", "}", "}", "public", "void", "setInTouchMode", "(", "boolean", "mode", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "mInTouchMode", "=", "mode", ";", "}", "}", "public", "void", "showStrictModeViolation", "(", "boolean", "on", ")", "{", "int", "pid", "=", "Binder", ".", "getCallingPid", "(", ")", ";", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "on", ")", "{", "boolean", "isVisible", "=", "false", ";", "for", "(", "WindowState", "ws", ":", "mWindows", ")", "{", "if", "(", "ws", ".", "mSession", ".", "mPid", "==", "pid", "&&", "ws", ".", "isVisibleLw", "(", ")", ")", "{", "isVisible", "=", "true", ";", "break", ";", "}", "}", "if", "(", "!", "isVisible", ")", "{", "return", ";", "}", "}", "if", "(", "SHOW_LIGHT_TRANSACTIONS", ")", "Slog", ".", "i", "(", "TAG", ",", "\"\"", ")", ";", "Surface", ".", "openTransaction", "(", ")", ";", "try", "{", "if", "(", "mStrictModeFlash", "==", "null", ")", "{", "mStrictModeFlash", "=", "new", "StrictModeFlash", "(", "mDisplay", ",", "mFxSession", ")", ";", "}", "mStrictModeFlash", ".", "setVisibility", "(", "on", ")", ";", "}", "finally", "{", "Surface", ".", "closeTransaction", "(", ")", ";", "if", "(", "SHOW_LIGHT_TRANSACTIONS", ")", "Slog", ".", "i", "(", "TAG", ",", "\"\"", ")", ";", "}", "}", "}", "public", "void", "setStrictModeVisualIndicatorPreference", "(", "String", "value", ")", "{", "SystemProperties", ".", "set", "(", "StrictMode", ".", "VISUAL_PROPERTY", ",", "value", ")", ";", "}", "public", "void", "setLandscapeProperty", "(", "String", "value", ")", "{", "if", "(", "!", "mSetLandscapeProperty", ")", "return", ";", "SystemProperties", ".", "set", "(", "\"\"", ",", "value", ")", ";", "}", "public", "Bitmap", "screenshotApplications", "(", "IBinder", "appToken", ",", "int", "width", ",", "int", "height", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "READ_FRAME_BUFFER", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "Bitmap", "rawss", ";", "int", "maxLayer", "=", "0", ";", "final", "Rect", "frame", "=", "new", "Rect", "(", ")", ";", "float", "scale", ";", "int", "dw", ",", "dh", ";", "int", "rot", ";", "synchronized", "(", "mWindowMap", ")", "{", "long", "ident", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "dw", "=", "mAppDisplayWidth", ";", "dh", "=", "mAppDisplayHeight", ";", "int", "aboveAppLayer", "=", "mPolicy", ".", "windowTypeToLayerLw", "(", "WindowManager", ".", "LayoutParams", ".", "TYPE_APPLICATION", ")", "*", "TYPE_LAYER_MULTIPLIER", "+", "TYPE_LAYER_OFFSET", ";", "aboveAppLayer", "+=", "TYPE_LAYER_MULTIPLIER", ";", "boolean", "isImeTarget", "=", "mInputMethodTarget", "!=", "null", "&&", "mInputMethodTarget", ".", "mAppToken", "!=", "null", "&&", "mInputMethodTarget", ".", "mAppToken", ".", "appToken", "!=", "null", "&&", "mInputMethodTarget", ".", "mAppToken", ".", "appToken", ".", "asBinder", "(", ")", "==", "appToken", ";", "boolean", "including", "=", "false", ";", "for", "(", "int", "i", "=", "mWindows", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowState", "ws", "=", "mWindows", ".", "get", "(", "i", ")", ";", "if", "(", "ws", ".", "mSurface", "==", "null", ")", "{", "continue", ";", "}", "if", "(", "ws", ".", "mLayer", ">=", "aboveAppLayer", ")", "{", "continue", ";", "}", "if", "(", "!", "including", "&&", "appToken", "!=", "null", ")", "{", "if", "(", "!", "ws", ".", "mIsImWindow", "||", "!", "isImeTarget", ")", "{", "if", "(", "ws", ".", "mAppToken", "==", "null", "||", "ws", ".", "mAppToken", ".", "token", "!=", "appToken", ")", "{", "continue", ";", "}", "}", "}", "including", "=", "!", "ws", ".", "mIsImWindow", "&&", "!", "ws", ".", "isFullscreen", "(", "dw", ",", "dh", ")", ";", "if", "(", "maxLayer", "<", "ws", ".", "mAnimLayer", ")", "{", "maxLayer", "=", "ws", ".", "mAnimLayer", ";", "}", "if", "(", "!", "ws", ".", "mIsWallpaper", ")", "{", "final", "Rect", "wf", "=", "ws", ".", "mFrame", ";", "final", "Rect", "cr", "=", "ws", ".", "mContentInsets", ";", "int", "left", "=", "wf", ".", "left", "+", "cr", ".", "left", ";", "int", "top", "=", "wf", ".", "top", "+", "cr", ".", "top", ";", "int", "right", "=", "wf", ".", "right", "-", "cr", ".", "right", ";", "int", "bottom", "=", "wf", ".", "bottom", "-", "cr", ".", "bottom", ";", "frame", ".", "union", "(", "left", ",", "top", ",", "right", ",", "bottom", ")", ";", "}", "}", "Binder", ".", "restoreCallingIdentity", "(", "ident", ")", ";", "frame", ".", "intersect", "(", "0", ",", "0", ",", "dw", ",", "dh", ")", ";", "if", "(", "frame", ".", "isEmpty", "(", ")", "||", "maxLayer", "==", "0", ")", "{", "return", "null", ";", "}", "rot", "=", "mDisplay", ".", "getRotation", "(", ")", ";", "rot", "=", "(", "rot", "+", "(", "android", ".", "os", ".", "SystemProperties", ".", "getInt", "(", "\"\"", ",", "0", ")", "/", "90", ")", ")", "%", "4", ";", "int", "fw", "=", "frame", ".", "width", "(", ")", ";", "int", "fh", "=", "frame", ".", "height", "(", ")", ";", "float", "targetWidthScale", "=", "width", "/", "(", "float", ")", "fw", ";", "float", "targetHeightScale", "=", "height", "/", "(", "float", ")", "fh", ";", "if", "(", "dw", "<=", "dh", ")", "{", "scale", "=", "targetWidthScale", ";", "if", "(", "targetHeightScale", ">", "scale", "&&", "(", "int", ")", "(", "targetHeightScale", "*", "fw", ")", "==", "width", ")", "{", "scale", "=", "targetHeightScale", ";", "}", "}", "else", "{", "scale", "=", "targetHeightScale", ";", "if", "(", "targetWidthScale", ">", "scale", "&&", "(", "int", ")", "(", "targetWidthScale", "*", "fh", ")", "==", "height", ")", "{", "scale", "=", "targetWidthScale", ";", "}", "}", "dw", "=", "(", "int", ")", "(", "dw", "*", "scale", ")", ";", "dh", "=", "(", "int", ")", "(", "dh", "*", "scale", ")", ";", "if", "(", "rot", "==", "Surface", ".", "ROTATION_90", "||", "rot", "==", "Surface", ".", "ROTATION_270", ")", "{", "int", "tmp", "=", "dw", ";", "dw", "=", "dh", ";", "dh", "=", "tmp", ";", "rot", "=", "(", "rot", "==", "Surface", ".", "ROTATION_90", ")", "?", "Surface", ".", "ROTATION_270", ":", "Surface", ".", "ROTATION_90", ";", "}", "if", "(", "DEBUG_SCREENSHOT", ")", "{", "Slog", ".", "i", "(", "TAG", ",", "\"Screenshot:", "\"", "+", "dw", "+", "\"x\"", "+", "dh", "+", "\"", "from", "0", "to", "\"", "+", "maxLayer", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "mWindows", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Slog", ".", "i", "(", "TAG", ",", "mWindows", ".", "get", "(", "i", ")", "+", "\":", "\"", "+", "mWindows", ".", "get", "(", "i", ")", ".", "mLayer", "+", "\"", "animLayer=\"", "+", "mWindows", ".", "get", "(", "i", ")", ".", "mAnimLayer", "+", "\"\"", "+", "mWindows", ".", "get", "(", "i", ")", ".", "mSurfaceLayer", ")", ";", "}", "}", "rawss", "=", "Surface", ".", "screenshot", "(", "dw", ",", "dh", ",", "0", ",", "maxLayer", ")", ";", "}", "if", "(", "rawss", "==", "null", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "dw", "+", "\"x\"", "+", "dh", "+", "\")", "to", "layer", "\"", "+", "maxLayer", ")", ";", "return", "null", ";", "}", "Bitmap", "bm", "=", "Bitmap", ".", "createBitmap", "(", "width", ",", "height", ",", "rawss", ".", "getConfig", "(", ")", ")", ";", "Matrix", "matrix", "=", "new", "Matrix", "(", ")", ";", "ScreenRotationAnimation", ".", "createRotationMatrix", "(", "rot", ",", "dw", ",", "dh", ",", "matrix", ")", ";", "matrix", ".", "postTranslate", "(", "-", "(", "int", ")", "(", "frame", ".", "left", "*", "scale", ")", ",", "-", "(", "int", ")", "(", "frame", ".", "top", "*", "scale", ")", ")", ";", "Canvas", "canvas", "=", "new", "Canvas", "(", "bm", ")", ";", "canvas", ".", "drawBitmap", "(", "rawss", ",", "matrix", ",", "null", ")", ";", "canvas", ".", "setBitmap", "(", "null", ")", ";", "rawss", ".", "recycle", "(", ")", ";", "return", "bm", ";", "}", "public", "void", "freezeRotation", "(", "int", "rotation", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "SET_ORIENTATION", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "if", "(", "rotation", "<", "-", "1", "||", "rotation", ">", "Surface", ".", "ROTATION_270", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"\"", "+", "\"\"", ")", ";", "}", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "mRotation", ")", ";", "mPolicy", ".", "setUserRotationMode", "(", "WindowManagerPolicy", ".", "USER_ROTATION_LOCKED", ",", "rotation", "==", "-", "1", "?", "mRotation", ":", "rotation", ")", ";", "updateRotationUnchecked", "(", "false", ")", ";", "}", "public", "void", "thawRotation", "(", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "SET_ORIENTATION", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "mRotation", ")", ";", "mPolicy", ".", "setUserRotationMode", "(", "WindowManagerPolicy", ".", "USER_ROTATION_FREE", ",", "777", ")", ";", "updateRotationUnchecked", "(", "false", ")", ";", "}", "public", "void", "updateRotation", "(", "boolean", "alwaysSendConfiguration", ")", "{", "updateRotationUnchecked", "(", "alwaysSendConfiguration", ")", ";", "}", "void", "pauseRotationLocked", "(", ")", "{", "mDeferredRotationPauseCount", "+=", "1", ";", "}", "void", "resumeRotationLocked", "(", ")", "{", "if", "(", "mDeferredRotationPauseCount", ">", "0", ")", "{", "mDeferredRotationPauseCount", "-=", "1", ";", "if", "(", "mDeferredRotationPauseCount", "==", "0", ")", "{", "boolean", "changed", "=", "updateRotationUncheckedLocked", "(", "false", ")", ";", "if", "(", "changed", ")", "{", "mH", ".", "sendEmptyMessage", "(", "H", ".", "SEND_NEW_CONFIGURATION", ")", ";", "}", "}", "}", "}", "public", "void", "updateRotationUnchecked", "(", "boolean", "alwaysSendConfiguration", ")", "{", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "\"\"", "+", "alwaysSendConfiguration", "+", "\")\"", ")", ";", "long", "origId", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "boolean", "changed", ";", "synchronized", "(", "mWindowMap", ")", "{", "changed", "=", "updateRotationUncheckedLocked", "(", "false", ")", ";", "}", "if", "(", "changed", "||", "alwaysSendConfiguration", ")", "{", "sendNewConfiguration", "(", ")", ";", "}", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "}", "public", "boolean", "updateRotationUncheckedLocked", "(", "boolean", "inTransaction", ")", "{", "if", "(", "mDeferredRotationPauseCount", ">", "0", ")", "{", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "return", "false", ";", "}", "if", "(", "mScreenRotationAnimation", "!=", "null", "&&", "mScreenRotationAnimation", ".", "isAnimating", "(", ")", ")", "{", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "return", "false", ";", "}", "if", "(", "!", "mDisplayEnabled", ")", "{", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "return", "false", ";", "}", "int", "rotation", "=", "mPolicy", ".", "rotationForOrientationLw", "(", "mForcedAppOrientation", ",", "mRotation", ")", ";", "boolean", "altOrientation", "=", "!", "mPolicy", ".", "rotationHasCompatibleMetricsLw", "(", "mForcedAppOrientation", ",", "rotation", ")", ";", "if", "(", "DEBUG_ORIENTATION", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "mForcedAppOrientation", "+", "\"\"", "+", "rotation", "+", "\"", "which", "has", "\"", "+", "(", "altOrientation", "?", "\"incompatible\"", ":", "\"compatible\"", ")", "+", "\"", "metrics\"", ")", ";", "}", "if", "(", "mRotation", "==", "rotation", "&&", "mAltOrientation", "==", "altOrientation", ")", "{", "return", "false", ";", "}", "if", "(", "DEBUG_ORIENTATION", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "rotation", "+", "(", "altOrientation", "?", "\"", "(alt)\"", ":", "\"\"", ")", "+", "\"", "from", "\"", "+", "mRotation", "+", "(", "mAltOrientation", "?", "\"", "(alt)\"", ":", "\"\"", ")", "+", "\",", "forceApp=\"", "+", "mForcedAppOrientation", ")", ";", "}", "mRotation", "=", "rotation", ";", "mAltOrientation", "=", "altOrientation", ";", "mPolicy", ".", "setRotationLw", "(", "mRotation", ")", ";", "mWindowsFreezingScreen", "=", "true", ";", "mH", ".", "removeMessages", "(", "H", ".", "WINDOW_FREEZE_TIMEOUT", ")", ";", "mH", ".", "sendMessageDelayed", "(", "mH", ".", "obtainMessage", "(", "H", ".", "WINDOW_FREEZE_TIMEOUT", ")", ",", "2000", ")", ";", "mWaitingForConfig", "=", "true", ";", "mLayoutNeeded", "=", "true", ";", "startFreezingDisplayLocked", "(", "inTransaction", ")", ";", "mInputManager", ".", "setDisplayOrientation", "(", "0", ",", "rotation", ")", ";", "if", "(", "!", "inTransaction", ")", "{", "if", "(", "SHOW_TRANSACTIONS", ")", "Slog", ".", "i", "(", "TAG", ",", "\"\"", ")", ";", "Surface", ".", "openTransaction", "(", ")", ";", "}", "try", "{", "if", "(", "CUSTOM_SCREEN_ROTATION", "&&", "mScreenRotationAnimation", "!=", "null", "&&", "mScreenRotationAnimation", ".", "hasScreenshot", "(", ")", ")", "{", "mScreenRotationAnimation", ".", "setRotation", "(", "rotation", ")", ";", "}", "Surface", ".", "setOrientation", "(", "0", ",", "rotation", ")", ";", "}", "finally", "{", "if", "(", "!", "inTransaction", ")", "{", "Surface", ".", "closeTransaction", "(", ")", ";", "if", "(", "SHOW_LIGHT_TRANSACTIONS", ")", "Slog", ".", "i", "(", "TAG", ",", "\"\"", ")", ";", "}", "}", "rebuildBlackFrame", "(", "inTransaction", ")", ";", "for", "(", "int", "i", "=", "mWindows", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowState", "w", "=", "mWindows", ".", "get", "(", "i", ")", ";", "if", "(", "w", ".", "mSurface", "!=", "null", ")", "{", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "w", ")", ";", "w", ".", "mOrientationChanging", "=", "true", ";", "}", "}", "for", "(", "int", "i", "=", "mRotationWatchers", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "try", "{", "mRotationWatchers", ".", "get", "(", "i", ")", ".", "onRotationChanged", "(", "rotation", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "return", "true", ";", "}", "public", "int", "getRotation", "(", ")", "{", "return", "mRotation", ";", "}", "public", "int", "watchRotation", "(", "IRotationWatcher", "watcher", ")", "{", "final", "IBinder", "watcherBinder", "=", "watcher", ".", "asBinder", "(", ")", ";", "IBinder", ".", "DeathRecipient", "dr", "=", "new", "IBinder", ".", "DeathRecipient", "(", ")", "{", "public", "void", "binderDied", "(", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "mRotationWatchers", ".", "size", "(", ")", ";", "i", "++", ")", "{", "if", "(", "watcherBinder", "==", "mRotationWatchers", ".", "get", "(", "i", ")", ".", "asBinder", "(", ")", ")", "{", "IRotationWatcher", "removed", "=", "mRotationWatchers", ".", "remove", "(", "i", ")", ";", "if", "(", "removed", "!=", "null", ")", "{", "removed", ".", "asBinder", "(", ")", ".", "unlinkToDeath", "(", "this", ",", "0", ")", ";", "}", "i", "--", ";", "}", "}", "}", "}", "}", ";", "synchronized", "(", "mWindowMap", ")", "{", "try", "{", "watcher", ".", "asBinder", "(", ")", ".", "linkToDeath", "(", "dr", ",", "0", ")", ";", "mRotationWatchers", ".", "add", "(", "watcher", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "return", "mRotation", ";", "}", "}", "public", "int", "getPreferredOptionsPanelGravity", "(", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "final", "int", "rotation", "=", "getRotation", "(", ")", ";", "if", "(", "mInitialDisplayWidth", "<", "mInitialDisplayHeight", ")", "{", "switch", "(", "rotation", ")", "{", "default", ":", "case", "Surface", ".", "ROTATION_0", ":", "return", "Gravity", ".", "CENTER_HORIZONTAL", "|", "Gravity", ".", "BOTTOM", ";", "case", "Surface", ".", "ROTATION_90", ":", "return", "Gravity", ".", "RIGHT", "|", "Gravity", ".", "BOTTOM", ";", "case", "Surface", ".", "ROTATION_180", ":", "return", "Gravity", ".", "CENTER_HORIZONTAL", "|", "Gravity", ".", "BOTTOM", ";", "case", "Surface", ".", "ROTATION_270", ":", "return", "Gravity", ".", "LEFT", "|", "Gravity", ".", "BOTTOM", ";", "}", "}", "else", "{", "switch", "(", "rotation", ")", "{", "default", ":", "case", "Surface", ".", "ROTATION_0", ":", "return", "Gravity", ".", "RIGHT", "|", "Gravity", ".", "BOTTOM", ";", "case", "Surface", ".", "ROTATION_90", ":", "return", "Gravity", ".", "CENTER_HORIZONTAL", "|", "Gravity", ".", "BOTTOM", ";", "case", "Surface", ".", "ROTATION_180", ":", "return", "Gravity", ".", "LEFT", "|", "Gravity", ".", "BOTTOM", ";", "case", "Surface", ".", "ROTATION_270", ":", "return", "Gravity", ".", "CENTER_HORIZONTAL", "|", "Gravity", ".", "BOTTOM", ";", "}", "}", "}", "}", "public", "boolean", "startViewServer", "(", "int", "port", ")", "{", "if", "(", "isSystemSecure", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "checkCallingPermission", "(", "Manifest", ".", "permission", ".", "DUMP", ",", "\"\"", ")", ")", "{", "return", "false", ";", "}", "if", "(", "port", "<", "1024", ")", "{", "return", "false", ";", "}", "if", "(", "mViewServer", "!=", "null", ")", "{", "if", "(", "!", "mViewServer", ".", "isRunning", "(", ")", ")", "{", "try", "{", "return", "mViewServer", ".", "start", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "}", "}", "return", "false", ";", "}", "try", "{", "mViewServer", "=", "new", "ViewServer", "(", "this", ",", "port", ")", ";", "return", "mViewServer", ".", "start", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "}", "return", "false", ";", "}", "private", "boolean", "isSystemSecure", "(", ")", "{", "return", "\"1\"", ".", "equals", "(", "SystemProperties", ".", "get", "(", "SYSTEM_SECURE", ",", "\"1\"", ")", ")", "&&", "\"0\"", ".", "equals", "(", "SystemProperties", ".", "get", "(", "SYSTEM_DEBUGGABLE", ",", "\"0\"", ")", ")", ";", "}", "public", "boolean", "stopViewServer", "(", ")", "{", "if", "(", "isSystemSecure", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "checkCallingPermission", "(", "Manifest", ".", "permission", ".", "DUMP", ",", "\"\"", ")", ")", "{", "return", "false", ";", "}", "if", "(", "mViewServer", "!=", "null", ")", "{", "return", "mViewServer", ".", "stop", "(", ")", ";", "}", "return", "false", ";", "}", "public", "boolean", "isViewServerRunning", "(", ")", "{", "if", "(", "isSystemSecure", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "checkCallingPermission", "(", "Manifest", ".", "permission", ".", "DUMP", ",", "\"\"", ")", ")", "{", "return", "false", ";", "}", "return", "mViewServer", "!=", "null", "&&", "mViewServer", ".", "isRunning", "(", ")", ";", "}", "boolean", "viewServerListWindows", "(", "Socket", "client", ")", "{", "if", "(", "isSystemSecure", "(", ")", ")", "{", "return", "false", ";", "}", "boolean", "result", "=", "true", ";", "WindowState", "[", "]", "windows", ";", "synchronized", "(", "mWindowMap", ")", "{", "windows", "=", "mWindows", ".", "toArray", "(", "new", "WindowState", "[", "mWindows", ".", "size", "(", ")", "]", ")", ";", "}", "BufferedWriter", "out", "=", "null", ";", "try", "{", "OutputStream", "clientStream", "=", "client", ".", "getOutputStream", "(", ")", ";", "out", "=", "new", "BufferedWriter", "(", "new", "OutputStreamWriter", "(", "clientStream", ")", ",", "8", "*", "1024", ")", ";", "final", "int", "count", "=", "windows", ".", "length", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "count", ";", "i", "++", ")", "{", "final", "WindowState", "w", "=", "windows", "[", "i", "]", ";", "out", ".", "write", "(", "Integer", ".", "toHexString", "(", "System", ".", "identityHashCode", "(", "w", ")", ")", ")", ";", "out", ".", "write", "(", "'", "'", ")", ";", "out", ".", "append", "(", "w", ".", "mAttrs", ".", "getTitle", "(", ")", ")", ";", "out", ".", "write", "(", "'\\n'", ")", ";", "}", "out", ".", "write", "(", "\"DONE.n\"", ")", ";", "out", ".", "flush", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "result", "=", "false", ";", "}", "finally", "{", "if", "(", "out", "!=", "null", ")", "{", "try", "{", "out", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "result", "=", "false", ";", "}", "}", "}", "return", "result", ";", "}", "boolean", "viewServerGetFocusedWindow", "(", "Socket", "client", ")", "{", "if", "(", "isSystemSecure", "(", ")", ")", "{", "return", "false", ";", "}", "boolean", "result", "=", "true", ";", "WindowState", "focusedWindow", "=", "getFocusedWindow", "(", ")", ";", "BufferedWriter", "out", "=", "null", ";", "try", "{", "OutputStream", "clientStream", "=", "client", ".", "getOutputStream", "(", ")", ";", "out", "=", "new", "BufferedWriter", "(", "new", "OutputStreamWriter", "(", "clientStream", ")", ",", "8", "*", "1024", ")", ";", "if", "(", "focusedWindow", "!=", "null", ")", "{", "out", ".", "write", "(", "Integer", ".", "toHexString", "(", "System", ".", "identityHashCode", "(", "focusedWindow", ")", ")", ")", ";", "out", ".", "write", "(", "'", "'", ")", ";", "out", ".", "append", "(", "focusedWindow", ".", "mAttrs", ".", "getTitle", "(", ")", ")", ";", "}", "out", ".", "write", "(", "'\\n'", ")", ";", "out", ".", "flush", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "result", "=", "false", ";", "}", "finally", "{", "if", "(", "out", "!=", "null", ")", "{", "try", "{", "out", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "result", "=", "false", ";", "}", "}", "}", "return", "result", ";", "}", "boolean", "viewServerWindowCommand", "(", "Socket", "client", ",", "String", "command", ",", "String", "parameters", ")", "{", "if", "(", "isSystemSecure", "(", ")", ")", "{", "return", "false", ";", "}", "boolean", "success", "=", "true", ";", "Parcel", "data", "=", "null", ";", "Parcel", "reply", "=", "null", ";", "BufferedWriter", "out", "=", "null", ";", "try", "{", "int", "index", "=", "parameters", ".", "indexOf", "(", "'", "'", ")", ";", "if", "(", "index", "==", "-", "1", ")", "{", "index", "=", "parameters", ".", "length", "(", ")", ";", "}", "final", "String", "code", "=", "parameters", ".", "substring", "(", "0", ",", "index", ")", ";", "int", "hashCode", "=", "(", "int", ")", "Long", ".", "parseLong", "(", "code", ",", "16", ")", ";", "if", "(", "index", "<", "parameters", ".", "length", "(", ")", ")", "{", "parameters", "=", "parameters", ".", "substring", "(", "index", "+", "1", ")", ";", "}", "else", "{", "parameters", "=", "\"\"", ";", "}", "final", "WindowState", "window", "=", "findWindow", "(", "hashCode", ")", ";", "if", "(", "window", "==", "null", ")", "{", "return", "false", ";", "}", "data", "=", "Parcel", ".", "obtain", "(", ")", ";", "data", ".", "writeInterfaceToken", "(", "\"\"", ")", ";", "data", ".", "writeString", "(", "command", ")", ";", "data", ".", "writeString", "(", "parameters", ")", ";", "data", ".", "writeInt", "(", "1", ")", ";", "ParcelFileDescriptor", ".", "fromSocket", "(", "client", ")", ".", "writeToParcel", "(", "data", ",", "0", ")", ";", "reply", "=", "Parcel", ".", "obtain", "(", ")", ";", "final", "IBinder", "binder", "=", "window", ".", "mClient", ".", "asBinder", "(", ")", ";", "binder", ".", "transact", "(", "IBinder", ".", "FIRST_CALL_TRANSACTION", ",", "data", ",", "reply", ",", "0", ")", ";", "reply", ".", "readException", "(", ")", ";", "if", "(", "!", "client", ".", "isOutputShutdown", "(", ")", ")", "{", "out", "=", "new", "BufferedWriter", "(", "new", "OutputStreamWriter", "(", "client", ".", "getOutputStream", "(", ")", ")", ")", ";", "out", ".", "write", "(", "\"DONEn\"", ")", ";", "out", ".", "flush", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "command", "+", "\"\"", "+", "parameters", ",", "e", ")", ";", "success", "=", "false", ";", "}", "finally", "{", "if", "(", "data", "!=", "null", ")", "{", "data", ".", "recycle", "(", ")", ";", "}", "if", "(", "reply", "!=", "null", ")", "{", "reply", ".", "recycle", "(", ")", ";", "}", "if", "(", "out", "!=", "null", ")", "{", "try", "{", "out", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "}", "}", "}", "return", "success", ";", "}", "public", "void", "addWindowChangeListener", "(", "WindowChangeListener", "listener", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "mWindowChangeListeners", ".", "add", "(", "listener", ")", ";", "}", "}", "public", "void", "removeWindowChangeListener", "(", "WindowChangeListener", "listener", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "mWindowChangeListeners", ".", "remove", "(", "listener", ")", ";", "}", "}", "private", "void", "notifyWindowsChanged", "(", ")", "{", "WindowChangeListener", "[", "]", "windowChangeListeners", ";", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "mWindowChangeListeners", ".", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "windowChangeListeners", "=", "new", "WindowChangeListener", "[", "mWindowChangeListeners", ".", "size", "(", ")", "]", ";", "windowChangeListeners", "=", "mWindowChangeListeners", ".", "toArray", "(", "windowChangeListeners", ")", ";", "}", "int", "N", "=", "windowChangeListeners", ".", "length", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "windowChangeListeners", "[", "i", "]", ".", "windowsChanged", "(", ")", ";", "}", "}", "private", "void", "notifyFocusChanged", "(", ")", "{", "WindowChangeListener", "[", "]", "windowChangeListeners", ";", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "mWindowChangeListeners", ".", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "windowChangeListeners", "=", "new", "WindowChangeListener", "[", "mWindowChangeListeners", ".", "size", "(", ")", "]", ";", "windowChangeListeners", "=", "mWindowChangeListeners", ".", "toArray", "(", "windowChangeListeners", ")", ";", "}", "int", "N", "=", "windowChangeListeners", ".", "length", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "windowChangeListeners", "[", "i", "]", ".", "focusChanged", "(", ")", ";", "}", "}", "private", "WindowState", "findWindow", "(", "int", "hashCode", ")", "{", "if", "(", "hashCode", "==", "-", "1", ")", "{", "return", "getFocusedWindow", "(", ")", ";", "}", "synchronized", "(", "mWindowMap", ")", "{", "final", "ArrayList", "<", "WindowState", ">", "windows", "=", "mWindows", ";", "final", "int", "count", "=", "windows", ".", "size", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "count", ";", "i", "++", ")", "{", "WindowState", "w", "=", "windows", ".", "get", "(", "i", ")", ";", "if", "(", "System", ".", "identityHashCode", "(", "w", ")", "==", "hashCode", ")", "{", "return", "w", ";", "}", "}", "}", "return", "null", ";", "}", "void", "sendNewConfiguration", "(", ")", "{", "try", "{", "mActivityManager", ".", "updateConfiguration", "(", "null", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "public", "Configuration", "computeNewConfiguration", "(", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "Configuration", "config", "=", "computeNewConfigurationLocked", "(", ")", ";", "if", "(", "config", "==", "null", "&&", "mWaitingForConfig", ")", "{", "mWaitingForConfig", "=", "false", ";", "performLayoutAndPlaceSurfacesLocked", "(", ")", ";", "}", "return", "config", ";", "}", "}", "Configuration", "computeNewConfigurationLocked", "(", ")", "{", "Configuration", "config", "=", "new", "Configuration", "(", ")", ";", "config", ".", "fontScale", "=", "0", ";", "if", "(", "!", "computeNewConfigurationLocked", "(", "config", ")", ")", "{", "return", "null", ";", "}", "return", "config", ";", "}", "private", "int", "reduceConfigWidthSize", "(", "int", "curSize", ",", "int", "rotation", ",", "float", "density", ",", "int", "dw", ",", "int", "dh", ")", "{", "int", "size", "=", "(", "int", ")", "(", "mPolicy", ".", "getConfigDisplayWidth", "(", "dw", ",", "dh", ",", "rotation", ")", "/", "density", ")", ";", "if", "(", "size", "<", "curSize", ")", "{", "curSize", "=", "size", ";", "}", "return", "curSize", ";", "}", "private", "int", "reduceConfigLayout", "(", "int", "curLayout", ",", "int", "rotation", ",", "float", "density", ",", "int", "dw", ",", "int", "dh", ")", "{", "int", "w", "=", "mPolicy", ".", "getNonDecorDisplayWidth", "(", "dw", ",", "dh", ",", "rotation", ")", ";", "int", "h", "=", "mPolicy", ".", "getNonDecorDisplayHeight", "(", "dw", ",", "dh", ",", "rotation", ")", ";", "int", "screenLayoutSize", ";", "boolean", "screenLayoutLong", ";", "boolean", "screenLayoutCompatNeeded", ";", "int", "longSize", "=", "w", ";", "int", "shortSize", "=", "h", ";", "if", "(", "longSize", "<", "shortSize", ")", "{", "int", "tmp", "=", "longSize", ";", "longSize", "=", "shortSize", ";", "shortSize", "=", "tmp", ";", "}", "longSize", "=", "(", "int", ")", "(", "longSize", "/", "density", ")", ";", "shortSize", "=", "(", "int", ")", "(", "shortSize", "/", "density", ")", ";", "if", "(", "longSize", "<", "470", ")", "{", "screenLayoutSize", "=", "Configuration", ".", "SCREENLAYOUT_SIZE_SMALL", ";", "screenLayoutLong", "=", "false", ";", "screenLayoutCompatNeeded", "=", "false", ";", "}", "else", "{", "if", "(", "longSize", ">=", "960", "&&", "shortSize", ">=", "720", ")", "{", "screenLayoutSize", "=", "Configuration", ".", "SCREENLAYOUT_SIZE_XLARGE", ";", "}", "else", "if", "(", "longSize", ">=", "640", ")", "{", "screenLayoutSize", "=", "Configuration", ".", "SCREENLAYOUT_SIZE_LARGE", ";", "}", "else", "{", "screenLayoutSize", "=", "Configuration", ".", "SCREENLAYOUT_SIZE_NORMAL", ";", "}", "if", "(", "shortSize", ">", "321", "||", "longSize", ">", "570", ")", "{", "screenLayoutCompatNeeded", "=", "true", ";", "}", "else", "{", "screenLayoutCompatNeeded", "=", "false", ";", "}", "if", "(", "(", "(", "longSize", "*", "3", ")", "/", "5", ")", ">=", "(", "shortSize", "-", "1", ")", ")", "{", "screenLayoutLong", "=", "true", ";", "}", "else", "{", "screenLayoutLong", "=", "false", ";", "}", "}", "if", "(", "!", "screenLayoutLong", ")", "{", "curLayout", "=", "(", "curLayout", "&", "~", "Configuration", ".", "SCREENLAYOUT_LONG_MASK", ")", "|", "Configuration", ".", "SCREENLAYOUT_LONG_NO", ";", "}", "if", "(", "screenLayoutCompatNeeded", ")", "{", "curLayout", "|=", "Configuration", ".", "SCREENLAYOUT_COMPAT_NEEDED", ";", "}", "int", "curSize", "=", "curLayout", "&", "Configuration", ".", "SCREENLAYOUT_SIZE_MASK", ";", "if", "(", "screenLayoutSize", "<", "curSize", ")", "{", "curLayout", "=", "(", "curLayout", "&", "~", "Configuration", ".", "SCREENLAYOUT_SIZE_MASK", ")", "|", "screenLayoutSize", ";", "}", "return", "curLayout", ";", "}", "private", "void", "computeSmallestWidthAndScreenLayout", "(", "boolean", "rotated", ",", "int", "dw", ",", "int", "dh", ",", "float", "density", ",", "Configuration", "outConfig", ")", "{", "int", "unrotDw", ",", "unrotDh", ";", "if", "(", "rotated", ")", "{", "unrotDw", "=", "dh", ";", "unrotDh", "=", "dw", ";", "}", "else", "{", "unrotDw", "=", "dw", ";", "unrotDh", "=", "dh", ";", "}", "int", "sw", "=", "reduceConfigWidthSize", "(", "unrotDw", ",", "Surface", ".", "ROTATION_0", ",", "density", ",", "unrotDw", ",", "unrotDh", ")", ";", "sw", "=", "reduceConfigWidthSize", "(", "sw", ",", "Surface", ".", "ROTATION_90", ",", "density", ",", "unrotDh", ",", "unrotDw", ")", ";", "sw", "=", "reduceConfigWidthSize", "(", "sw", ",", "Surface", ".", "ROTATION_180", ",", "density", ",", "unrotDw", ",", "unrotDh", ")", ";", "sw", "=", "reduceConfigWidthSize", "(", "sw", ",", "Surface", ".", "ROTATION_270", ",", "density", ",", "unrotDh", ",", "unrotDw", ")", ";", "int", "sl", "=", "Configuration", ".", "SCREENLAYOUT_SIZE_XLARGE", "|", "Configuration", ".", "SCREENLAYOUT_LONG_YES", ";", "sl", "=", "reduceConfigLayout", "(", "sl", ",", "Surface", ".", "ROTATION_0", ",", "density", ",", "unrotDw", ",", "unrotDh", ")", ";", "sl", "=", "reduceConfigLayout", "(", "sl", ",", "Surface", ".", "ROTATION_90", ",", "density", ",", "unrotDh", ",", "unrotDw", ")", ";", "sl", "=", "reduceConfigLayout", "(", "sl", ",", "Surface", ".", "ROTATION_180", ",", "density", ",", "unrotDw", ",", "unrotDh", ")", ";", "sl", "=", "reduceConfigLayout", "(", "sl", ",", "Surface", ".", "ROTATION_270", ",", "density", ",", "unrotDh", ",", "unrotDw", ")", ";", "outConfig", ".", "smallestScreenWidthDp", "=", "sw", ";", "outConfig", ".", "screenLayout", "=", "sl", ";", "}", "private", "int", "reduceCompatConfigWidthSize", "(", "int", "curSize", ",", "int", "rotation", ",", "DisplayMetrics", "dm", ",", "int", "dw", ",", "int", "dh", ")", "{", "dm", ".", "noncompatWidthPixels", "=", "mPolicy", ".", "getNonDecorDisplayWidth", "(", "dw", ",", "dh", ",", "rotation", ")", ";", "dm", ".", "noncompatHeightPixels", "=", "mPolicy", ".", "getNonDecorDisplayHeight", "(", "dw", ",", "dh", ",", "rotation", ")", ";", "float", "scale", "=", "CompatibilityInfo", ".", "computeCompatibleScaling", "(", "dm", ",", "null", ")", ";", "int", "size", "=", "(", "int", ")", "(", "(", "(", "dm", ".", "noncompatWidthPixels", "/", "scale", ")", "/", "dm", ".", "density", ")", "+", ".5f", ")", ";", "if", "(", "curSize", "==", "0", "||", "size", "<", "curSize", ")", "{", "curSize", "=", "size", ";", "}", "return", "curSize", ";", "}", "private", "int", "computeCompatSmallestWidth", "(", "boolean", "rotated", ",", "DisplayMetrics", "dm", ",", "int", "dw", ",", "int", "dh", ")", "{", "mTmpDisplayMetrics", ".", "setTo", "(", "dm", ")", ";", "dm", "=", "mTmpDisplayMetrics", ";", "int", "unrotDw", ",", "unrotDh", ";", "if", "(", "rotated", ")", "{", "unrotDw", "=", "dh", ";", "unrotDh", "=", "dw", ";", "}", "else", "{", "unrotDw", "=", "dw", ";", "unrotDh", "=", "dh", ";", "}", "int", "sw", "=", "reduceCompatConfigWidthSize", "(", "0", ",", "Surface", ".", "ROTATION_0", ",", "dm", ",", "unrotDw", ",", "unrotDh", ")", ";", "sw", "=", "reduceCompatConfigWidthSize", "(", "sw", ",", "Surface", ".", "ROTATION_90", ",", "dm", ",", "unrotDh", ",", "unrotDw", ")", ";", "sw", "=", "reduceCompatConfigWidthSize", "(", "sw", ",", "Surface", ".", "ROTATION_180", ",", "dm", ",", "unrotDw", ",", "unrotDh", ")", ";", "sw", "=", "reduceCompatConfigWidthSize", "(", "sw", ",", "Surface", ".", "ROTATION_270", ",", "dm", ",", "unrotDh", ",", "unrotDw", ")", ";", "return", "sw", ";", "}", "boolean", "computeNewConfigurationLocked", "(", "Configuration", "config", ")", "{", "if", "(", "mDisplay", "==", "null", ")", "{", "return", "false", ";", "}", "mInputManager", ".", "getInputConfiguration", "(", "config", ")", ";", "final", "boolean", "rotated", "=", "(", "mRotation", "==", "Surface", ".", "ROTATION_90", "||", "mRotation", "==", "Surface", ".", "ROTATION_270", ")", ";", "final", "int", "realdw", "=", "rotated", "?", "mBaseDisplayHeight", ":", "mBaseDisplayWidth", ";", "final", "int", "realdh", "=", "rotated", "?", "mBaseDisplayWidth", ":", "mBaseDisplayHeight", ";", "synchronized", "(", "mDisplaySizeLock", ")", "{", "if", "(", "mAltOrientation", ")", "{", "mCurDisplayWidth", "=", "realdw", ";", "mCurDisplayHeight", "=", "realdh", ";", "if", "(", "realdw", ">", "realdh", ")", "{", "int", "maxw", "=", "(", "int", ")", "(", "realdh", "/", "1.3f", ")", ";", "if", "(", "maxw", "<", "realdw", ")", "{", "mCurDisplayWidth", "=", "maxw", ";", "}", "}", "else", "{", "int", "maxh", "=", "(", "int", ")", "(", "realdw", "/", "1.3f", ")", ";", "if", "(", "maxh", "<", "realdh", ")", "{", "mCurDisplayHeight", "=", "maxh", ";", "}", "}", "}", "else", "{", "mCurDisplayWidth", "=", "realdw", ";", "mCurDisplayHeight", "=", "realdh", ";", "}", "}", "final", "int", "dw", "=", "mCurDisplayWidth", ";", "final", "int", "dh", "=", "mCurDisplayHeight", ";", "int", "orientation", "=", "Configuration", ".", "ORIENTATION_SQUARE", ";", "if", "(", "dw", "<", "dh", ")", "{", "orientation", "=", "Configuration", ".", "ORIENTATION_PORTRAIT", ";", "setLandscapeProperty", "(", "\"0\"", ")", ";", "}", "else", "if", "(", "dw", ">", "dh", ")", "{", "orientation", "=", "Configuration", ".", "ORIENTATION_LANDSCAPE", ";", "setLandscapeProperty", "(", "\"1\"", ")", ";", "}", "config", ".", "orientation", "=", "orientation", ";", "mDisplay", ".", "getMetricsWithSize", "(", "mRealDisplayMetrics", ",", "mCurDisplayWidth", ",", "mCurDisplayHeight", ")", ";", "final", "DisplayMetrics", "dm", "=", "mDisplayMetrics", ";", "final", "int", "appWidth", "=", "mPolicy", ".", "getNonDecorDisplayWidth", "(", "dw", ",", "dh", ",", "mRotation", ")", ";", "final", "int", "appHeight", "=", "mPolicy", ".", "getNonDecorDisplayHeight", "(", "dw", ",", "dh", ",", "mRotation", ")", ";", "synchronized", "(", "mDisplaySizeLock", ")", "{", "mAppDisplayWidth", "=", "appWidth", ";", "mAppDisplayHeight", "=", "appHeight", ";", "}", "if", "(", "false", ")", "{", "Slog", ".", "i", "(", "TAG", ",", "\"\"", "+", "mAppDisplayWidth", "+", "\"", "x", "\"", "+", "mAppDisplayHeight", ")", ";", "}", "mDisplay", ".", "getMetricsWithSize", "(", "dm", ",", "mAppDisplayWidth", ",", "mAppDisplayHeight", ")", ";", "mCompatibleScreenScale", "=", "CompatibilityInfo", ".", "computeCompatibleScaling", "(", "dm", ",", "mCompatDisplayMetrics", ")", ";", "config", ".", "screenWidthDp", "=", "(", "int", ")", "(", "mPolicy", ".", "getConfigDisplayWidth", "(", "dw", ",", "dh", ",", "mRotation", ")", "/", "dm", ".", "density", ")", ";", "config", ".", "screenHeightDp", "=", "(", "int", ")", "(", "mPolicy", ".", "getConfigDisplayHeight", "(", "dw", ",", "dh", ",", "mRotation", ")", "/", "dm", ".", "density", ")", ";", "computeSmallestWidthAndScreenLayout", "(", "rotated", ",", "dw", ",", "dh", ",", "dm", ".", "density", ",", "config", ")", ";", "config", ".", "compatScreenWidthDp", "=", "(", "int", ")", "(", "config", ".", "screenWidthDp", "/", "mCompatibleScreenScale", ")", ";", "config", ".", "compatScreenHeightDp", "=", "(", "int", ")", "(", "config", ".", "screenHeightDp", "/", "mCompatibleScreenScale", ")", ";", "config", ".", "compatSmallestScreenWidthDp", "=", "computeCompatSmallestWidth", "(", "rotated", ",", "dm", ",", "dw", ",", "dh", ")", ";", "boolean", "hardKeyboardAvailable", "=", "false", ";", "if", "(", "!", "mForceDisableHardwareKeyboard", ")", "{", "hardKeyboardAvailable", "=", "config", ".", "keyboard", "!=", "Configuration", ".", "KEYBOARD_NOKEYS", ";", "}", "if", "(", "hardKeyboardAvailable", "!=", "mHardKeyboardAvailable", ")", "{", "mHardKeyboardAvailable", "=", "hardKeyboardAvailable", ";", "mHardKeyboardEnabled", "=", "hardKeyboardAvailable", ";", "mH", ".", "removeMessages", "(", "H", ".", "REPORT_HARD_KEYBOARD_STATUS_CHANGE", ")", ";", "mH", ".", "sendEmptyMessage", "(", "H", ".", "REPORT_HARD_KEYBOARD_STATUS_CHANGE", ")", ";", "}", "if", "(", "!", "mHardKeyboardEnabled", ")", "{", "config", ".", "keyboard", "=", "Configuration", ".", "KEYBOARD_NOKEYS", ";", "}", "config", ".", "keyboardHidden", "=", "Configuration", ".", "KEYBOARDHIDDEN_NO", ";", "config", ".", "hardKeyboardHidden", "=", "Configuration", ".", "HARDKEYBOARDHIDDEN_NO", ";", "config", ".", "navigationHidden", "=", "Configuration", ".", "NAVIGATIONHIDDEN_NO", ";", "mPolicy", ".", "adjustConfigurationLw", "(", "config", ")", ";", "return", "true", ";", "}", "public", "boolean", "isHardKeyboardAvailable", "(", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "return", "mHardKeyboardAvailable", ";", "}", "}", "public", "boolean", "isHardKeyboardEnabled", "(", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "return", "mHardKeyboardEnabled", ";", "}", "}", "public", "void", "setHardKeyboardEnabled", "(", "boolean", "enabled", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "mHardKeyboardEnabled", "!=", "enabled", ")", "{", "mHardKeyboardEnabled", "=", "enabled", ";", "mH", ".", "sendEmptyMessage", "(", "H", ".", "SEND_NEW_CONFIGURATION", ")", ";", "}", "}", "}", "public", "void", "setOnHardKeyboardStatusChangeListener", "(", "OnHardKeyboardStatusChangeListener", "listener", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "mHardKeyboardStatusChangeListener", "=", "listener", ";", "}", "}", "void", "notifyHardKeyboardStatusChange", "(", ")", "{", "final", "boolean", "available", ",", "enabled", ";", "final", "OnHardKeyboardStatusChangeListener", "listener", ";", "synchronized", "(", "mWindowMap", ")", "{", "listener", "=", "mHardKeyboardStatusChangeListener", ";", "available", "=", "mHardKeyboardAvailable", ";", "enabled", "=", "mHardKeyboardEnabled", ";", "}", "if", "(", "listener", "!=", "null", ")", "{", "listener", ".", "onHardKeyboardStatusChange", "(", "available", ",", "enabled", ")", ";", "}", "}", "IBinder", "prepareDragSurface", "(", "IWindow", "window", ",", "SurfaceSession", "session", ",", "int", "flags", ",", "int", "width", ",", "int", "height", ",", "Surface", "outSurface", ")", "{", "if", "(", "DEBUG_DRAG", ")", "{", "Slog", ".", "d", "(", "TAG", ",", "\"\"", "+", "width", "+", "\"", "h=\"", "+", "height", "+", "\"", "flags=\"", "+", "Integer", ".", "toHexString", "(", "flags", ")", "+", "\"", "win=\"", "+", "window", "+", "\"", "asbinder=\"", "+", "window", ".", "asBinder", "(", ")", ")", ";", "}", "final", "int", "callerPid", "=", "Binder", ".", "getCallingPid", "(", ")", ";", "final", "long", "origId", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "IBinder", "token", "=", "null", ";", "try", "{", "synchronized", "(", "mWindowMap", ")", "{", "try", "{", "if", "(", "mDragState", "==", "null", ")", "{", "Surface", "surface", "=", "new", "Surface", "(", "session", ",", "callerPid", ",", "\"drag", "surface\"", ",", "0", ",", "width", ",", "height", ",", "PixelFormat", ".", "TRANSLUCENT", ",", "Surface", ".", "HIDDEN", ")", ";", "if", "(", "SHOW_TRANSACTIONS", ")", "Slog", ".", "i", "(", "TAG", ",", "\"", "DRAG", "\"", "+", "surface", "+", "\":", "CREATE\"", ")", ";", "outSurface", ".", "copyFrom", "(", "surface", ")", ";", "final", "IBinder", "winBinder", "=", "window", ".", "asBinder", "(", ")", ";", "token", "=", "new", "Binder", "(", ")", ";", "mDragState", "=", "new", "DragState", "(", "this", ",", "token", ",", "surface", ",", "0", ",", "winBinder", ")", ";", "mDragState", ".", "mSurface", "=", "surface", ";", "token", "=", "mDragState", ".", "mToken", "=", "new", "Binder", "(", ")", ";", "mH", ".", "removeMessages", "(", "H", ".", "DRAG_START_TIMEOUT", ",", "winBinder", ")", ";", "Message", "msg", "=", "mH", ".", "obtainMessage", "(", "H", ".", "DRAG_START_TIMEOUT", ",", "winBinder", ")", ";", "mH", ".", "sendMessageDelayed", "(", "msg", ",", "5000", ")", ";", "}", "else", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "}", "}", "catch", "(", "Surface", ".", "OutOfResourcesException", "e", ")", "{", "Slog", ".", "e", "(", "TAG", ",", "\"\"", "+", "width", "+", "\"", "h=\"", "+", "height", ",", "e", ")", ";", "if", "(", "mDragState", "!=", "null", ")", "{", "mDragState", ".", "reset", "(", ")", ";", "mDragState", "=", "null", ";", "}", "}", "}", "}", "finally", "{", "Binder", ".", "restoreCallingIdentity", "(", "origId", ")", ";", "}", "return", "token", ";", "}", "final", "InputMonitor", "mInputMonitor", "=", "new", "InputMonitor", "(", "this", ")", ";", "public", "void", "pauseKeyDispatching", "(", "IBinder", "_token", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "MANAGE_APP_TOKENS", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "synchronized", "(", "mWindowMap", ")", "{", "WindowToken", "token", "=", "mTokenMap", ".", "get", "(", "_token", ")", ";", "if", "(", "token", "!=", "null", ")", "{", "mInputMonitor", ".", "pauseDispatchingLw", "(", "token", ")", ";", "}", "}", "}", "public", "void", "resumeKeyDispatching", "(", "IBinder", "_token", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "MANAGE_APP_TOKENS", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "synchronized", "(", "mWindowMap", ")", "{", "WindowToken", "token", "=", "mTokenMap", ".", "get", "(", "_token", ")", ";", "if", "(", "token", "!=", "null", ")", "{", "mInputMonitor", ".", "resumeDispatchingLw", "(", "token", ")", ";", "}", "}", "}", "public", "void", "setEventDispatching", "(", "boolean", "enabled", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "MANAGE_APP_TOKENS", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "synchronized", "(", "mWindowMap", ")", "{", "mInputMonitor", ".", "setEventDispatchingLw", "(", "enabled", ")", ";", "}", "}", "public", "boolean", "injectKeyEvent", "(", "KeyEvent", "ev", ",", "boolean", "sync", ")", "{", "long", "downTime", "=", "ev", ".", "getDownTime", "(", ")", ";", "long", "eventTime", "=", "ev", ".", "getEventTime", "(", ")", ";", "int", "action", "=", "ev", ".", "getAction", "(", ")", ";", "int", "code", "=", "ev", ".", "getKeyCode", "(", ")", ";", "int", "repeatCount", "=", "ev", ".", "getRepeatCount", "(", ")", ";", "int", "metaState", "=", "ev", ".", "getMetaState", "(", ")", ";", "int", "deviceId", "=", "ev", ".", "getDeviceId", "(", ")", ";", "int", "scancode", "=", "ev", ".", "getScanCode", "(", ")", ";", "int", "source", "=", "ev", ".", "getSource", "(", ")", ";", "int", "flags", "=", "ev", ".", "getFlags", "(", ")", ";", "if", "(", "source", "==", "InputDevice", ".", "SOURCE_UNKNOWN", ")", "{", "source", "=", "InputDevice", ".", "SOURCE_KEYBOARD", ";", "}", "if", "(", "eventTime", "==", "0", ")", "eventTime", "=", "SystemClock", ".", "uptimeMillis", "(", ")", ";", "if", "(", "downTime", "==", "0", ")", "downTime", "=", "eventTime", ";", "KeyEvent", "newEvent", "=", "new", "KeyEvent", "(", "downTime", ",", "eventTime", ",", "action", ",", "code", ",", "repeatCount", ",", "metaState", ",", "deviceId", ",", "scancode", ",", "flags", "|", "KeyEvent", ".", "FLAG_FROM_SYSTEM", ",", "source", ")", ";", "final", "int", "pid", "=", "Binder", ".", "getCallingPid", "(", ")", ";", "final", "int", "uid", "=", "Binder", ".", "getCallingUid", "(", ")", ";", "final", "long", "ident", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "final", "int", "result", "=", "mInputManager", ".", "injectInputEvent", "(", "newEvent", ",", "pid", ",", "uid", ",", "sync", "?", "InputManager", ".", "INPUT_EVENT_INJECTION_SYNC_WAIT_FOR_FINISH", ":", "InputManager", ".", "INPUT_EVENT_INJECTION_SYNC_WAIT_FOR_RESULT", ",", "INJECTION_TIMEOUT_MILLIS", ")", ";", "Binder", ".", "restoreCallingIdentity", "(", "ident", ")", ";", "return", "reportInjectionResult", "(", "result", ")", ";", "}", "public", "boolean", "injectPointerEvent", "(", "MotionEvent", "ev", ",", "boolean", "sync", ")", "{", "final", "int", "pid", "=", "Binder", ".", "getCallingPid", "(", ")", ";", "final", "int", "uid", "=", "Binder", ".", "getCallingUid", "(", ")", ";", "final", "long", "ident", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "MotionEvent", "newEvent", "=", "MotionEvent", ".", "obtain", "(", "ev", ")", ";", "if", "(", "(", "newEvent", ".", "getSource", "(", ")", "&", "InputDevice", ".", "SOURCE_CLASS_POINTER", ")", "==", "0", ")", "{", "newEvent", ".", "setSource", "(", "InputDevice", ".", "SOURCE_TOUCHSCREEN", ")", ";", "}", "final", "int", "result", "=", "mInputManager", ".", "injectInputEvent", "(", "newEvent", ",", "pid", ",", "uid", ",", "sync", "?", "InputManager", ".", "INPUT_EVENT_INJECTION_SYNC_WAIT_FOR_FINISH", ":", "InputManager", ".", "INPUT_EVENT_INJECTION_SYNC_WAIT_FOR_RESULT", ",", "INJECTION_TIMEOUT_MILLIS", ")", ";", "Binder", ".", "restoreCallingIdentity", "(", "ident", ")", ";", "return", "reportInjectionResult", "(", "result", ")", ";", "}", "public", "boolean", "injectTrackballEvent", "(", "MotionEvent", "ev", ",", "boolean", "sync", ")", "{", "final", "int", "pid", "=", "Binder", ".", "getCallingPid", "(", ")", ";", "final", "int", "uid", "=", "Binder", ".", "getCallingUid", "(", ")", ";", "final", "long", "ident", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "MotionEvent", "newEvent", "=", "MotionEvent", ".", "obtain", "(", "ev", ")", ";", "if", "(", "(", "newEvent", ".", "getSource", "(", ")", "&", "InputDevice", ".", "SOURCE_CLASS_TRACKBALL", ")", "==", "0", ")", "{", "newEvent", ".", "setSource", "(", "InputDevice", ".", "SOURCE_TRACKBALL", ")", ";", "}", "final", "int", "result", "=", "mInputManager", ".", "injectInputEvent", "(", "newEvent", ",", "pid", ",", "uid", ",", "sync", "?", "InputManager", ".", "INPUT_EVENT_INJECTION_SYNC_WAIT_FOR_FINISH", ":", "InputManager", ".", "INPUT_EVENT_INJECTION_SYNC_WAIT_FOR_RESULT", ",", "INJECTION_TIMEOUT_MILLIS", ")", ";", "Binder", ".", "restoreCallingIdentity", "(", "ident", ")", ";", "return", "reportInjectionResult", "(", "result", ")", ";", "}", "public", "boolean", "injectInputEventNoWait", "(", "InputEvent", "ev", ")", "{", "final", "int", "pid", "=", "Binder", ".", "getCallingPid", "(", ")", ";", "final", "int", "uid", "=", "Binder", ".", "getCallingUid", "(", ")", ";", "final", "long", "ident", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "final", "int", "result", "=", "mInputManager", ".", "injectInputEvent", "(", "ev", ",", "pid", ",", "uid", ",", "InputManager", ".", "INPUT_EVENT_INJECTION_SYNC_NONE", ",", "INJECTION_TIMEOUT_MILLIS", ")", ";", "Binder", ".", "restoreCallingIdentity", "(", "ident", ")", ";", "return", "reportInjectionResult", "(", "result", ")", ";", "}", "private", "boolean", "reportInjectionResult", "(", "int", "result", ")", "{", "switch", "(", "result", ")", "{", "case", "InputManager", ".", "INPUT_EVENT_INJECTION_PERMISSION_DENIED", ":", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "case", "InputManager", ".", "INPUT_EVENT_INJECTION_SUCCEEDED", ":", "return", "true", ";", "case", "InputManager", ".", "INPUT_EVENT_INJECTION_TIMED_OUT", ":", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "return", "false", ";", "case", "InputManager", ".", "INPUT_EVENT_INJECTION_FAILED", ":", "default", ":", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "return", "false", ";", "}", "}", "public", "void", "setPointerSpeed", "(", "int", "speed", ")", "{", "if", "(", "!", "checkCallingPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "SET_POINTER_SPEED", ",", "\"\"", ")", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", ")", ";", "}", "mInputManager", ".", "setPointerSpeed", "(", "speed", ")", ";", "}", "private", "WindowState", "getFocusedWindow", "(", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "return", "getFocusedWindowLocked", "(", ")", ";", "}", "}", "private", "WindowState", "getFocusedWindowLocked", "(", ")", "{", "return", "mCurrentFocus", ";", "}", "public", "boolean", "detectSafeMode", "(", ")", "{", "if", "(", "!", "mInputMonitor", ".", "waitForInputDevicesReady", "(", "INPUT_DEVICES_READY_FOR_SAFE_MODE_DETECTION_TIMEOUT_MILLIS", ")", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "INPUT_DEVICES_READY_FOR_SAFE_MODE_DETECTION_TIMEOUT_MILLIS", "+", "\"\"", ")", ";", "}", "mSafeMode", "=", "mPolicy", ".", "detectSafeMode", "(", ")", ";", "return", "mSafeMode", ";", "}", "public", "void", "displayReady", "(", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "mDisplay", "!=", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"\"", ")", ";", "}", "WindowManager", "wm", "=", "(", "WindowManager", ")", "mContext", ".", "getSystemService", "(", "Context", ".", "WINDOW_SERVICE", ")", ";", "mDisplay", "=", "wm", ".", "getDefaultDisplay", "(", ")", ";", "synchronized", "(", "mDisplaySizeLock", ")", "{", "mInitialDisplayWidth", "=", "mDisplay", ".", "getRawWidth", "(", ")", ";", "mInitialDisplayHeight", "=", "mDisplay", ".", "getRawHeight", "(", ")", ";", "int", "rot", "=", "mDisplay", ".", "getRotation", "(", ")", ";", "if", "(", "rot", "==", "Surface", ".", "ROTATION_90", "||", "rot", "==", "Surface", ".", "ROTATION_270", ")", "{", "int", "tmp", "=", "mInitialDisplayWidth", ";", "mInitialDisplayWidth", "=", "mInitialDisplayHeight", ";", "mInitialDisplayHeight", "=", "tmp", ";", "}", "mBaseDisplayWidth", "=", "mCurDisplayWidth", "=", "mAppDisplayWidth", "=", "mInitialDisplayWidth", ";", "mBaseDisplayHeight", "=", "mCurDisplayHeight", "=", "mAppDisplayHeight", "=", "mInitialDisplayHeight", ";", "}", "mInputManager", ".", "setDisplaySize", "(", "Display", ".", "DEFAULT_DISPLAY", ",", "mDisplay", ".", "getRawWidth", "(", ")", ",", "mDisplay", ".", "getRawHeight", "(", ")", ",", "mDisplay", ".", "getRawExternalWidth", "(", ")", ",", "mDisplay", ".", "getRawExternalHeight", "(", ")", ")", ";", "mPolicy", ".", "setInitialDisplaySize", "(", "mInitialDisplayWidth", ",", "mInitialDisplayHeight", ")", ";", "}", "try", "{", "mActivityManager", ".", "updateConfiguration", "(", "null", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "synchronized", "(", "mWindowMap", ")", "{", "readForcedDisplaySizeLocked", "(", ")", ";", "}", "}", "public", "void", "systemReady", "(", ")", "{", "mPolicy", ".", "systemReady", "(", ")", ";", "}", "static", "final", "class", "DummyAnimation", "extends", "Animation", "{", "public", "boolean", "getTransformation", "(", "long", "currentTime", ",", "Transformation", "outTransformation", ")", "{", "return", "false", ";", "}", "}", "static", "final", "Animation", "sDummyAnimation", "=", "new", "DummyAnimation", "(", ")", ";", "final", "class", "H", "extends", "Handler", "{", "public", "static", "final", "int", "REPORT_FOCUS_CHANGE", "=", "2", ";", "public", "static", "final", "int", "REPORT_LOSING_FOCUS", "=", "3", ";", "public", "static", "final", "int", "ANIMATE", "=", "4", ";", "public", "static", "final", "int", "ADD_STARTING", "=", "5", ";", "public", "static", "final", "int", "REMOVE_STARTING", "=", "6", ";", "public", "static", "final", "int", "FINISHED_STARTING", "=", "7", ";", "public", "static", "final", "int", "REPORT_APPLICATION_TOKEN_WINDOWS", "=", "8", ";", "public", "static", "final", "int", "REPORT_APPLICATION_TOKEN_DRAWN", "=", "9", ";", "public", "static", "final", "int", "WINDOW_FREEZE_TIMEOUT", "=", "11", ";", "public", "static", "final", "int", "HOLD_SCREEN_CHANGED", "=", "12", ";", "public", "static", "final", "int", "APP_TRANSITION_TIMEOUT", "=", "13", ";", "public", "static", "final", "int", "PERSIST_ANIMATION_SCALE", "=", "14", ";", "public", "static", "final", "int", "FORCE_GC", "=", "15", ";", "public", "static", "final", "int", "ENABLE_SCREEN", "=", "16", ";", "public", "static", "final", "int", "APP_FREEZE_TIMEOUT", "=", "17", ";", "public", "static", "final", "int", "SEND_NEW_CONFIGURATION", "=", "18", ";", "public", "static", "final", "int", "REPORT_WINDOWS_CHANGE", "=", "19", ";", "public", "static", "final", "int", "DRAG_START_TIMEOUT", "=", "20", ";", "public", "static", "final", "int", "DRAG_END_TIMEOUT", "=", "21", ";", "public", "static", "final", "int", "REPORT_HARD_KEYBOARD_STATUS_CHANGE", "=", "22", ";", "public", "static", "final", "int", "BOOT_TIMEOUT", "=", "23", ";", "public", "static", "final", "int", "WAITING_FOR_DRAWN_TIMEOUT", "=", "24", ";", "private", "Session", "mLastReportedHold", ";", "public", "H", "(", ")", "{", "}", "@", "Override", "public", "void", "handleMessage", "(", "Message", "msg", ")", "{", "switch", "(", "msg", ".", "what", ")", "{", "case", "REPORT_FOCUS_CHANGE", ":", "{", "WindowState", "lastFocus", ";", "WindowState", "newFocus", ";", "synchronized", "(", "mWindowMap", ")", "{", "lastFocus", "=", "mLastFocus", ";", "newFocus", "=", "mCurrentFocus", ";", "if", "(", "lastFocus", "==", "newFocus", ")", "{", "return", ";", "}", "mLastFocus", "=", "newFocus", ";", "if", "(", "newFocus", "!=", "null", "&&", "lastFocus", "!=", "null", "&&", "!", "newFocus", ".", "isDisplayedLw", "(", ")", ")", "{", "mLosingFocus", ".", "add", "(", "lastFocus", ")", ";", "lastFocus", "=", "null", ";", "}", "}", "if", "(", "lastFocus", "!=", "newFocus", ")", "{", "if", "(", "newFocus", "!=", "null", ")", "{", "try", "{", "newFocus", ".", "mClient", ".", "windowFocusChanged", "(", "true", ",", "mInTouchMode", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "notifyFocusChanged", "(", ")", ";", "}", "if", "(", "lastFocus", "!=", "null", ")", "{", "try", "{", "lastFocus", ".", "mClient", ".", "windowFocusChanged", "(", "false", ",", "mInTouchMode", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "}", "}", "break", ";", "case", "REPORT_LOSING_FOCUS", ":", "{", "ArrayList", "<", "WindowState", ">", "losers", ";", "synchronized", "(", "mWindowMap", ")", "{", "losers", "=", "mLosingFocus", ";", "mLosingFocus", "=", "new", "ArrayList", "<", "WindowState", ">", "(", ")", ";", "}", "final", "int", "N", "=", "losers", ".", "size", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "try", "{", "losers", ".", "get", "(", "i", ")", ".", "mClient", ".", "windowFocusChanged", "(", "false", ",", "mInTouchMode", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "}", "break", ";", "case", "ANIMATE", ":", "{", "synchronized", "(", "mWindowMap", ")", "{", "mAnimationPending", "=", "false", ";", "performLayoutAndPlaceSurfacesLocked", "(", ")", ";", "}", "}", "break", ";", "case", "ADD_STARTING", ":", "{", "final", "AppWindowToken", "wtoken", "=", "(", "AppWindowToken", ")", "msg", ".", "obj", ";", "final", "StartingData", "sd", "=", "wtoken", ".", "startingData", ";", "if", "(", "sd", "==", "null", ")", "{", "return", ";", "}", "if", "(", "DEBUG_STARTING_WINDOW", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", "+", "\":", "pkg=\"", "+", "sd", ".", "pkg", ")", ";", "View", "view", "=", "null", ";", "try", "{", "view", "=", "mPolicy", ".", "addStartingWindow", "(", "wtoken", ".", "token", ",", "sd", ".", "pkg", ",", "sd", ".", "theme", ",", "sd", ".", "compatInfo", ",", "sd", ".", "nonLocalizedLabel", ",", "sd", ".", "labelRes", ",", "sd", ".", "icon", ",", "sd", ".", "windowFlags", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ",", "e", ")", ";", "}", "if", "(", "view", "!=", "null", ")", "{", "boolean", "abort", "=", "false", ";", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "wtoken", ".", "removed", "||", "wtoken", ".", "startingData", "==", "null", ")", "{", "if", "(", "wtoken", ".", "startingWindow", "!=", "null", ")", "{", "if", "(", "DEBUG_STARTING_WINDOW", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", "+", "\":", "removed=\"", "+", "wtoken", ".", "removed", "+", "\"\"", "+", "wtoken", ".", "startingData", ")", ";", "wtoken", ".", "startingWindow", "=", "null", ";", "wtoken", ".", "startingData", "=", "null", ";", "abort", "=", "true", ";", "}", "}", "else", "{", "wtoken", ".", "startingView", "=", "view", ";", "}", "if", "(", "DEBUG_STARTING_WINDOW", "&&", "!", "abort", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", "+", "\"\"", "+", "wtoken", ".", "startingWindow", "+", "\"\"", "+", "wtoken", ".", "startingView", ")", ";", "}", "if", "(", "abort", ")", "{", "try", "{", "mPolicy", ".", "removeStartingWindow", "(", "wtoken", ".", "token", ",", "view", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ",", "e", ")", ";", "}", "}", "}", "}", "break", ";", "case", "REMOVE_STARTING", ":", "{", "final", "AppWindowToken", "wtoken", "=", "(", "AppWindowToken", ")", "msg", ".", "obj", ";", "IBinder", "token", "=", "null", ";", "View", "view", "=", "null", ";", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "DEBUG_STARTING_WINDOW", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", "+", "\"\"", "+", "wtoken", ".", "startingWindow", "+", "\"\"", "+", "wtoken", ".", "startingView", ")", ";", "if", "(", "wtoken", ".", "startingWindow", "!=", "null", ")", "{", "view", "=", "wtoken", ".", "startingView", ";", "token", "=", "wtoken", ".", "token", ";", "wtoken", ".", "startingData", "=", "null", ";", "wtoken", ".", "startingView", "=", "null", ";", "wtoken", ".", "startingWindow", "=", "null", ";", "}", "}", "if", "(", "view", "!=", "null", ")", "{", "try", "{", "mPolicy", ".", "removeStartingWindow", "(", "token", ",", "view", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ",", "e", ")", ";", "}", "}", "}", "break", ";", "case", "FINISHED_STARTING", ":", "{", "IBinder", "token", "=", "null", ";", "View", "view", "=", "null", ";", "while", "(", "true", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "final", "int", "N", "=", "mFinishedStarting", ".", "size", "(", ")", ";", "if", "(", "N", "<=", "0", ")", "{", "break", ";", "}", "AppWindowToken", "wtoken", "=", "mFinishedStarting", ".", "remove", "(", "N", "-", "1", ")", ";", "if", "(", "DEBUG_STARTING_WINDOW", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", "+", "\"\"", "+", "wtoken", ".", "startingWindow", "+", "\"\"", "+", "wtoken", ".", "startingView", ")", ";", "if", "(", "wtoken", ".", "startingWindow", "==", "null", ")", "{", "continue", ";", "}", "view", "=", "wtoken", ".", "startingView", ";", "token", "=", "wtoken", ".", "token", ";", "wtoken", ".", "startingData", "=", "null", ";", "wtoken", ".", "startingView", "=", "null", ";", "wtoken", ".", "startingWindow", "=", "null", ";", "}", "try", "{", "mPolicy", ".", "removeStartingWindow", "(", "token", ",", "view", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ",", "e", ")", ";", "}", "}", "}", "break", ";", "case", "REPORT_APPLICATION_TOKEN_DRAWN", ":", "{", "final", "AppWindowToken", "wtoken", "=", "(", "AppWindowToken", ")", "msg", ".", "obj", ";", "try", "{", "if", "(", "DEBUG_VISIBILITY", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", ")", ";", "wtoken", ".", "appToken", ".", "windowsDrawn", "(", ")", ";", "}", "catch", "(", "RemoteException", "ex", ")", "{", "}", "}", "break", ";", "case", "REPORT_APPLICATION_TOKEN_WINDOWS", ":", "{", "final", "AppWindowToken", "wtoken", "=", "(", "AppWindowToken", ")", "msg", ".", "obj", ";", "boolean", "nowVisible", "=", "msg", ".", "arg1", "!=", "0", ";", "boolean", "nowGone", "=", "msg", ".", "arg2", "!=", "0", ";", "try", "{", "if", "(", "DEBUG_VISIBILITY", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", "+", "\"", "visible=\"", "+", "nowVisible", "+", "\"", "gone=\"", "+", "nowGone", ")", ";", "if", "(", "nowVisible", ")", "{", "wtoken", ".", "appToken", ".", "windowsVisible", "(", ")", ";", "}", "else", "{", "wtoken", ".", "appToken", ".", "windowsGone", "(", ")", ";", "}", "}", "catch", "(", "RemoteException", "ex", ")", "{", "}", "}", "break", ";", "case", "WINDOW_FREEZE_TIMEOUT", ":", "{", "synchronized", "(", "mWindowMap", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "int", "i", "=", "mWindows", ".", "size", "(", ")", ";", "while", "(", "i", ">", "0", ")", "{", "i", "--", ";", "WindowState", "w", "=", "mWindows", ".", "get", "(", "i", ")", ";", "if", "(", "w", ".", "mOrientationChanging", ")", "{", "w", ".", "mOrientationChanging", "=", "false", ";", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "w", ")", ";", "}", "}", "performLayoutAndPlaceSurfacesLocked", "(", ")", ";", "}", "break", ";", "}", "case", "HOLD_SCREEN_CHANGED", ":", "{", "Session", "oldHold", ";", "Session", "newHold", ";", "synchronized", "(", "mWindowMap", ")", "{", "oldHold", "=", "mLastReportedHold", ";", "newHold", "=", "(", "Session", ")", "msg", ".", "obj", ";", "mLastReportedHold", "=", "newHold", ";", "}", "if", "(", "oldHold", "!=", "newHold", ")", "{", "try", "{", "if", "(", "oldHold", "!=", "null", ")", "{", "mBatteryStats", ".", "noteStopWakelock", "(", "oldHold", ".", "mUid", ",", "-", "1", ",", "\"window\"", ",", "BatteryStats", ".", "WAKE_TYPE_WINDOW", ")", ";", "}", "if", "(", "newHold", "!=", "null", ")", "{", "mBatteryStats", ".", "noteStartWakelock", "(", "newHold", ".", "mUid", ",", "-", "1", ",", "\"window\"", ",", "BatteryStats", ".", "WAKE_TYPE_WINDOW", ")", ";", "}", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "break", ";", "}", "case", "APP_TRANSITION_TIMEOUT", ":", "{", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "mNextAppTransition", "!=", "WindowManagerPolicy", ".", "TRANSIT_UNSET", ")", "{", "if", "(", "DEBUG_APP_TRANSITIONS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "mAppTransitionReady", "=", "true", ";", "mAppTransitionTimeout", "=", "true", ";", "performLayoutAndPlaceSurfacesLocked", "(", ")", ";", "}", "}", "break", ";", "}", "case", "PERSIST_ANIMATION_SCALE", ":", "{", "Settings", ".", "System", ".", "putFloat", "(", "mContext", ".", "getContentResolver", "(", ")", ",", "Settings", ".", "System", ".", "WINDOW_ANIMATION_SCALE", ",", "mWindowAnimationScale", ")", ";", "Settings", ".", "System", ".", "putFloat", "(", "mContext", ".", "getContentResolver", "(", ")", ",", "Settings", ".", "System", ".", "TRANSITION_ANIMATION_SCALE", ",", "mTransitionAnimationScale", ")", ";", "break", ";", "}", "case", "FORCE_GC", ":", "{", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "mAnimationPending", ")", "{", "mH", ".", "sendMessageDelayed", "(", "mH", ".", "obtainMessage", "(", "H", ".", "FORCE_GC", ")", ",", "2000", ")", ";", "return", ";", "}", "if", "(", "mDisplayFrozen", ")", "{", "return", ";", "}", "}", "Runtime", ".", "getRuntime", "(", ")", ".", "gc", "(", ")", ";", "break", ";", "}", "case", "ENABLE_SCREEN", ":", "{", "performEnableScreen", "(", ")", ";", "break", ";", "}", "case", "APP_FREEZE_TIMEOUT", ":", "{", "synchronized", "(", "mWindowMap", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "int", "i", "=", "mAppTokens", ".", "size", "(", ")", ";", "while", "(", "i", ">", "0", ")", "{", "i", "--", ";", "AppWindowToken", "tok", "=", "mAppTokens", ".", "get", "(", "i", ")", ";", "if", "(", "tok", ".", "freezingScreen", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "tok", ")", ";", "unsetAppFreezingScreenLocked", "(", "tok", ",", "true", ",", "true", ")", ";", "}", "}", "}", "break", ";", "}", "case", "SEND_NEW_CONFIGURATION", ":", "{", "removeMessages", "(", "SEND_NEW_CONFIGURATION", ")", ";", "sendNewConfiguration", "(", ")", ";", "break", ";", "}", "case", "REPORT_WINDOWS_CHANGE", ":", "{", "if", "(", "mWindowsChanged", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "mWindowsChanged", "=", "false", ";", "}", "notifyWindowsChanged", "(", ")", ";", "}", "break", ";", "}", "case", "DRAG_START_TIMEOUT", ":", "{", "IBinder", "win", "=", "(", "IBinder", ")", "msg", ".", "obj", ";", "if", "(", "DEBUG_DRAG", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "win", ")", ";", "}", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "mDragState", "!=", "null", ")", "{", "mDragState", ".", "unregister", "(", ")", ";", "mInputMonitor", ".", "updateInputWindowsLw", "(", "true", ")", ";", "mDragState", ".", "reset", "(", ")", ";", "mDragState", "=", "null", ";", "}", "}", "break", ";", "}", "case", "DRAG_END_TIMEOUT", ":", "{", "IBinder", "win", "=", "(", "IBinder", ")", "msg", ".", "obj", ";", "if", "(", "DEBUG_DRAG", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "win", ")", ";", "}", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "mDragState", "!=", "null", ")", "{", "mDragState", ".", "mDragResult", "=", "false", ";", "mDragState", ".", "endDragLw", "(", ")", ";", "}", "}", "break", ";", "}", "case", "REPORT_HARD_KEYBOARD_STATUS_CHANGE", ":", "{", "notifyHardKeyboardStatusChange", "(", ")", ";", "break", ";", "}", "case", "BOOT_TIMEOUT", ":", "{", "performBootTimeout", "(", ")", ";", "break", ";", "}", "case", "WAITING_FOR_DRAWN_TIMEOUT", ":", "{", "Pair", "<", "WindowState", ",", "IRemoteCallback", ">", "pair", ";", "synchronized", "(", "mWindowMap", ")", "{", "pair", "=", "(", "Pair", "<", "WindowState", ",", "IRemoteCallback", ">", ")", "msg", ".", "obj", ";", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "pair", ".", "first", ")", ";", "if", "(", "!", "mWaitingForDrawn", ".", "remove", "(", "pair", ")", ")", "{", "return", ";", "}", "}", "try", "{", "pair", ".", "second", ".", "sendResult", "(", "null", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "break", ";", "}", "}", "}", "}", "public", "IWindowSession", "openSession", "(", "IInputMethodClient", "client", ",", "IInputContext", "inputContext", ")", "{", "if", "(", "client", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"null", "client\"", ")", ";", "if", "(", "inputContext", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "Session", "session", "=", "new", "Session", "(", "this", ",", "client", ",", "inputContext", ")", ";", "return", "session", ";", "}", "public", "boolean", "inputMethodClientHasFocus", "(", "IInputMethodClient", "client", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "int", "idx", "=", "findDesiredInputMethodWindowIndexLocked", "(", "false", ")", ";", "WindowState", "imFocus", ";", "if", "(", "idx", ">", "0", ")", "{", "imFocus", "=", "mWindows", ".", "get", "(", "idx", "-", "1", ")", ";", "if", "(", "imFocus", "!=", "null", ")", "{", "if", "(", "imFocus", ".", "mAttrs", ".", "type", "==", "LayoutParams", ".", "TYPE_APPLICATION_STARTING", "&&", "imFocus", ".", "mAppToken", "!=", "null", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "imFocus", ".", "mAppToken", ".", "windows", ".", "size", "(", ")", ";", "i", "++", ")", "{", "WindowState", "w", "=", "imFocus", ".", "mAppToken", ".", "windows", ".", "get", "(", "i", ")", ";", "if", "(", "w", "!=", "imFocus", ")", "{", "imFocus", "=", "w", ";", "break", ";", "}", "}", "}", "if", "(", "imFocus", ".", "mSession", ".", "mClient", "!=", "null", "&&", "imFocus", ".", "mSession", ".", "mClient", ".", "asBinder", "(", ")", "==", "client", ".", "asBinder", "(", ")", ")", "{", "return", "true", ";", "}", "if", "(", "mCurrentFocus", "!=", "null", "&&", "mCurrentFocus", ".", "mSession", ".", "mClient", "!=", "null", "&&", "mCurrentFocus", ".", "mSession", ".", "mClient", ".", "asBinder", "(", ")", "==", "client", ".", "asBinder", "(", ")", ")", "{", "return", "true", ";", "}", "}", "}", "}", "return", "false", ";", "}", "public", "void", "getDisplaySize", "(", "Point", "size", ")", "{", "synchronized", "(", "mDisplaySizeLock", ")", "{", "size", ".", "x", "=", "mAppDisplayWidth", ";", "size", ".", "y", "=", "mAppDisplayHeight", ";", "}", "}", "public", "void", "getRealDisplaySize", "(", "Point", "size", ")", "{", "synchronized", "(", "mDisplaySizeLock", ")", "{", "size", ".", "x", "=", "mCurDisplayWidth", ";", "size", ".", "y", "=", "mCurDisplayHeight", ";", "}", "}", "public", "void", "getInitialDisplaySize", "(", "Point", "size", ")", "{", "synchronized", "(", "mDisplaySizeLock", ")", "{", "size", ".", "x", "=", "mInitialDisplayWidth", ";", "size", ".", "y", "=", "mInitialDisplayHeight", ";", "}", "}", "public", "int", "getMaximumSizeDimension", "(", ")", "{", "synchronized", "(", "mDisplaySizeLock", ")", "{", "return", "mBaseDisplayWidth", ">", "mBaseDisplayHeight", "?", "mBaseDisplayWidth", ":", "mBaseDisplayHeight", ";", "}", "}", "public", "void", "setForcedDisplaySize", "(", "int", "longDimen", ",", "int", "shortDimen", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "int", "width", ",", "height", ";", "if", "(", "mInitialDisplayWidth", "<", "mInitialDisplayHeight", ")", "{", "width", "=", "shortDimen", "<", "mInitialDisplayWidth", "?", "shortDimen", ":", "mInitialDisplayWidth", ";", "height", "=", "longDimen", "<", "mInitialDisplayHeight", "?", "longDimen", ":", "mInitialDisplayHeight", ";", "}", "else", "{", "width", "=", "longDimen", "<", "mInitialDisplayWidth", "?", "longDimen", ":", "mInitialDisplayWidth", ";", "height", "=", "shortDimen", "<", "mInitialDisplayHeight", "?", "shortDimen", ":", "mInitialDisplayHeight", ";", "}", "setForcedDisplaySizeLocked", "(", "width", ",", "height", ")", ";", "Settings", ".", "Secure", ".", "putString", "(", "mContext", ".", "getContentResolver", "(", ")", ",", "Settings", ".", "Secure", ".", "DISPLAY_SIZE_FORCED", ",", "width", "+", "\",\"", "+", "height", ")", ";", "}", "}", "private", "void", "rebuildBlackFrame", "(", "boolean", "inTransaction", ")", "{", "if", "(", "!", "inTransaction", ")", "{", "if", "(", "SHOW_LIGHT_TRANSACTIONS", ")", "Slog", ".", "i", "(", "TAG", ",", "\"\"", ")", ";", "Surface", ".", "openTransaction", "(", ")", ";", "}", "try", "{", "if", "(", "mBlackFrame", "!=", "null", ")", "{", "mBlackFrame", ".", "kill", "(", ")", ";", "mBlackFrame", "=", "null", ";", "}", "if", "(", "mBaseDisplayWidth", "<", "mInitialDisplayWidth", "||", "mBaseDisplayHeight", "<", "mInitialDisplayHeight", ")", "{", "int", "initW", ",", "initH", ",", "baseW", ",", "baseH", ";", "final", "boolean", "rotated", "=", "(", "mRotation", "==", "Surface", ".", "ROTATION_90", "||", "mRotation", "==", "Surface", ".", "ROTATION_270", ")", ";", "if", "(", "rotated", ")", "{", "initW", "=", "mInitialDisplayHeight", ";", "initH", "=", "mInitialDisplayWidth", ";", "baseW", "=", "mBaseDisplayHeight", ";", "baseH", "=", "mBaseDisplayWidth", ";", "}", "else", "{", "initW", "=", "mInitialDisplayWidth", ";", "initH", "=", "mInitialDisplayHeight", ";", "baseW", "=", "mBaseDisplayWidth", ";", "baseH", "=", "mBaseDisplayHeight", ";", "}", "Rect", "outer", "=", "new", "Rect", "(", "0", ",", "0", ",", "initW", ",", "initH", ")", ";", "Rect", "inner", "=", "new", "Rect", "(", "0", ",", "0", ",", "baseW", ",", "baseH", ")", ";", "try", "{", "mBlackFrame", "=", "new", "BlackFrame", "(", "mFxSession", ",", "outer", ",", "inner", ",", "MASK_LAYER", ")", ";", "}", "catch", "(", "Surface", ".", "OutOfResourcesException", "e", ")", "{", "}", "}", "}", "finally", "{", "if", "(", "!", "inTransaction", ")", "{", "Surface", ".", "closeTransaction", "(", ")", ";", "if", "(", "SHOW_LIGHT_TRANSACTIONS", ")", "Slog", ".", "i", "(", "TAG", ",", "\"\"", ")", ";", "}", "}", "}", "private", "void", "readForcedDisplaySizeLocked", "(", ")", "{", "final", "String", "str", "=", "Settings", ".", "Secure", ".", "getString", "(", "mContext", ".", "getContentResolver", "(", ")", ",", "Settings", ".", "Secure", ".", "DISPLAY_SIZE_FORCED", ")", ";", "if", "(", "str", "==", "null", "||", "str", ".", "length", "(", ")", "==", "0", ")", "{", "return", ";", "}", "final", "int", "pos", "=", "str", ".", "indexOf", "(", "','", ")", ";", "if", "(", "pos", "<=", "0", "||", "str", ".", "lastIndexOf", "(", "','", ")", "!=", "pos", ")", "{", "return", ";", "}", "int", "width", ",", "height", ";", "try", "{", "width", "=", "Integer", ".", "parseInt", "(", "str", ".", "substring", "(", "0", ",", "pos", ")", ")", ";", "height", "=", "Integer", ".", "parseInt", "(", "str", ".", "substring", "(", "pos", "+", "1", ")", ")", ";", "}", "catch", "(", "NumberFormatException", "ex", ")", "{", "return", ";", "}", "setForcedDisplaySizeLocked", "(", "width", ",", "height", ")", ";", "}", "private", "void", "setForcedDisplaySizeLocked", "(", "int", "width", ",", "int", "height", ")", "{", "Slog", ".", "i", "(", "TAG", ",", "\"\"", "+", "width", "+", "\"x\"", "+", "height", ")", ";", "synchronized", "(", "mDisplaySizeLock", ")", "{", "mBaseDisplayWidth", "=", "width", ";", "mBaseDisplayHeight", "=", "height", ";", "}", "mPolicy", ".", "setInitialDisplaySize", "(", "mBaseDisplayWidth", ",", "mBaseDisplayHeight", ")", ";", "mLayoutNeeded", "=", "true", ";", "boolean", "configChanged", "=", "updateOrientationFromAppTokensLocked", "(", "false", ")", ";", "mTempConfiguration", ".", "setToDefaults", "(", ")", ";", "mTempConfiguration", ".", "fontScale", "=", "mCurConfiguration", ".", "fontScale", ";", "if", "(", "computeNewConfigurationLocked", "(", "mTempConfiguration", ")", ")", "{", "if", "(", "mCurConfiguration", ".", "diff", "(", "mTempConfiguration", ")", "!=", "0", ")", "{", "configChanged", "=", "true", ";", "}", "}", "if", "(", "configChanged", ")", "{", "mWaitingForConfig", "=", "true", ";", "startFreezingDisplayLocked", "(", "false", ")", ";", "mH", ".", "sendEmptyMessage", "(", "H", ".", "SEND_NEW_CONFIGURATION", ")", ";", "}", "rebuildBlackFrame", "(", "false", ")", ";", "performLayoutAndPlaceSurfacesLocked", "(", ")", ";", "}", "public", "void", "clearForcedDisplaySize", "(", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "setForcedDisplaySizeLocked", "(", "mInitialDisplayWidth", ",", "mInitialDisplayHeight", ")", ";", "Settings", ".", "Secure", ".", "putString", "(", "mContext", ".", "getContentResolver", "(", ")", ",", "Settings", ".", "Secure", ".", "DISPLAY_SIZE_FORCED", ",", "\"\"", ")", ";", "}", "}", "public", "boolean", "canStatusBarHide", "(", ")", "{", "return", "mPolicy", ".", "canStatusBarHide", "(", ")", ";", "}", "final", "WindowState", "windowForClientLocked", "(", "Session", "session", ",", "IWindow", "client", ",", "boolean", "throwOnError", ")", "{", "return", "windowForClientLocked", "(", "session", ",", "client", ".", "asBinder", "(", ")", ",", "throwOnError", ")", ";", "}", "final", "WindowState", "windowForClientLocked", "(", "Session", "session", ",", "IBinder", "client", ",", "boolean", "throwOnError", ")", "{", "WindowState", "win", "=", "mWindowMap", ".", "get", "(", "client", ")", ";", "if", "(", "localLOGV", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "client", "+", "\":", "\"", "+", "win", ")", ";", "if", "(", "win", "==", "null", ")", "{", "RuntimeException", "ex", "=", "new", "IllegalArgumentException", "(", "\"\"", "+", "client", "+", "\"\"", ")", ";", "if", "(", "throwOnError", ")", "{", "throw", "ex", ";", "}", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ",", "ex", ")", ";", "return", "null", ";", "}", "if", "(", "session", "!=", "null", "&&", "win", ".", "mSession", "!=", "session", ")", "{", "RuntimeException", "ex", "=", "new", "IllegalArgumentException", "(", "\"\"", "+", "client", "+", "\"\"", "+", "win", ".", "mSession", "+", "\",", "not", "\"", "+", "session", ")", ";", "if", "(", "throwOnError", ")", "{", "throw", "ex", ";", "}", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ",", "ex", ")", ";", "return", "null", ";", "}", "return", "win", ";", "}", "final", "void", "rebuildAppWindowListLocked", "(", ")", "{", "int", "NW", "=", "mWindows", ".", "size", "(", ")", ";", "int", "i", ";", "int", "lastWallpaper", "=", "-", "1", ";", "int", "numRemoved", "=", "0", ";", "if", "(", "mRebuildTmp", ".", "length", "<", "NW", ")", "{", "mRebuildTmp", "=", "new", "WindowState", "[", "NW", "+", "10", "]", ";", "}", "i", "=", "0", ";", "while", "(", "i", "<", "NW", ")", "{", "WindowState", "w", "=", "mWindows", ".", "get", "(", "i", ")", ";", "if", "(", "w", ".", "mAppToken", "!=", "null", ")", "{", "WindowState", "win", "=", "mWindows", ".", "remove", "(", "i", ")", ";", "win", ".", "mRebuilding", "=", "true", ";", "mRebuildTmp", "[", "numRemoved", "]", "=", "win", ";", "mWindowsChanged", "=", "true", ";", "if", "(", "DEBUG_WINDOW_MOVEMENT", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "win", ")", ";", "NW", "--", ";", "numRemoved", "++", ";", "continue", ";", "}", "else", "if", "(", "w", ".", "mAttrs", ".", "type", "==", "WindowManager", ".", "LayoutParams", ".", "TYPE_WALLPAPER", "&&", "lastWallpaper", "==", "i", "-", "1", ")", "{", "lastWallpaper", "=", "i", ";", "}", "i", "++", ";", "}", "lastWallpaper", "++", ";", "i", "=", "lastWallpaper", ";", "int", "NT", "=", "mExitingAppTokens", ".", "size", "(", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "NT", ";", "j", "++", ")", "{", "i", "=", "reAddAppWindowsLocked", "(", "i", ",", "mExitingAppTokens", ".", "get", "(", "j", ")", ")", ";", "}", "NT", "=", "mAppTokens", ".", "size", "(", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "NT", ";", "j", "++", ")", "{", "i", "=", "reAddAppWindowsLocked", "(", "i", ",", "mAppTokens", ".", "get", "(", "j", ")", ")", ";", "}", "i", "-=", "lastWallpaper", ";", "if", "(", "i", "!=", "numRemoved", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "numRemoved", "+", "\"\"", "+", "i", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "numRemoved", ";", "i", "++", ")", "{", "WindowState", "ws", "=", "mRebuildTmp", "[", "i", "]", ";", "if", "(", "ws", ".", "mRebuilding", ")", "{", "StringWriter", "sw", "=", "new", "StringWriter", "(", ")", ";", "PrintWriter", "pw", "=", "new", "PrintWriter", "(", "sw", ")", ";", "ws", ".", "dump", "(", "pw", ",", "\"\"", ",", "true", ")", ";", "pw", ".", "flush", "(", ")", ";", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "ws", ")", ";", "Slog", ".", "w", "(", "TAG", ",", "sw", ".", "toString", "(", ")", ")", ";", "}", "}", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "dumpAppTokensLocked", "(", ")", ";", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "dumpWindowsLocked", "(", ")", ";", "}", "}", "private", "final", "void", "assignLayersLocked", "(", ")", "{", "int", "N", "=", "mWindows", ".", "size", "(", ")", ";", "int", "curBaseLayer", "=", "0", ";", "int", "curLayer", "=", "0", ";", "int", "i", ";", "if", "(", "DEBUG_LAYERS", ")", "{", "RuntimeException", "here", "=", "new", "RuntimeException", "(", "\"here\"", ")", ";", "here", ".", "fillInStackTrace", "(", ")", ";", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ",", "here", ")", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "WindowState", "w", "=", "mWindows", ".", "get", "(", "i", ")", ";", "if", "(", "w", ".", "mBaseLayer", "==", "curBaseLayer", "||", "w", ".", "mIsImWindow", "||", "(", "i", ">", "0", "&&", "w", ".", "mIsWallpaper", ")", ")", "{", "curLayer", "+=", "WINDOW_LAYER_MULTIPLIER", ";", "w", ".", "mLayer", "=", "curLayer", ";", "}", "else", "{", "curBaseLayer", "=", "curLayer", "=", "w", ".", "mBaseLayer", ";", "w", ".", "mLayer", "=", "curLayer", ";", "}", "if", "(", "w", ".", "mTargetAppToken", "!=", "null", ")", "{", "w", ".", "mAnimLayer", "=", "w", ".", "mLayer", "+", "w", ".", "mTargetAppToken", ".", "animLayerAdjustment", ";", "}", "else", "if", "(", "w", ".", "mAppToken", "!=", "null", ")", "{", "w", ".", "mAnimLayer", "=", "w", ".", "mLayer", "+", "w", ".", "mAppToken", ".", "animLayerAdjustment", ";", "}", "else", "{", "w", ".", "mAnimLayer", "=", "w", ".", "mLayer", ";", "}", "if", "(", "w", ".", "mIsImWindow", ")", "{", "w", ".", "mAnimLayer", "+=", "mInputMethodAnimLayerAdjustment", ";", "}", "else", "if", "(", "w", ".", "mIsWallpaper", ")", "{", "w", ".", "mAnimLayer", "+=", "mWallpaperAnimLayerAdjustment", ";", "}", "if", "(", "DEBUG_LAYERS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "w", "+", "\":", "\"", "+", "w", ".", "mAnimLayer", ")", ";", "}", "}", "private", "boolean", "mInLayout", "=", "false", ";", "private", "final", "void", "performLayoutAndPlaceSurfacesLocked", "(", ")", "{", "if", "(", "mInLayout", ")", "{", "if", "(", "DEBUG", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "return", ";", "}", "if", "(", "mWaitingForConfig", ")", "{", "return", ";", "}", "if", "(", "mDisplay", "==", "null", ")", "{", "return", ";", "}", "mInLayout", "=", "true", ";", "boolean", "recoveringMemory", "=", "false", ";", "try", "{", "if", "(", "mForceRemoves", "!=", "null", ")", "{", "recoveringMemory", "=", "true", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "mForceRemoves", ".", "size", "(", ")", ";", "i", "++", ")", "{", "WindowState", "ws", "=", "mForceRemoves", ".", "get", "(", "i", ")", ";", "Slog", ".", "i", "(", "TAG", ",", "\"\"", "+", "ws", ")", ";", "removeWindowInnerLocked", "(", "ws", ".", "mSession", ",", "ws", ")", ";", "}", "mForceRemoves", "=", "null", ";", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "Object", "tmp", "=", "new", "Object", "(", ")", ";", "synchronized", "(", "tmp", ")", "{", "try", "{", "tmp", ".", "wait", "(", "250", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "}", "}", "}", "catch", "(", "RuntimeException", "e", ")", "{", "Log", ".", "wtf", "(", "TAG", ",", "\"\"", ",", "e", ")", ";", "}", "try", "{", "performLayoutAndPlaceSurfacesLockedInner", "(", "recoveringMemory", ")", ";", "int", "N", "=", "mPendingRemove", ".", "size", "(", ")", ";", "if", "(", "N", ">", "0", ")", "{", "if", "(", "mPendingRemoveTmp", ".", "length", "<", "N", ")", "{", "mPendingRemoveTmp", "=", "new", "WindowState", "[", "N", "+", "10", "]", ";", "}", "mPendingRemove", ".", "toArray", "(", "mPendingRemoveTmp", ")", ";", "mPendingRemove", ".", "clear", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "WindowState", "w", "=", "mPendingRemoveTmp", "[", "i", "]", ";", "removeWindowInnerLocked", "(", "w", ".", "mSession", ",", "w", ")", ";", "}", "mInLayout", "=", "false", ";", "assignLayersLocked", "(", ")", ";", "mLayoutNeeded", "=", "true", ";", "performLayoutAndPlaceSurfacesLocked", "(", ")", ";", "}", "else", "{", "mInLayout", "=", "false", ";", "if", "(", "mLayoutNeeded", ")", "{", "requestAnimationLocked", "(", "0", ")", ";", "}", "}", "if", "(", "mWindowsChanged", "&&", "!", "mWindowChangeListeners", ".", "isEmpty", "(", ")", ")", "{", "mH", ".", "removeMessages", "(", "H", ".", "REPORT_WINDOWS_CHANGE", ")", ";", "mH", ".", "sendMessage", "(", "mH", ".", "obtainMessage", "(", "H", ".", "REPORT_WINDOWS_CHANGE", ")", ")", ";", "}", "}", "catch", "(", "RuntimeException", "e", ")", "{", "mInLayout", "=", "false", ";", "Log", ".", "wtf", "(", "TAG", ",", "\"\"", ",", "e", ")", ";", "}", "}", "private", "final", "int", "performLayoutLockedInner", "(", "boolean", "initial", ",", "boolean", "updateInputWindows", ")", "{", "if", "(", "!", "mLayoutNeeded", ")", "{", "return", "0", ";", "}", "mLayoutNeeded", "=", "false", ";", "final", "int", "dw", "=", "mCurDisplayWidth", ";", "final", "int", "dh", "=", "mCurDisplayHeight", ";", "final", "int", "NFW", "=", "mFakeWindows", ".", "size", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "NFW", ";", "i", "++", ")", "{", "mFakeWindows", ".", "get", "(", "i", ")", ".", "layout", "(", "dw", ",", "dh", ")", ";", "}", "final", "int", "N", "=", "mWindows", ".", "size", "(", ")", ";", "int", "i", ";", "if", "(", "DEBUG_LAYOUT", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "mLayoutNeeded", "+", "\"", "dw=\"", "+", "dw", "+", "\"", "dh=\"", "+", "dh", ")", ";", "}", "mPolicy", ".", "beginLayoutLw", "(", "dw", ",", "dh", ",", "mRotation", ")", ";", "int", "seq", "=", "mLayoutSeq", "+", "1", ";", "if", "(", "seq", "<", "0", ")", "seq", "=", "0", ";", "mLayoutSeq", "=", "seq", ";", "int", "topAttached", "=", "-", "1", ";", "for", "(", "i", "=", "N", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowState", "win", "=", "mWindows", ".", "get", "(", "i", ")", ";", "final", "boolean", "gone", "=", "win", ".", "isGoneForLayoutLw", "(", ")", ";", "if", "(", "DEBUG_LAYOUT", "&&", "!", "win", ".", "mLayoutAttached", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"1ST", "PASS", "\"", "+", "win", "+", "\":", "gone=\"", "+", "gone", "+", "\"", "mHaveFrame=\"", "+", "win", ".", "mHaveFrame", "+", "\"\"", "+", "win", ".", "mLayoutAttached", ")", ";", "final", "AppWindowToken", "atoken", "=", "win", ".", "mAppToken", ";", "if", "(", "gone", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "win", ".", "mViewVisibility", "+", "\"\"", "+", "win", ".", "mRelayoutCalled", "+", "\"", "hidden=\"", "+", "win", ".", "mRootToken", ".", "hidden", "+", "\"\"", "+", "(", "atoken", "!=", "null", "&&", "atoken", ".", "hiddenRequested", ")", "+", "\"\"", "+", "win", ".", "mAttachedHidden", ")", ";", "else", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "win", ".", "mViewVisibility", "+", "\"\"", "+", "win", ".", "mRelayoutCalled", "+", "\"", "hidden=\"", "+", "win", ".", "mRootToken", ".", "hidden", "+", "\"\"", "+", "(", "atoken", "!=", "null", "&&", "atoken", ".", "hiddenRequested", ")", "+", "\"\"", "+", "win", ".", "mAttachedHidden", ")", ";", "}", "if", "(", "!", "gone", "||", "!", "win", ".", "mHaveFrame", "||", "win", ".", "mLayoutNeeded", ")", "{", "if", "(", "!", "win", ".", "mLayoutAttached", ")", "{", "if", "(", "initial", ")", "{", "win", ".", "mContentChanged", "=", "false", ";", "}", "win", ".", "mLayoutNeeded", "=", "false", ";", "win", ".", "prelayout", "(", ")", ";", "mPolicy", ".", "layoutWindowLw", "(", "win", ",", "win", ".", "mAttrs", ",", "null", ")", ";", "win", ".", "mLayoutSeq", "=", "seq", ";", "if", "(", "DEBUG_LAYOUT", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "win", ".", "mFrame", "+", "\"\"", "+", "win", ".", "mContainingFrame", "+", "\"\"", "+", "win", ".", "mDisplayFrame", ")", ";", "}", "else", "{", "if", "(", "topAttached", "<", "0", ")", "topAttached", "=", "i", ";", "}", "}", "}", "for", "(", "i", "=", "topAttached", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowState", "win", "=", "mWindows", ".", "get", "(", "i", ")", ";", "if", "(", "win", ".", "mLayoutAttached", ")", "{", "if", "(", "DEBUG_LAYOUT", ")", "Slog", ".", "v", "(", "TAG", ",", "\"2ND", "PASS", "\"", "+", "win", "+", "\"", "mHaveFrame=\"", "+", "win", ".", "mHaveFrame", "+", "\"\"", "+", "win", ".", "mViewVisibility", "+", "\"\"", "+", "win", ".", "mRelayoutCalled", ")", ";", "if", "(", "(", "win", ".", "mViewVisibility", "!=", "View", ".", "GONE", "&&", "win", ".", "mRelayoutCalled", ")", "||", "!", "win", ".", "mHaveFrame", "||", "win", ".", "mLayoutNeeded", ")", "{", "if", "(", "initial", ")", "{", "win", ".", "mContentChanged", "=", "false", ";", "}", "win", ".", "mLayoutNeeded", "=", "false", ";", "win", ".", "prelayout", "(", ")", ";", "mPolicy", ".", "layoutWindowLw", "(", "win", ",", "win", ".", "mAttrs", ",", "win", ".", "mAttachedWindow", ")", ";", "win", ".", "mLayoutSeq", "=", "seq", ";", "if", "(", "DEBUG_LAYOUT", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "win", ".", "mFrame", "+", "\"\"", "+", "win", ".", "mContainingFrame", "+", "\"\"", "+", "win", ".", "mDisplayFrame", ")", ";", "}", "}", "}", "mInputMonitor", ".", "setUpdateInputWindowsNeededLw", "(", ")", ";", "if", "(", "updateInputWindows", ")", "{", "mInputMonitor", ".", "updateInputWindowsLw", "(", "false", ")", ";", "}", "return", "mPolicy", ".", "finishLayoutLw", "(", ")", ";", "}", "void", "makeWindowFreezingScreenIfNeededLocked", "(", "WindowState", "w", ")", "{", "if", "(", "mDisplayFrozen", "||", "!", "mPolicy", ".", "isScreenOnFully", "(", ")", ")", "{", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "w", ")", ";", "w", ".", "mOrientationChanging", "=", "true", ";", "if", "(", "!", "mWindowsFreezingScreen", ")", "{", "mWindowsFreezingScreen", "=", "true", ";", "mH", ".", "removeMessages", "(", "H", ".", "WINDOW_FREEZE_TIMEOUT", ")", ";", "mH", ".", "sendMessageDelayed", "(", "mH", ".", "obtainMessage", "(", "H", ".", "WINDOW_FREEZE_TIMEOUT", ")", ",", "2000", ")", ";", "}", "}", "}", "private", "final", "void", "performLayoutAndPlaceSurfacesLockedInner", "(", "boolean", "recoveringMemory", ")", "{", "if", "(", "mDisplay", "==", "null", ")", "{", "Slog", ".", "i", "(", "TAG", ",", "\"\"", ")", ";", "return", ";", "}", "final", "long", "currentTime", "=", "SystemClock", ".", "uptimeMillis", "(", ")", ";", "final", "int", "dw", "=", "mCurDisplayWidth", ";", "final", "int", "dh", "=", "mCurDisplayHeight", ";", "final", "int", "innerDw", "=", "mAppDisplayWidth", ";", "final", "int", "innerDh", "=", "mAppDisplayHeight", ";", "int", "i", ";", "if", "(", "mFocusMayChange", ")", "{", "mFocusMayChange", "=", "false", ";", "updateFocusedWindowLocked", "(", "UPDATE_FOCUS_WILL_PLACE_SURFACES", ",", "false", ")", ";", "}", "for", "(", "i", "=", "mExitingTokens", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "mExitingTokens", ".", "get", "(", "i", ")", ".", "hasVisible", "=", "false", ";", "}", "for", "(", "i", "=", "mExitingAppTokens", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "mExitingAppTokens", ".", "get", "(", "i", ")", ".", "hasVisible", "=", "false", ";", "}", "boolean", "orientationChangeComplete", "=", "true", ";", "Session", "holdScreen", "=", "null", ";", "float", "screenBrightness", "=", "-", "1", ";", "float", "buttonBrightness", "=", "-", "1", ";", "boolean", "focusDisplayed", "=", "false", ";", "boolean", "animating", "=", "false", ";", "boolean", "createWatermark", "=", "false", ";", "boolean", "updateRotation", "=", "false", ";", "boolean", "screenRotationFinished", "=", "false", ";", "if", "(", "mFxSession", "==", "null", ")", "{", "mFxSession", "=", "new", "SurfaceSession", "(", ")", ";", "createWatermark", "=", "true", ";", "}", "if", "(", "SHOW_LIGHT_TRANSACTIONS", ")", "Slog", ".", "i", "(", "TAG", ",", "\"\"", ")", ";", "Surface", ".", "openTransaction", "(", ")", ";", "if", "(", "createWatermark", ")", "{", "createWatermark", "(", ")", ";", "}", "if", "(", "mWatermark", "!=", "null", ")", "{", "mWatermark", ".", "positionSurface", "(", "dw", ",", "dh", ")", ";", "}", "if", "(", "mStrictModeFlash", "!=", "null", ")", "{", "mStrictModeFlash", ".", "positionSurface", "(", "dw", ",", "dh", ")", ";", "}", "try", "{", "boolean", "wallpaperForceHidingChanged", "=", "false", ";", "int", "repeats", "=", "0", ";", "int", "changes", "=", "0", ";", "do", "{", "repeats", "++", ";", "if", "(", "repeats", ">", "6", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "mLayoutNeeded", "=", "false", ";", "break", ";", "}", "if", "(", "(", "changes", "&", "(", "WindowManagerPolicy", ".", "FINISH_LAYOUT_REDO_WALLPAPER", "|", "WindowManagerPolicy", ".", "FINISH_LAYOUT_REDO_CONFIG", "|", "WindowManagerPolicy", ".", "FINISH_LAYOUT_REDO_LAYOUT", ")", ")", "!=", "0", ")", "{", "if", "(", "(", "changes", "&", "WindowManagerPolicy", ".", "FINISH_LAYOUT_REDO_WALLPAPER", ")", "!=", "0", ")", "{", "if", "(", "(", "adjustWallpaperWindowsLocked", "(", ")", "&", "ADJUST_WALLPAPER_LAYERS_CHANGED", ")", "!=", "0", ")", "{", "assignLayersLocked", "(", ")", ";", "mLayoutNeeded", "=", "true", ";", "}", "}", "if", "(", "(", "changes", "&", "WindowManagerPolicy", ".", "FINISH_LAYOUT_REDO_CONFIG", ")", "!=", "0", ")", "{", "if", "(", "DEBUG_LAYOUT", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "if", "(", "updateOrientationFromAppTokensLocked", "(", "true", ")", ")", "{", "mLayoutNeeded", "=", "true", ";", "mH", ".", "sendEmptyMessage", "(", "H", ".", "SEND_NEW_CONFIGURATION", ")", ";", "}", "}", "if", "(", "(", "changes", "&", "WindowManagerPolicy", ".", "FINISH_LAYOUT_REDO_LAYOUT", ")", "!=", "0", ")", "{", "mLayoutNeeded", "=", "true", ";", "}", "}", "if", "(", "repeats", "<", "4", ")", "{", "changes", "=", "performLayoutLockedInner", "(", "repeats", "==", "0", ",", "false", ")", ";", "if", "(", "changes", "!=", "0", ")", "{", "continue", ";", "}", "}", "else", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "changes", "=", "0", ";", "}", "final", "int", "transactionSequence", "=", "++", "mTransactionSequence", ";", "boolean", "tokensAnimating", "=", "false", ";", "final", "int", "NAT", "=", "mAppTokens", ".", "size", "(", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "NAT", ";", "i", "++", ")", "{", "if", "(", "mAppTokens", ".", "get", "(", "i", ")", ".", "stepAnimationLocked", "(", "currentTime", ",", "innerDw", ",", "innerDh", ")", ")", "{", "tokensAnimating", "=", "true", ";", "}", "}", "final", "int", "NEAT", "=", "mExitingAppTokens", ".", "size", "(", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "NEAT", ";", "i", "++", ")", "{", "if", "(", "mExitingAppTokens", ".", "get", "(", "i", ")", ".", "stepAnimationLocked", "(", "currentTime", ",", "innerDw", ",", "innerDh", ")", ")", "{", "tokensAnimating", "=", "true", ";", "}", "}", "if", "(", "DEBUG_APP_TRANSITIONS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "transactionSequence", "+", "\"\"", "+", "tokensAnimating", ")", ";", "animating", "=", "tokensAnimating", ";", "if", "(", "mScreenRotationAnimation", "!=", "null", ")", "{", "if", "(", "mScreenRotationAnimation", ".", "isAnimating", "(", ")", ")", "{", "if", "(", "mScreenRotationAnimation", ".", "stepAnimation", "(", "currentTime", ")", ")", "{", "animating", "=", "true", ";", "}", "else", "{", "screenRotationFinished", "=", "true", ";", "updateRotation", "=", "true", ";", "}", "}", "}", "boolean", "tokenMayBeDrawn", "=", "false", ";", "boolean", "wallpaperMayChange", "=", "false", ";", "boolean", "forceHiding", "=", "false", ";", "WindowState", "windowDetachedWallpaper", "=", "null", ";", "WindowState", "windowAnimationBackground", "=", "null", ";", "int", "windowAnimationBackgroundColor", "=", "0", ";", "mPolicy", ".", "beginAnimationLw", "(", "dw", ",", "dh", ")", ";", "final", "int", "N", "=", "mWindows", ".", "size", "(", ")", ";", "for", "(", "i", "=", "N", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowState", "w", "=", "mWindows", ".", "get", "(", "i", ")", ";", "final", "WindowManager", ".", "LayoutParams", "attrs", "=", "w", ".", "mAttrs", ";", "if", "(", "w", ".", "mSurface", "!=", "null", ")", "{", "if", "(", "w", ".", "commitFinishDrawingLocked", "(", "currentTime", ")", ")", "{", "if", "(", "(", "w", ".", "mAttrs", ".", "flags", "&", "WindowManager", ".", "LayoutParams", ".", "FLAG_SHOW_WALLPAPER", ")", "!=", "0", ")", "{", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "w", ")", ";", "wallpaperMayChange", "=", "true", ";", "}", "}", "final", "boolean", "wasAnimating", "=", "w", ".", "mAnimating", ";", "int", "animDw", "=", "innerDw", ";", "int", "animDh", "=", "innerDh", ";", "if", "(", "w", ".", "shouldAnimateMove", "(", ")", ")", "{", "Animation", "a", "=", "AnimationUtils", ".", "loadAnimation", "(", "mContext", ",", "com", ".", "android", ".", "internal", ".", "R", ".", "anim", ".", "window_move_from_decor", ")", ";", "w", ".", "setAnimation", "(", "a", ")", ";", "animDw", "=", "w", ".", "mLastFrame", ".", "left", "-", "w", ".", "mFrame", ".", "left", ";", "animDh", "=", "w", ".", "mLastFrame", ".", "top", "-", "w", ".", "mFrame", ".", "top", ";", "}", "final", "boolean", "nowAnimating", "=", "w", ".", "stepAnimationLocked", "(", "currentTime", ",", "animDw", ",", "animDh", ")", ";", "if", "(", "nowAnimating", ")", "{", "if", "(", "w", ".", "mAnimation", "!=", "null", ")", "{", "if", "(", "(", "w", ".", "mAttrs", ".", "flags", "&", "FLAG_SHOW_WALLPAPER", ")", "!=", "0", "&&", "w", ".", "mAnimation", ".", "getDetachWallpaper", "(", ")", ")", "{", "windowDetachedWallpaper", "=", "w", ";", "}", "if", "(", "w", ".", "mAnimation", ".", "getBackgroundColor", "(", ")", "!=", "0", ")", "{", "if", "(", "windowAnimationBackground", "==", "null", "||", "w", ".", "mAnimLayer", "<", "windowAnimationBackground", ".", "mAnimLayer", ")", "{", "windowAnimationBackground", "=", "w", ";", "windowAnimationBackgroundColor", "=", "w", ".", "mAnimation", ".", "getBackgroundColor", "(", ")", ";", "}", "}", "}", "animating", "=", "true", ";", "}", "if", "(", "w", ".", "mAppToken", "!=", "null", "&&", "w", ".", "mAppToken", ".", "animation", "!=", "null", "&&", "w", ".", "mAppToken", ".", "animating", ")", "{", "if", "(", "(", "w", ".", "mAttrs", ".", "flags", "&", "FLAG_SHOW_WALLPAPER", ")", "!=", "0", "&&", "w", ".", "mAppToken", ".", "animation", ".", "getDetachWallpaper", "(", ")", ")", "{", "windowDetachedWallpaper", "=", "w", ";", "}", "if", "(", "w", ".", "mAppToken", ".", "animation", ".", "getBackgroundColor", "(", ")", "!=", "0", ")", "{", "if", "(", "windowAnimationBackground", "==", "null", "||", "w", ".", "mAnimLayer", "<", "windowAnimationBackground", ".", "mAnimLayer", ")", "{", "windowAnimationBackground", "=", "w", ";", "windowAnimationBackgroundColor", "=", "w", ".", "mAppToken", ".", "animation", ".", "getBackgroundColor", "(", ")", ";", "}", "}", "}", "if", "(", "wasAnimating", "&&", "!", "w", ".", "mAnimating", "&&", "mWallpaperTarget", "==", "w", ")", "{", "wallpaperMayChange", "=", "true", ";", "}", "if", "(", "mPolicy", ".", "doesForceHide", "(", "w", ",", "attrs", ")", ")", "{", "if", "(", "!", "wasAnimating", "&&", "nowAnimating", ")", "{", "if", "(", "DEBUG_VISIBILITY", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "w", ")", ";", "wallpaperForceHidingChanged", "=", "true", ";", "mFocusMayChange", "=", "true", ";", "}", "else", "if", "(", "w", ".", "isReadyForDisplay", "(", ")", "&&", "w", ".", "mAnimation", "==", "null", ")", "{", "forceHiding", "=", "true", ";", "}", "}", "else", "if", "(", "mPolicy", ".", "canBeForceHidden", "(", "w", ",", "attrs", ")", ")", "{", "boolean", "changed", ";", "if", "(", "forceHiding", ")", "{", "changed", "=", "w", ".", "hideLw", "(", "false", ",", "false", ")", ";", "if", "(", "DEBUG_VISIBILITY", "&&", "changed", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "w", ")", ";", "}", "else", "{", "changed", "=", "w", ".", "showLw", "(", "false", ",", "false", ")", ";", "if", "(", "DEBUG_VISIBILITY", "&&", "changed", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "w", ")", ";", "if", "(", "changed", ")", "{", "if", "(", "wallpaperForceHidingChanged", "&&", "w", ".", "isVisibleNow", "(", ")", ")", "{", "Animation", "a", "=", "mPolicy", ".", "createForceHideEnterAnimation", "(", ")", ";", "if", "(", "a", "!=", "null", ")", "{", "w", ".", "setAnimation", "(", "a", ")", ";", "}", "}", "if", "(", "mCurrentFocus", "==", "null", "||", "mCurrentFocus", ".", "mLayer", "<", "w", ".", "mLayer", ")", "{", "mFocusMayChange", "=", "true", ";", "}", "}", "}", "if", "(", "changed", "&&", "(", "attrs", ".", "flags", "&", "WindowManager", ".", "LayoutParams", ".", "FLAG_SHOW_WALLPAPER", ")", "!=", "0", ")", "{", "wallpaperMayChange", "=", "true", ";", "}", "}", "mPolicy", ".", "animatingWindowLw", "(", "w", ",", "attrs", ")", ";", "}", "final", "AppWindowToken", "atoken", "=", "w", ".", "mAppToken", ";", "if", "(", "atoken", "!=", "null", "&&", "(", "!", "atoken", ".", "allDrawn", "||", "atoken", ".", "freezingScreen", ")", ")", "{", "if", "(", "atoken", ".", "lastTransactionSequence", "!=", "transactionSequence", ")", "{", "atoken", ".", "lastTransactionSequence", "=", "transactionSequence", ";", "atoken", ".", "numInterestingWindows", "=", "atoken", ".", "numDrawnWindows", "=", "0", ";", "atoken", ".", "startingDisplayed", "=", "false", ";", "}", "if", "(", "(", "w", ".", "isOnScreen", "(", ")", "||", "w", ".", "mAttrs", ".", "type", "==", "WindowManager", ".", "LayoutParams", ".", "TYPE_BASE_APPLICATION", ")", "&&", "!", "w", ".", "mExiting", "&&", "!", "w", ".", "mDestroying", ")", "{", "if", "(", "DEBUG_VISIBILITY", "||", "DEBUG_ORIENTATION", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"Eval", "win", "\"", "+", "w", "+", "\":", "isDrawn=\"", "+", "w", ".", "isDrawnLw", "(", ")", "+", "\"\"", "+", "w", ".", "isAnimating", "(", ")", ")", ";", "if", "(", "!", "w", ".", "isDrawnLw", "(", ")", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "w", ".", "mSurface", "+", "\"", "pv=\"", "+", "w", ".", "mPolicyVisibility", "+", "\"", "dp=\"", "+", "w", ".", "mDrawPending", "+", "\"", "cdp=\"", "+", "w", ".", "mCommitDrawPending", "+", "\"", "ah=\"", "+", "w", ".", "mAttachedHidden", "+", "\"", "th=\"", "+", "atoken", ".", "hiddenRequested", "+", "\"", "a=\"", "+", "w", ".", "mAnimating", ")", ";", "}", "}", "if", "(", "w", "!=", "atoken", ".", "startingWindow", ")", "{", "if", "(", "!", "atoken", ".", "freezingScreen", "||", "!", "w", ".", "mAppFreezing", ")", "{", "atoken", ".", "numInterestingWindows", "++", ";", "if", "(", "w", ".", "isDrawnLw", "(", ")", ")", "{", "atoken", ".", "numDrawnWindows", "++", ";", "if", "(", "DEBUG_VISIBILITY", "||", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "atoken", "+", "\"\"", "+", "atoken", ".", "freezingScreen", "+", "\"\"", "+", "w", ".", "mAppFreezing", ")", ";", "tokenMayBeDrawn", "=", "true", ";", "}", "}", "}", "else", "if", "(", "w", ".", "isDrawnLw", "(", ")", ")", "{", "atoken", ".", "startingDisplayed", "=", "true", ";", "}", "}", "}", "else", "if", "(", "w", ".", "mReadyToShow", ")", "{", "w", ".", "performShowLocked", "(", ")", ";", "}", "}", "changes", "|=", "mPolicy", ".", "finishAnimationLw", "(", ")", ";", "if", "(", "tokenMayBeDrawn", ")", "{", "final", "int", "NT", "=", "mAppTokens", ".", "size", "(", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "NT", ";", "i", "++", ")", "{", "AppWindowToken", "wtoken", "=", "mAppTokens", ".", "get", "(", "i", ")", ";", "if", "(", "wtoken", ".", "freezingScreen", ")", "{", "int", "numInteresting", "=", "wtoken", ".", "numInterestingWindows", ";", "if", "(", "numInteresting", ">", "0", "&&", "wtoken", ".", "numDrawnWindows", ">=", "numInteresting", ")", "{", "if", "(", "DEBUG_VISIBILITY", ")", "Slog", ".", "v", "(", "TAG", ",", "\"allDrawn:", "\"", "+", "wtoken", "+", "\"\"", "+", "numInteresting", "+", "\"", "drawn=\"", "+", "wtoken", ".", "numDrawnWindows", ")", ";", "wtoken", ".", "showAllWindowsLocked", "(", ")", ";", "unsetAppFreezingScreenLocked", "(", "wtoken", ",", "false", ",", "true", ")", ";", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "i", "(", "TAG", ",", "\"\"", "+", "wtoken", "+", "\"\"", "+", "numInteresting", "+", "\"", "numDrawn=\"", "+", "wtoken", ".", "numDrawnWindows", ")", ";", "orientationChangeComplete", "=", "true", ";", "}", "}", "else", "if", "(", "!", "wtoken", ".", "allDrawn", ")", "{", "int", "numInteresting", "=", "wtoken", ".", "numInterestingWindows", ";", "if", "(", "numInteresting", ">", "0", "&&", "wtoken", ".", "numDrawnWindows", ">=", "numInteresting", ")", "{", "if", "(", "DEBUG_VISIBILITY", ")", "Slog", ".", "v", "(", "TAG", ",", "\"allDrawn:", "\"", "+", "wtoken", "+", "\"\"", "+", "numInteresting", "+", "\"", "drawn=\"", "+", "wtoken", ".", "numDrawnWindows", ")", ";", "wtoken", ".", "allDrawn", "=", "true", ";", "changes", "|=", "PhoneWindowManager", ".", "FINISH_LAYOUT_REDO_ANIM", ";", "if", "(", "!", "mOpeningApps", ".", "contains", "(", "wtoken", ")", ")", "{", "wtoken", ".", "showAllWindowsLocked", "(", ")", ";", "}", "}", "}", "}", "}", "if", "(", "mAppTransitionReady", ")", "{", "int", "NN", "=", "mOpeningApps", ".", "size", "(", ")", ";", "boolean", "goodToGo", "=", "true", ";", "if", "(", "DEBUG_APP_TRANSITIONS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Checking", "\"", "+", "NN", "+", "\"\"", "+", "mDisplayFrozen", "+", "\"", "timeout=\"", "+", "mAppTransitionTimeout", "+", "\")...\"", ")", ";", "if", "(", "!", "mDisplayFrozen", "&&", "!", "mAppTransitionTimeout", ")", "{", "for", "(", "i", "=", "0", ";", "i", "<", "NN", "&&", "goodToGo", ";", "i", "++", ")", "{", "AppWindowToken", "wtoken", "=", "mOpeningApps", ".", "get", "(", "i", ")", ";", "if", "(", "DEBUG_APP_TRANSITIONS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", "+", "\":", "allDrawn=\"", "+", "wtoken", ".", "allDrawn", "+", "\"\"", "+", "wtoken", ".", "startingDisplayed", ")", ";", "if", "(", "!", "wtoken", ".", "allDrawn", "&&", "!", "wtoken", ".", "startingDisplayed", "&&", "!", "wtoken", ".", "startingMoved", ")", "{", "goodToGo", "=", "false", ";", "}", "}", "}", "if", "(", "goodToGo", ")", "{", "if", "(", "DEBUG_APP_TRANSITIONS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "int", "transit", "=", "mNextAppTransition", ";", "if", "(", "mSkipAppTransitionAnimation", ")", "{", "transit", "=", "WindowManagerPolicy", ".", "TRANSIT_UNSET", ";", "}", "mNextAppTransition", "=", "WindowManagerPolicy", ".", "TRANSIT_UNSET", ";", "mAppTransitionReady", "=", "false", ";", "mAppTransitionRunning", "=", "true", ";", "mAppTransitionTimeout", "=", "false", ";", "mStartingIconInTransition", "=", "false", ";", "mSkipAppTransitionAnimation", "=", "false", ";", "mH", ".", "removeMessages", "(", "H", ".", "APP_TRANSITION_TIMEOUT", ")", ";", "if", "(", "mToTopApps", ".", "size", "(", ")", ">", "0", ")", "{", "NN", "=", "mAppTokens", ".", "size", "(", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "NN", ";", "i", "++", ")", "{", "AppWindowToken", "wtoken", "=", "mAppTokens", ".", "get", "(", "i", ")", ";", "if", "(", "wtoken", ".", "sendingToTop", ")", "{", "wtoken", ".", "sendingToTop", "=", "false", ";", "moveAppWindowsLocked", "(", "wtoken", ",", "NN", ",", "false", ")", ";", "}", "}", "mToTopApps", ".", "clear", "(", ")", ";", "}", "WindowState", "oldWallpaper", "=", "mWallpaperTarget", ";", "adjustWallpaperWindowsLocked", "(", ")", ";", "wallpaperMayChange", "=", "false", ";", "LayoutParams", "animLp", "=", "null", ";", "int", "bestAnimLayer", "=", "-", "1", ";", "boolean", "fullscreenAnim", "=", "false", ";", "if", "(", "DEBUG_APP_TRANSITIONS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "mWallpaperTarget", "+", "\"\"", "+", "mLowerWallpaperTarget", "+", "\"\"", "+", "mUpperWallpaperTarget", ")", ";", "int", "foundWallpapers", "=", "0", ";", "final", "int", "NC", "=", "mClosingApps", ".", "size", "(", ")", ";", "NN", "=", "NC", "+", "mOpeningApps", ".", "size", "(", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "NN", ";", "i", "++", ")", "{", "AppWindowToken", "wtoken", ";", "int", "mode", ";", "if", "(", "i", "<", "NC", ")", "{", "wtoken", "=", "mClosingApps", ".", "get", "(", "i", ")", ";", "mode", "=", "1", ";", "}", "else", "{", "wtoken", "=", "mOpeningApps", ".", "get", "(", "i", "-", "NC", ")", ";", "mode", "=", "2", ";", "}", "if", "(", "mLowerWallpaperTarget", "!=", "null", ")", "{", "if", "(", "mLowerWallpaperTarget", ".", "mAppToken", "==", "wtoken", "||", "mUpperWallpaperTarget", ".", "mAppToken", "==", "wtoken", ")", "{", "foundWallpapers", "|=", "mode", ";", "}", "}", "if", "(", "wtoken", ".", "appFullscreen", ")", "{", "WindowState", "ws", "=", "wtoken", ".", "findMainWindow", "(", ")", ";", "if", "(", "ws", "!=", "null", ")", "{", "animLp", "=", "ws", ".", "mAttrs", ";", "bestAnimLayer", "=", "ws", ".", "mLayer", ";", "fullscreenAnim", "=", "true", ";", "}", "}", "else", "if", "(", "!", "fullscreenAnim", ")", "{", "WindowState", "ws", "=", "wtoken", ".", "findMainWindow", "(", ")", ";", "if", "(", "ws", "!=", "null", ")", "{", "if", "(", "ws", ".", "mLayer", ">", "bestAnimLayer", ")", "{", "animLp", "=", "ws", ".", "mAttrs", ";", "bestAnimLayer", "=", "ws", ".", "mLayer", ";", "}", "}", "}", "}", "if", "(", "foundWallpapers", "==", "3", ")", "{", "if", "(", "DEBUG_APP_TRANSITIONS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "switch", "(", "transit", ")", "{", "case", "WindowManagerPolicy", ".", "TRANSIT_ACTIVITY_OPEN", ":", "case", "WindowManagerPolicy", ".", "TRANSIT_TASK_OPEN", ":", "case", "WindowManagerPolicy", ".", "TRANSIT_TASK_TO_FRONT", ":", "transit", "=", "WindowManagerPolicy", ".", "TRANSIT_WALLPAPER_INTRA_OPEN", ";", "break", ";", "case", "WindowManagerPolicy", ".", "TRANSIT_ACTIVITY_CLOSE", ":", "case", "WindowManagerPolicy", ".", "TRANSIT_TASK_CLOSE", ":", "case", "WindowManagerPolicy", ".", "TRANSIT_TASK_TO_BACK", ":", "transit", "=", "WindowManagerPolicy", ".", "TRANSIT_WALLPAPER_INTRA_CLOSE", ";", "break", ";", "}", "if", "(", "DEBUG_APP_TRANSITIONS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "transit", ")", ";", "}", "else", "if", "(", "oldWallpaper", "!=", "null", ")", "{", "transit", "=", "WindowManagerPolicy", ".", "TRANSIT_WALLPAPER_CLOSE", ";", "if", "(", "DEBUG_APP_TRANSITIONS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "transit", ")", ";", "}", "else", "if", "(", "mWallpaperTarget", "!=", "null", ")", "{", "transit", "=", "WindowManagerPolicy", ".", "TRANSIT_WALLPAPER_OPEN", ";", "if", "(", "DEBUG_APP_TRANSITIONS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "transit", ")", ";", "}", "if", "(", "!", "mPolicy", ".", "allowAppAnimationsLw", "(", ")", ")", "{", "animLp", "=", "null", ";", "}", "NN", "=", "mOpeningApps", ".", "size", "(", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "NN", ";", "i", "++", ")", "{", "AppWindowToken", "wtoken", "=", "mOpeningApps", ".", "get", "(", "i", ")", ";", "if", "(", "DEBUG_APP_TRANSITIONS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", ")", ";", "wtoken", ".", "reportedVisible", "=", "false", ";", "wtoken", ".", "inPendingTransaction", "=", "false", ";", "wtoken", ".", "animation", "=", "null", ";", "setTokenVisibilityLocked", "(", "wtoken", ",", "animLp", ",", "true", ",", "transit", ",", "false", ")", ";", "wtoken", ".", "updateReportedVisibilityLocked", "(", ")", ";", "wtoken", ".", "waitingToShow", "=", "false", ";", "wtoken", ".", "showAllWindowsLocked", "(", ")", ";", "}", "NN", "=", "mClosingApps", ".", "size", "(", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "NN", ";", "i", "++", ")", "{", "AppWindowToken", "wtoken", "=", "mClosingApps", ".", "get", "(", "i", ")", ";", "if", "(", "DEBUG_APP_TRANSITIONS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "wtoken", ")", ";", "wtoken", ".", "inPendingTransaction", "=", "false", ";", "wtoken", ".", "animation", "=", "null", ";", "setTokenVisibilityLocked", "(", "wtoken", ",", "animLp", ",", "false", ",", "transit", ",", "false", ")", ";", "wtoken", ".", "updateReportedVisibilityLocked", "(", ")", ";", "wtoken", ".", "waitingToHide", "=", "false", ";", "wtoken", ".", "allDrawn", "=", "true", ";", "}", "mNextAppTransitionPackage", "=", "null", ";", "mOpeningApps", ".", "clear", "(", ")", ";", "mClosingApps", ".", "clear", "(", ")", ";", "changes", "|=", "PhoneWindowManager", ".", "FINISH_LAYOUT_REDO_LAYOUT", "|", "WindowManagerPolicy", ".", "FINISH_LAYOUT_REDO_CONFIG", ";", "mLayoutNeeded", "=", "true", ";", "if", "(", "!", "moveInputMethodWindowsIfNeededLocked", "(", "true", ")", ")", "{", "assignLayersLocked", "(", ")", ";", "}", "updateFocusedWindowLocked", "(", "UPDATE_FOCUS_PLACING_SURFACES", ",", "false", ")", ";", "mFocusMayChange", "=", "false", ";", "}", "}", "int", "adjResult", "=", "0", ";", "if", "(", "!", "animating", "&&", "mAppTransitionRunning", ")", "{", "mAppTransitionRunning", "=", "false", ";", "mToBottomApps", ".", "clear", "(", ")", ";", "rebuildAppWindowListLocked", "(", ")", ";", "changes", "|=", "PhoneWindowManager", ".", "FINISH_LAYOUT_REDO_LAYOUT", ";", "adjResult", "|=", "ADJUST_WALLPAPER_LAYERS_CHANGED", ";", "moveInputMethodWindowsIfNeededLocked", "(", "false", ")", ";", "wallpaperMayChange", "=", "true", ";", "mFocusMayChange", "=", "true", ";", "}", "if", "(", "wallpaperForceHidingChanged", "&&", "changes", "==", "0", "&&", "!", "mAppTransitionReady", ")", "{", "WindowState", "oldWallpaper", "=", "mWallpaperTarget", ";", "if", "(", "mLowerWallpaperTarget", "!=", "null", "&&", "mLowerWallpaperTarget", ".", "mAppToken", "!=", "null", ")", "{", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "mLowerWallpaperTarget", ")", ";", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"hidden=\"", "+", "mLowerWallpaperTarget", ".", "mAppToken", ".", "hidden", "+", "\"\"", "+", "mLowerWallpaperTarget", ".", "mAppToken", ".", "hiddenRequested", ")", ";", "if", "(", "mLowerWallpaperTarget", ".", "mAppToken", ".", "hidden", ")", "{", "mLowerWallpaperTarget", "=", "mUpperWallpaperTarget", "=", "null", ";", "changes", "|=", "PhoneWindowManager", ".", "FINISH_LAYOUT_REDO_ANIM", ";", "}", "}", "adjResult", "|=", "adjustWallpaperWindowsLocked", "(", ")", ";", "wallpaperMayChange", "=", "false", ";", "wallpaperForceHidingChanged", "=", "false", ";", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"******", "OLD:", "\"", "+", "oldWallpaper", "+", "\"", "NEW:", "\"", "+", "mWallpaperTarget", "+", "\"", "LOWER:", "\"", "+", "mLowerWallpaperTarget", ")", ";", "if", "(", "mLowerWallpaperTarget", "==", "null", ")", "{", "forceHiding", "=", "false", ";", "for", "(", "i", "=", "N", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowState", "w", "=", "mWindows", ".", "get", "(", "i", ")", ";", "if", "(", "w", ".", "mSurface", "!=", "null", ")", "{", "final", "WindowManager", ".", "LayoutParams", "attrs", "=", "w", ".", "mAttrs", ";", "if", "(", "mPolicy", ".", "doesForceHide", "(", "w", ",", "attrs", ")", "&&", "w", ".", "isVisibleLw", "(", ")", ")", "{", "if", "(", "DEBUG_FOCUS", ")", "Slog", ".", "i", "(", "TAG", ",", "\"win=\"", "+", "w", "+", "\"\"", ")", ";", "forceHiding", "=", "true", ";", "}", "else", "if", "(", "mPolicy", ".", "canBeForceHidden", "(", "w", ",", "attrs", ")", ")", "{", "if", "(", "!", "w", ".", "mAnimating", ")", "{", "w", ".", "clearAnimation", "(", ")", ";", "}", "}", "}", "}", "}", "}", "if", "(", "mWindowDetachedWallpaper", "!=", "windowDetachedWallpaper", ")", "{", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "mWindowDetachedWallpaper", "+", "\"", "to", "\"", "+", "windowDetachedWallpaper", ")", ";", "mWindowDetachedWallpaper", "=", "windowDetachedWallpaper", ";", "wallpaperMayChange", "=", "true", ";", "}", "if", "(", "windowAnimationBackgroundColor", "!=", "0", ")", "{", "WindowState", "target", "=", "windowAnimationBackground", ";", "if", "(", "mWallpaperTarget", "==", "windowAnimationBackground", "||", "mLowerWallpaperTarget", "==", "windowAnimationBackground", "||", "mUpperWallpaperTarget", "==", "windowAnimationBackground", ")", "{", "for", "(", "i", "=", "0", ";", "i", "<", "mWindows", ".", "size", "(", ")", ";", "i", "++", ")", "{", "WindowState", "w", "=", "mWindows", ".", "get", "(", "i", ")", ";", "if", "(", "w", ".", "mIsWallpaper", ")", "{", "target", "=", "w", ";", "break", ";", "}", "}", "}", "if", "(", "mWindowAnimationBackgroundSurface", "==", "null", ")", "{", "mWindowAnimationBackgroundSurface", "=", "new", "DimSurface", "(", "mFxSession", ")", ";", "}", "mWindowAnimationBackgroundSurface", ".", "show", "(", "dw", ",", "dh", ",", "target", ".", "mAnimLayer", "-", "LAYER_OFFSET_DIM", ",", "windowAnimationBackgroundColor", ")", ";", "}", "else", "if", "(", "mWindowAnimationBackgroundSurface", "!=", "null", ")", "{", "mWindowAnimationBackgroundSurface", ".", "hide", "(", ")", ";", "}", "if", "(", "wallpaperMayChange", ")", "{", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "adjResult", "|=", "adjustWallpaperWindowsLocked", "(", ")", ";", "}", "if", "(", "(", "adjResult", "&", "ADJUST_WALLPAPER_LAYERS_CHANGED", ")", "!=", "0", ")", "{", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "changes", "|=", "PhoneWindowManager", ".", "FINISH_LAYOUT_REDO_LAYOUT", ";", "assignLayersLocked", "(", ")", ";", "}", "else", "if", "(", "(", "adjResult", "&", "ADJUST_WALLPAPER_VISIBILITY_CHANGED", ")", "!=", "0", ")", "{", "if", "(", "DEBUG_WALLPAPER", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "changes", "|=", "PhoneWindowManager", ".", "FINISH_LAYOUT_REDO_LAYOUT", ";", "}", "if", "(", "mFocusMayChange", ")", "{", "mFocusMayChange", "=", "false", ";", "if", "(", "updateFocusedWindowLocked", "(", "UPDATE_FOCUS_PLACING_SURFACES", ",", "false", ")", ")", "{", "changes", "|=", "PhoneWindowManager", ".", "FINISH_LAYOUT_REDO_ANIM", ";", "adjResult", "=", "0", ";", "}", "}", "if", "(", "mLayoutNeeded", ")", "{", "changes", "|=", "PhoneWindowManager", ".", "FINISH_LAYOUT_REDO_LAYOUT", ";", "}", "if", "(", "DEBUG_APP_TRANSITIONS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "Integer", ".", "toHexString", "(", "changes", ")", ")", ";", "}", "while", "(", "changes", "!=", "0", ")", ";", "final", "boolean", "someoneLosingFocus", "=", "mLosingFocus", ".", "size", "(", ")", "!=", "0", ";", "boolean", "obscured", "=", "false", ";", "boolean", "blurring", "=", "false", ";", "boolean", "dimming", "=", "false", ";", "boolean", "covered", "=", "false", ";", "boolean", "syswin", "=", "false", ";", "final", "int", "N", "=", "mWindows", ".", "size", "(", ")", ";", "for", "(", "i", "=", "N", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowState", "w", "=", "mWindows", ".", "get", "(", "i", ")", ";", "boolean", "displayed", "=", "false", ";", "final", "WindowManager", ".", "LayoutParams", "attrs", "=", "w", ".", "mAttrs", ";", "final", "int", "attrFlags", "=", "attrs", ".", "flags", ";", "if", "(", "w", ".", "mSurface", "!=", "null", ")", "{", "w", ".", "computeShownFrameLocked", "(", ")", ";", "if", "(", "localLOGV", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "i", "+", "\"", "\"", "+", "w", ".", "mSurface", "+", "\":", "new=\"", "+", "w", ".", "mShownFrame", ")", ";", "if", "(", "w", ".", "mSurface", "!=", "null", ")", "{", "int", "width", ",", "height", ";", "if", "(", "(", "w", ".", "mAttrs", ".", "flags", "&", "w", ".", "mAttrs", ".", "FLAG_SCALED", ")", "!=", "0", ")", "{", "width", "=", "w", ".", "mRequestedWidth", ";", "height", "=", "w", ".", "mRequestedHeight", ";", "}", "else", "{", "width", "=", "w", ".", "mCompatFrame", ".", "width", "(", ")", ";", "height", "=", "w", ".", "mCompatFrame", ".", "height", "(", ")", ";", "}", "if", "(", "width", "<", "1", ")", "{", "width", "=", "1", ";", "}", "if", "(", "height", "<", "1", ")", "{", "height", "=", "1", ";", "}", "final", "boolean", "surfaceResized", "=", "w", ".", "mSurfaceW", "!=", "width", "||", "w", ".", "mSurfaceH", "!=", "height", ";", "if", "(", "surfaceResized", ")", "{", "w", ".", "mSurfaceW", "=", "width", ";", "w", ".", "mSurfaceH", "=", "height", ";", "}", "if", "(", "w", ".", "mSurfaceX", "!=", "w", ".", "mShownFrame", ".", "left", "||", "w", ".", "mSurfaceY", "!=", "w", ".", "mShownFrame", ".", "top", ")", "{", "try", "{", "if", "(", "SHOW_TRANSACTIONS", ")", "logSurface", "(", "w", ",", "\"POS", "\"", "+", "w", ".", "mShownFrame", ".", "left", "+", "\",", "\"", "+", "w", ".", "mShownFrame", ".", "top", ",", "null", ")", ";", "w", ".", "mSurfaceX", "=", "w", ".", "mShownFrame", ".", "left", ";", "w", ".", "mSurfaceY", "=", "w", ".", "mShownFrame", ".", "top", ";", "w", ".", "mSurface", ".", "setPosition", "(", "w", ".", "mShownFrame", ".", "left", ",", "w", ".", "mShownFrame", ".", "top", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "w", "+", "\"", "pos=(\"", "+", "w", ".", "mShownFrame", ".", "left", "+", "\",\"", "+", "w", ".", "mShownFrame", ".", "top", "+", "\")\"", ",", "e", ")", ";", "if", "(", "!", "recoveringMemory", ")", "{", "reclaimSomeSurfaceMemoryLocked", "(", "w", ",", "\"position\"", ",", "true", ")", ";", "}", "}", "}", "if", "(", "surfaceResized", ")", "{", "try", "{", "if", "(", "SHOW_TRANSACTIONS", ")", "logSurface", "(", "w", ",", "\"SIZE", "\"", "+", "width", "+", "\"x\"", "+", "height", ",", "null", ")", ";", "w", ".", "mSurfaceResized", "=", "true", ";", "w", ".", "mSurface", ".", "setSize", "(", "width", ",", "height", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "Slog", ".", "e", "(", "TAG", ",", "\"\"", "+", "w", "+", "\"", "size=(\"", "+", "width", "+", "\"x\"", "+", "height", "+", "\")\"", ",", "e", ")", ";", "if", "(", "!", "recoveringMemory", ")", "{", "reclaimSomeSurfaceMemoryLocked", "(", "w", ",", "\"size\"", ",", "true", ")", ";", "}", "}", "}", "}", "if", "(", "!", "w", ".", "mAppFreezing", "&&", "w", ".", "mLayoutSeq", "==", "mLayoutSeq", ")", "{", "w", ".", "mContentInsetsChanged", "|=", "!", "w", ".", "mLastContentInsets", ".", "equals", "(", "w", ".", "mContentInsets", ")", ";", "w", ".", "mVisibleInsetsChanged", "|=", "!", "w", ".", "mLastVisibleInsets", ".", "equals", "(", "w", ".", "mVisibleInsets", ")", ";", "boolean", "configChanged", "=", "w", ".", "mConfiguration", "!=", "mCurConfiguration", "&&", "(", "w", ".", "mConfiguration", "==", "null", "||", "mCurConfiguration", ".", "diff", "(", "w", ".", "mConfiguration", ")", "!=", "0", ")", ";", "if", "(", "DEBUG_CONFIGURATION", "&&", "configChanged", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"Win", "\"", "+", "w", "+", "\"\"", "+", "mCurConfiguration", ")", ";", "}", "if", "(", "localLOGV", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Resizing", "\"", "+", "w", "+", "\"\"", "+", "configChanged", "+", "\"", "last=\"", "+", "w", ".", "mLastFrame", "+", "\"", "frame=\"", "+", "w", ".", "mFrame", ")", ";", "w", ".", "mLastFrame", ".", "set", "(", "w", ".", "mFrame", ")", ";", "if", "(", "w", ".", "mContentInsetsChanged", "||", "w", ".", "mVisibleInsetsChanged", "||", "w", ".", "mSurfaceResized", "||", "configChanged", ")", "{", "if", "(", "DEBUG_RESIZE", "||", "DEBUG_ORIENTATION", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "\"\"", "+", "w", ".", "mContentInsetsChanged", "+", "\"\"", "+", "w", ".", "mVisibleInsetsChanged", "+", "\"\"", "+", "w", ".", "mSurfaceResized", "+", "\"\"", "+", "configChanged", ")", ";", "}", "w", ".", "mLastContentInsets", ".", "set", "(", "w", ".", "mContentInsets", ")", ";", "w", ".", "mLastVisibleInsets", ".", "set", "(", "w", ".", "mVisibleInsets", ")", ";", "makeWindowFreezingScreenIfNeededLocked", "(", "w", ")", ";", "if", "(", "w", ".", "mOrientationChanging", ")", "{", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "w", "+", "\",", "surface", "\"", "+", "w", ".", "mSurface", ")", ";", "w", ".", "mDrawPending", "=", "true", ";", "w", ".", "mCommitDrawPending", "=", "false", ";", "w", ".", "mReadyToShow", "=", "false", ";", "if", "(", "w", ".", "mAppToken", "!=", "null", ")", "{", "w", ".", "mAppToken", ".", "allDrawn", "=", "false", ";", "}", "}", "if", "(", "!", "mResizingWindows", ".", "contains", "(", "w", ")", ")", "{", "if", "(", "DEBUG_RESIZE", "||", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "w", "+", "\"", "to", "\"", "+", "w", ".", "mSurfaceW", "+", "\"x\"", "+", "w", ".", "mSurfaceH", ")", ";", "mResizingWindows", ".", "add", "(", "w", ")", ";", "}", "}", "else", "if", "(", "w", ".", "mOrientationChanging", ")", "{", "if", "(", "!", "w", ".", "mDrawPending", "&&", "!", "w", ".", "mCommitDrawPending", ")", "{", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "w", "+", "\",", "surface", "\"", "+", "w", ".", "mSurface", ")", ";", "w", ".", "mOrientationChanging", "=", "false", ";", "}", "}", "}", "if", "(", "w", ".", "mAttachedHidden", "||", "!", "w", ".", "isReadyForDisplay", "(", ")", ")", "{", "if", "(", "!", "w", ".", "mLastHidden", ")", "{", "w", ".", "mLastHidden", "=", "true", ";", "if", "(", "SHOW_TRANSACTIONS", ")", "logSurface", "(", "w", ",", "\"\"", ",", "null", ")", ";", "if", "(", "w", ".", "mSurface", "!=", "null", ")", "{", "w", ".", "mSurfaceShown", "=", "false", ";", "try", "{", "w", ".", "mSurface", ".", "hide", "(", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "w", ")", ";", "}", "}", "}", "if", "(", "w", ".", "mOrientationChanging", ")", "{", "w", ".", "mOrientationChanging", "=", "false", ";", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "w", ")", ";", "}", "}", "else", "if", "(", "w", ".", "mLastLayer", "!=", "w", ".", "mAnimLayer", "||", "w", ".", "mLastAlpha", "!=", "w", ".", "mShownAlpha", "||", "w", ".", "mLastDsDx", "!=", "w", ".", "mDsDx", "||", "w", ".", "mLastDtDx", "!=", "w", ".", "mDtDx", "||", "w", ".", "mLastDsDy", "!=", "w", ".", "mDsDy", "||", "w", ".", "mLastDtDy", "!=", "w", ".", "mDtDy", "||", "w", ".", "mLastHScale", "!=", "w", ".", "mHScale", "||", "w", ".", "mLastVScale", "!=", "w", ".", "mVScale", "||", "w", ".", "mLastHidden", ")", "{", "displayed", "=", "true", ";", "w", ".", "mLastAlpha", "=", "w", ".", "mShownAlpha", ";", "w", ".", "mLastLayer", "=", "w", ".", "mAnimLayer", ";", "w", ".", "mLastDsDx", "=", "w", ".", "mDsDx", ";", "w", ".", "mLastDtDx", "=", "w", ".", "mDtDx", ";", "w", ".", "mLastDsDy", "=", "w", ".", "mDsDy", ";", "w", ".", "mLastDtDy", "=", "w", ".", "mDtDy", ";", "w", ".", "mLastHScale", "=", "w", ".", "mHScale", ";", "w", ".", "mLastVScale", "=", "w", ".", "mVScale", ";", "if", "(", "SHOW_TRANSACTIONS", ")", "logSurface", "(", "w", ",", "\"alpha=\"", "+", "w", ".", "mShownAlpha", "+", "\"", "layer=\"", "+", "w", ".", "mAnimLayer", "+", "\"", "matrix=[\"", "+", "(", "w", ".", "mDsDx", "*", "w", ".", "mHScale", ")", "+", "\",\"", "+", "(", "w", ".", "mDtDx", "*", "w", ".", "mVScale", ")", "+", "\"][\"", "+", "(", "w", ".", "mDsDy", "*", "w", ".", "mHScale", ")", "+", "\",\"", "+", "(", "w", ".", "mDtDy", "*", "w", ".", "mVScale", ")", "+", "\"]\"", ",", "null", ")", ";", "if", "(", "w", ".", "mSurface", "!=", "null", ")", "{", "try", "{", "w", ".", "mSurfaceAlpha", "=", "w", ".", "mShownAlpha", ";", "w", ".", "mSurface", ".", "setAlpha", "(", "w", ".", "mShownAlpha", ")", ";", "w", ".", "mSurfaceLayer", "=", "w", ".", "mAnimLayer", ";", "w", ".", "mSurface", ".", "setLayer", "(", "w", ".", "mAnimLayer", ")", ";", "w", ".", "mSurface", ".", "setMatrix", "(", "w", ".", "mDsDx", "*", "w", ".", "mHScale", ",", "w", ".", "mDtDx", "*", "w", ".", "mVScale", ",", "w", ".", "mDsDy", "*", "w", ".", "mHScale", ",", "w", ".", "mDtDy", "*", "w", ".", "mVScale", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "w", ",", "e", ")", ";", "if", "(", "!", "recoveringMemory", ")", "{", "reclaimSomeSurfaceMemoryLocked", "(", "w", ",", "\"update\"", ",", "true", ")", ";", "}", "}", "}", "if", "(", "w", ".", "mLastHidden", "&&", "!", "w", ".", "mDrawPending", "&&", "!", "w", ".", "mCommitDrawPending", "&&", "!", "w", ".", "mReadyToShow", ")", "{", "if", "(", "SHOW_TRANSACTIONS", ")", "logSurface", "(", "w", ",", "\"\"", ",", "null", ")", ";", "if", "(", "DEBUG_VISIBILITY", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Showing", "\"", "+", "w", "+", "\"\"", ")", ";", "if", "(", "showSurfaceRobustlyLocked", "(", "w", ")", ")", "{", "w", ".", "mHasDrawn", "=", "true", ";", "w", ".", "mLastHidden", "=", "false", ";", "}", "else", "{", "w", ".", "mOrientationChanging", "=", "false", ";", "}", "}", "if", "(", "w", ".", "mSurface", "!=", "null", ")", "{", "w", ".", "mToken", ".", "hasVisible", "=", "true", ";", "}", "}", "else", "{", "displayed", "=", "true", ";", "}", "if", "(", "displayed", ")", "{", "if", "(", "!", "covered", ")", "{", "if", "(", "attrs", ".", "width", "==", "LayoutParams", ".", "MATCH_PARENT", "&&", "attrs", ".", "height", "==", "LayoutParams", ".", "MATCH_PARENT", ")", "{", "covered", "=", "true", ";", "}", "}", "if", "(", "w", ".", "mOrientationChanging", ")", "{", "if", "(", "w", ".", "mDrawPending", "||", "w", ".", "mCommitDrawPending", ")", "{", "orientationChangeComplete", "=", "false", ";", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "w", ")", ";", "}", "else", "{", "w", ".", "mOrientationChanging", "=", "false", ";", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "w", ")", ";", "}", "}", "w", ".", "mToken", ".", "hasVisible", "=", "true", ";", "}", "}", "else", "if", "(", "w", ".", "mOrientationChanging", ")", "{", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "w", ")", ";", "w", ".", "mOrientationChanging", "=", "false", ";", "}", "if", "(", "w", ".", "mContentChanged", ")", "{", "w", ".", "mContentChanged", "=", "false", ";", "}", "final", "boolean", "canBeSeen", "=", "w", ".", "isDisplayedLw", "(", ")", ";", "if", "(", "someoneLosingFocus", "&&", "w", "==", "mCurrentFocus", "&&", "canBeSeen", ")", "{", "focusDisplayed", "=", "true", ";", "}", "final", "boolean", "obscuredChanged", "=", "w", ".", "mObscured", "!=", "obscured", ";", "if", "(", "!", "(", "w", ".", "mObscured", "=", "obscured", ")", ")", "{", "if", "(", "w", ".", "mSurface", "!=", "null", ")", "{", "if", "(", "(", "attrFlags", "&", "FLAG_KEEP_SCREEN_ON", ")", "!=", "0", ")", "{", "holdScreen", "=", "w", ".", "mSession", ";", "}", "if", "(", "!", "syswin", "&&", "w", ".", "mAttrs", ".", "screenBrightness", ">=", "0", "&&", "screenBrightness", "<", "0", ")", "{", "screenBrightness", "=", "w", ".", "mAttrs", ".", "screenBrightness", ";", "}", "if", "(", "!", "syswin", "&&", "w", ".", "mAttrs", ".", "buttonBrightness", ">=", "0", "&&", "buttonBrightness", "<", "0", ")", "{", "buttonBrightness", "=", "w", ".", "mAttrs", ".", "buttonBrightness", ";", "}", "if", "(", "canBeSeen", "&&", "(", "attrs", ".", "type", "==", "WindowManager", ".", "LayoutParams", ".", "TYPE_SYSTEM_DIALOG", "||", "attrs", ".", "type", "==", "WindowManager", ".", "LayoutParams", ".", "TYPE_KEYGUARD", "||", "attrs", ".", "type", "==", "WindowManager", ".", "LayoutParams", ".", "TYPE_SYSTEM_ERROR", ")", ")", "{", "syswin", "=", "true", ";", "}", "}", "boolean", "opaqueDrawn", "=", "canBeSeen", "&&", "w", ".", "isOpaqueDrawn", "(", ")", ";", "if", "(", "opaqueDrawn", "&&", "w", ".", "isFullscreen", "(", "innerDw", ",", "innerDh", ")", ")", "{", "obscured", "=", "true", ";", "}", "else", "if", "(", "canBeSeen", "&&", "!", "obscured", "&&", "(", "attrFlags", "&", "FLAG_BLUR_BEHIND", "|", "FLAG_DIM_BEHIND", ")", "!=", "0", ")", "{", "if", "(", "localLOGV", ")", "Slog", ".", "v", "(", "TAG", ",", "\"Win", "\"", "+", "w", "+", "\":", "blurring=\"", "+", "blurring", "+", "\"", "obscured=\"", "+", "obscured", "+", "\"", "displayed=\"", "+", "displayed", ")", ";", "if", "(", "(", "attrFlags", "&", "FLAG_DIM_BEHIND", ")", "!=", "0", ")", "{", "if", "(", "!", "dimming", ")", "{", "dimming", "=", "true", ";", "if", "(", "mDimAnimator", "==", "null", ")", "{", "mDimAnimator", "=", "new", "DimAnimator", "(", "mFxSession", ")", ";", "}", "if", "(", "attrs", ".", "type", "==", "WindowManager", ".", "LayoutParams", ".", "TYPE_BOOT_PROGRESS", ")", "{", "mDimAnimator", ".", "show", "(", "dw", ",", "dh", ")", ";", "}", "else", "{", "mDimAnimator", ".", "show", "(", "innerDw", ",", "innerDh", ")", ";", "}", "mDimAnimator", ".", "updateParameters", "(", "mContext", ".", "getResources", "(", ")", ",", "w", ",", "currentTime", ")", ";", "}", "}", "if", "(", "(", "attrFlags", "&", "FLAG_BLUR_BEHIND", ")", "!=", "0", ")", "{", "if", "(", "!", "blurring", ")", "{", "blurring", "=", "true", ";", "if", "(", "mBlurSurface", "==", "null", ")", "{", "try", "{", "mBlurSurface", "=", "new", "Surface", "(", "mFxSession", ",", "0", ",", "\"BlurSurface\"", ",", "-", "1", ",", "16", ",", "16", ",", "PixelFormat", ".", "OPAQUE", ",", "Surface", ".", "FX_SURFACE_BLUR", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "Slog", ".", "e", "(", "TAG", ",", "\"\"", ",", "e", ")", ";", "}", "if", "(", "SHOW_TRANSACTIONS", ")", "Slog", ".", "i", "(", "TAG", ",", "\"", "BLUR", "\"", "+", "mBlurSurface", "+", "\":", "CREATE\"", ")", ";", "}", "if", "(", "mBlurSurface", "!=", "null", ")", "{", "if", "(", "SHOW_TRANSACTIONS", ")", "Slog", ".", "i", "(", "TAG", ",", "\"", "BLUR", "\"", "+", "mBlurSurface", "+", "\"\"", "+", "dw", "+", "\"x\"", "+", "dh", "+", "\"),", "layer=\"", "+", "(", "w", ".", "mAnimLayer", "-", "1", ")", ")", ";", "mBlurSurface", ".", "setPosition", "(", "0", ",", "0", ")", ";", "mBlurSurface", ".", "setSize", "(", "dw", ",", "dh", ")", ";", "mBlurSurface", ".", "setLayer", "(", "w", ".", "mAnimLayer", "-", "LAYER_OFFSET_BLUR", ")", ";", "if", "(", "!", "mBlurShown", ")", "{", "try", "{", "if", "(", "SHOW_TRANSACTIONS", ")", "Slog", ".", "i", "(", "TAG", ",", "\"", "BLUR", "\"", "+", "mBlurSurface", "+", "\":", "SHOW\"", ")", ";", "mBlurSurface", ".", "show", "(", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ",", "e", ")", ";", "}", "mBlurShown", "=", "true", ";", "}", "}", "}", "}", "}", "}", "if", "(", "obscuredChanged", "&&", "mWallpaperTarget", "==", "w", ")", "{", "updateWallpaperVisibilityLocked", "(", ")", ";", "}", "}", "if", "(", "mDimAnimator", "!=", "null", "&&", "mDimAnimator", ".", "mDimShown", ")", "{", "animating", "|=", "mDimAnimator", ".", "updateSurface", "(", "dimming", ",", "currentTime", ",", "mDisplayFrozen", "||", "!", "mDisplayEnabled", "||", "!", "mPolicy", ".", "isScreenOnFully", "(", ")", ")", ";", "}", "if", "(", "!", "blurring", "&&", "mBlurShown", ")", "{", "if", "(", "SHOW_TRANSACTIONS", ")", "Slog", ".", "i", "(", "TAG", ",", "\"", "BLUR", "\"", "+", "mBlurSurface", "+", "\":", "HIDE\"", ")", ";", "try", "{", "mBlurSurface", ".", "hide", "(", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "}", "mBlurShown", "=", "false", ";", "}", "if", "(", "mBlackFrame", "!=", "null", ")", "{", "if", "(", "mScreenRotationAnimation", "!=", "null", ")", "{", "mBlackFrame", ".", "setMatrix", "(", "mScreenRotationAnimation", ".", "getEnterTransformation", "(", ")", ".", "getMatrix", "(", ")", ")", ";", "}", "else", "{", "mBlackFrame", ".", "clearMatrix", "(", ")", ";", "}", "}", "}", "catch", "(", "RuntimeException", "e", ")", "{", "Log", ".", "wtf", "(", "TAG", ",", "\"\"", ",", "e", ")", ";", "}", "Surface", ".", "closeTransaction", "(", ")", ";", "if", "(", "SHOW_LIGHT_TRANSACTIONS", ")", "Slog", ".", "i", "(", "TAG", ",", "\"\"", ")", ";", "if", "(", "mWatermark", "!=", "null", ")", "{", "mWatermark", ".", "drawIfNeeded", "(", ")", ";", "}", "if", "(", "DEBUG_ORIENTATION", "&&", "mDisplayFrozen", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "orientationChangeComplete", ")", ";", "if", "(", "orientationChangeComplete", ")", "{", "if", "(", "mWindowsFreezingScreen", ")", "{", "mWindowsFreezingScreen", "=", "false", ";", "mH", ".", "removeMessages", "(", "H", ".", "WINDOW_FREEZE_TIMEOUT", ")", ";", "}", "stopFreezingDisplayLocked", "(", ")", ";", "}", "i", "=", "mResizingWindows", ".", "size", "(", ")", ";", "if", "(", "i", ">", "0", ")", "{", "do", "{", "i", "--", ";", "WindowState", "win", "=", "mResizingWindows", ".", "get", "(", "i", ")", ";", "try", "{", "if", "(", "DEBUG_RESIZE", "||", "DEBUG_ORIENTATION", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "win", "+", "\":", "\"", "+", "win", ".", "mCompatFrame", ")", ";", "int", "diff", "=", "0", ";", "boolean", "configChanged", "=", "win", ".", "mConfiguration", "!=", "mCurConfiguration", "&&", "(", "win", ".", "mConfiguration", "==", "null", "||", "(", "diff", "=", "mCurConfiguration", ".", "diff", "(", "win", ".", "mConfiguration", ")", ")", "!=", "0", ")", ";", "if", "(", "(", "DEBUG_RESIZE", "||", "DEBUG_ORIENTATION", "||", "DEBUG_CONFIGURATION", ")", "&&", "configChanged", ")", "{", "Slog", ".", "i", "(", "TAG", ",", "\"\"", "+", "win", "+", "\":", "\"", "+", "win", ".", "mSurfaceW", "+", "\"x\"", "+", "win", ".", "mSurfaceH", "+", "\"", "/", "\"", "+", "mCurConfiguration", "+", "\"", "/", "0x\"", "+", "Integer", ".", "toHexString", "(", "diff", ")", ")", ";", "}", "win", ".", "mConfiguration", "=", "mCurConfiguration", ";", "if", "(", "DEBUG_ORIENTATION", "&&", "win", ".", "mDrawPending", ")", "Slog", ".", "i", "(", "TAG", ",", "\"Resizing", "\"", "+", "win", "+", "\"\"", ")", ";", "win", ".", "mClient", ".", "resized", "(", "(", "int", ")", "win", ".", "mSurfaceW", ",", "(", "int", ")", "win", ".", "mSurfaceH", ",", "win", ".", "mLastContentInsets", ",", "win", ".", "mLastVisibleInsets", ",", "win", ".", "mDrawPending", ",", "configChanged", "?", "win", ".", "mConfiguration", ":", "null", ")", ";", "win", ".", "mContentInsetsChanged", "=", "false", ";", "win", ".", "mVisibleInsetsChanged", "=", "false", ";", "win", ".", "mSurfaceResized", "=", "false", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "win", ".", "mOrientationChanging", "=", "false", ";", "}", "}", "while", "(", "i", ">", "0", ")", ";", "mResizingWindows", ".", "clear", "(", ")", ";", "}", "boolean", "wallpaperDestroyed", "=", "false", ";", "i", "=", "mDestroySurface", ".", "size", "(", ")", ";", "if", "(", "i", ">", "0", ")", "{", "do", "{", "i", "--", ";", "WindowState", "win", "=", "mDestroySurface", ".", "get", "(", "i", ")", ";", "win", ".", "mDestroying", "=", "false", ";", "if", "(", "mInputMethodWindow", "==", "win", ")", "{", "mInputMethodWindow", "=", "null", ";", "}", "if", "(", "win", "==", "mWallpaperTarget", ")", "{", "wallpaperDestroyed", "=", "true", ";", "}", "win", ".", "destroySurfaceLocked", "(", ")", ";", "}", "while", "(", "i", ">", "0", ")", ";", "mDestroySurface", ".", "clear", "(", ")", ";", "}", "for", "(", "i", "=", "mExitingTokens", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowToken", "token", "=", "mExitingTokens", ".", "get", "(", "i", ")", ";", "if", "(", "!", "token", ".", "hasVisible", ")", "{", "mExitingTokens", ".", "remove", "(", "i", ")", ";", "if", "(", "token", ".", "windowType", "==", "TYPE_WALLPAPER", ")", "{", "mWallpaperTokens", ".", "remove", "(", "token", ")", ";", "}", "}", "}", "for", "(", "i", "=", "mExitingAppTokens", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "AppWindowToken", "token", "=", "mExitingAppTokens", ".", "get", "(", "i", ")", ";", "if", "(", "!", "token", ".", "hasVisible", "&&", "!", "mClosingApps", ".", "contains", "(", "token", ")", ")", "{", "token", ".", "animation", "=", "null", ";", "token", ".", "animating", "=", "false", ";", "if", "(", "DEBUG_ADD_REMOVE", "||", "DEBUG_TOKEN_MOVEMENT", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "token", ")", ";", "mAppTokens", ".", "remove", "(", "token", ")", ";", "mExitingAppTokens", ".", "remove", "(", "i", ")", ";", "}", "}", "boolean", "needRelayout", "=", "false", ";", "if", "(", "!", "animating", "&&", "mAppTransitionRunning", ")", "{", "mAppTransitionRunning", "=", "false", ";", "needRelayout", "=", "true", ";", "rebuildAppWindowListLocked", "(", ")", ";", "assignLayersLocked", "(", ")", ";", "mToBottomApps", ".", "clear", "(", ")", ";", "}", "if", "(", "focusDisplayed", ")", "{", "mH", ".", "sendEmptyMessage", "(", "H", ".", "REPORT_LOSING_FOCUS", ")", ";", "}", "if", "(", "wallpaperDestroyed", ")", "{", "needRelayout", "=", "adjustWallpaperWindowsLocked", "(", ")", "!=", "0", ";", "}", "if", "(", "needRelayout", ")", "{", "requestAnimationLocked", "(", "0", ")", ";", "}", "else", "if", "(", "animating", ")", "{", "final", "int", "refreshTimeUs", "=", "(", "int", ")", "(", "1000", "/", "mDisplay", ".", "getRefreshRate", "(", ")", ")", ";", "requestAnimationLocked", "(", "currentTime", "+", "refreshTimeUs", "-", "SystemClock", ".", "uptimeMillis", "(", ")", ")", ";", "}", "mInputMonitor", ".", "updateInputWindowsLw", "(", "true", ")", ";", "setHoldScreenLocked", "(", "holdScreen", "!=", "null", ")", ";", "if", "(", "!", "mDisplayFrozen", ")", "{", "if", "(", "screenBrightness", "<", "0", "||", "screenBrightness", ">", "1.0f", ")", "{", "mPowerManager", ".", "setScreenBrightnessOverride", "(", "-", "1", ")", ";", "}", "else", "{", "mPowerManager", ".", "setScreenBrightnessOverride", "(", "(", "int", ")", "(", "screenBrightness", "*", "Power", ".", "BRIGHTNESS_ON", ")", ")", ";", "}", "if", "(", "buttonBrightness", "<", "0", "||", "buttonBrightness", ">", "1.0f", ")", "{", "mPowerManager", ".", "setButtonBrightnessOverride", "(", "-", "1", ")", ";", "}", "else", "{", "mPowerManager", ".", "setButtonBrightnessOverride", "(", "(", "int", ")", "(", "buttonBrightness", "*", "Power", ".", "BRIGHTNESS_ON", ")", ")", ";", "}", "}", "if", "(", "holdScreen", "!=", "mHoldingScreenOn", ")", "{", "mHoldingScreenOn", "=", "holdScreen", ";", "Message", "m", "=", "mH", ".", "obtainMessage", "(", "H", ".", "HOLD_SCREEN_CHANGED", ",", "holdScreen", ")", ";", "mH", ".", "sendMessage", "(", "m", ")", ";", "}", "if", "(", "mTurnOnScreen", ")", "{", "if", "(", "DEBUG_VISIBILITY", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "mPowerManager", ".", "userActivity", "(", "SystemClock", ".", "uptimeMillis", "(", ")", ",", "false", ",", "LocalPowerManager", ".", "BUTTON_EVENT", ",", "true", ")", ";", "mTurnOnScreen", "=", "false", ";", "}", "if", "(", "screenRotationFinished", "&&", "mScreenRotationAnimation", "!=", "null", ")", "{", "mScreenRotationAnimation", ".", "kill", "(", ")", ";", "mScreenRotationAnimation", "=", "null", ";", "}", "if", "(", "updateRotation", ")", "{", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "d", "(", "TAG", ",", "\"\"", ")", ";", "boolean", "changed", "=", "updateRotationUncheckedLocked", "(", "false", ")", ";", "if", "(", "changed", ")", "{", "mH", ".", "sendEmptyMessage", "(", "H", ".", "SEND_NEW_CONFIGURATION", ")", ";", "}", "else", "{", "updateRotation", "=", "false", ";", "}", "}", "if", "(", "orientationChangeComplete", "&&", "!", "needRelayout", "&&", "!", "updateRotation", ")", "{", "checkDrawnWindowsLocked", "(", ")", ";", "}", "enableScreenIfNeededLocked", "(", ")", ";", "}", "void", "checkDrawnWindowsLocked", "(", ")", "{", "if", "(", "mWaitingForDrawn", ".", "size", "(", ")", ">", "0", ")", "{", "for", "(", "int", "j", "=", "mWaitingForDrawn", ".", "size", "(", ")", "-", "1", ";", "j", ">=", "0", ";", "j", "--", ")", "{", "Pair", "<", "WindowState", ",", "IRemoteCallback", ">", "pair", "=", "mWaitingForDrawn", ".", "get", "(", "j", ")", ";", "WindowState", "win", "=", "pair", ".", "first", ";", "if", "(", "win", ".", "mRemoved", "||", "!", "win", ".", "isVisibleLw", "(", ")", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "pair", ".", "first", ")", ";", "try", "{", "pair", ".", "second", ".", "sendResult", "(", "null", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "mWaitingForDrawn", ".", "remove", "(", "pair", ")", ";", "mH", ".", "removeMessages", "(", "H", ".", "WAITING_FOR_DRAWN_TIMEOUT", ",", "pair", ")", ";", "}", "else", "if", "(", "win", ".", "mSurfaceShown", ")", "{", "try", "{", "pair", ".", "second", ".", "sendResult", "(", "null", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "mWaitingForDrawn", ".", "remove", "(", "pair", ")", ";", "mH", ".", "removeMessages", "(", "H", ".", "WAITING_FOR_DRAWN_TIMEOUT", ",", "pair", ")", ";", "}", "}", "}", "}", "public", "void", "waitForWindowDrawn", "(", "IBinder", "token", ",", "IRemoteCallback", "callback", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "WindowState", "win", "=", "windowForClientLocked", "(", "null", ",", "token", ",", "true", ")", ";", "if", "(", "win", "!=", "null", ")", "{", "Pair", "<", "WindowState", ",", "IRemoteCallback", ">", "pair", "=", "new", "Pair", "<", "WindowState", ",", "IRemoteCallback", ">", "(", "win", ",", "callback", ")", ";", "Message", "m", "=", "mH", ".", "obtainMessage", "(", "H", ".", "WAITING_FOR_DRAWN_TIMEOUT", ",", "pair", ")", ";", "mH", ".", "sendMessageDelayed", "(", "m", ",", "2000", ")", ";", "mWaitingForDrawn", ".", "add", "(", "pair", ")", ";", "checkDrawnWindowsLocked", "(", ")", ";", "}", "}", "}", "void", "setHoldScreenLocked", "(", "boolean", "holding", ")", "{", "boolean", "state", "=", "mHoldingScreenWakeLock", ".", "isHeld", "(", ")", ";", "if", "(", "holding", "!=", "state", ")", "{", "if", "(", "holding", ")", "{", "mPolicy", ".", "screenOnStartedLw", "(", ")", ";", "mHoldingScreenWakeLock", ".", "acquire", "(", ")", ";", "}", "else", "{", "mPolicy", ".", "screenOnStoppedLw", "(", ")", ";", "mHoldingScreenWakeLock", ".", "release", "(", ")", ";", "}", "}", "}", "void", "requestAnimationLocked", "(", "long", "delay", ")", "{", "if", "(", "!", "mAnimationPending", ")", "{", "mAnimationPending", "=", "true", ";", "mH", ".", "sendMessageDelayed", "(", "mH", ".", "obtainMessage", "(", "H", ".", "ANIMATE", ")", ",", "delay", ")", ";", "}", "}", "boolean", "showSurfaceRobustlyLocked", "(", "WindowState", "win", ")", "{", "try", "{", "if", "(", "win", ".", "mSurface", "!=", "null", ")", "{", "win", ".", "mSurfaceShown", "=", "true", ";", "win", ".", "mSurface", ".", "show", "(", ")", ";", "if", "(", "win", ".", "mTurnOnScreen", ")", "{", "if", "(", "DEBUG_VISIBILITY", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "win", ")", ";", "win", ".", "mTurnOnScreen", "=", "false", ";", "mTurnOnScreen", "=", "true", ";", "}", "}", "return", "true", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "win", ".", "mSurface", "+", "\"", "in", "\"", "+", "win", ",", "e", ")", ";", "}", "reclaimSomeSurfaceMemoryLocked", "(", "win", ",", "\"show\"", ",", "true", ")", ";", "return", "false", ";", "}", "boolean", "reclaimSomeSurfaceMemoryLocked", "(", "WindowState", "win", ",", "String", "operation", ",", "boolean", "secure", ")", "{", "final", "Surface", "surface", "=", "win", ".", "mSurface", ";", "boolean", "leakedSurface", "=", "false", ";", "boolean", "killedApps", "=", "false", ";", "EventLog", ".", "writeEvent", "(", "EventLogTags", ".", "WM_NO_SURFACE_MEMORY", ",", "win", ".", "toString", "(", ")", ",", "win", ".", "mSession", ".", "mPid", ",", "operation", ")", ";", "if", "(", "mForceRemoves", "==", "null", ")", "{", "mForceRemoves", "=", "new", "ArrayList", "<", "WindowState", ">", "(", ")", ";", "}", "long", "callingIdentity", "=", "Binder", ".", "clearCallingIdentity", "(", ")", ";", "try", "{", "int", "N", "=", "mWindows", ".", "size", "(", ")", ";", "Slog", ".", "i", "(", "TAG", ",", "\"\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "WindowState", "ws", "=", "mWindows", ".", "get", "(", "i", ")", ";", "if", "(", "ws", ".", "mSurface", "!=", "null", ")", "{", "if", "(", "!", "mSessions", ".", "contains", "(", "ws", ".", "mSession", ")", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "ws", "+", "\"", "surface=\"", "+", "ws", ".", "mSurface", "+", "\"", "token=\"", "+", "win", ".", "mToken", "+", "\"", "pid=\"", "+", "ws", ".", "mSession", ".", "mPid", "+", "\"", "uid=\"", "+", "ws", ".", "mSession", ".", "mUid", ")", ";", "if", "(", "SHOW_TRANSACTIONS", ")", "logSurface", "(", "ws", ",", "\"LEAK", "DESTROY\"", ",", "null", ")", ";", "ws", ".", "mSurface", ".", "destroy", "(", ")", ";", "ws", ".", "mSurfaceShown", "=", "false", ";", "ws", ".", "mSurface", "=", "null", ";", "mForceRemoves", ".", "add", "(", "ws", ")", ";", "i", "--", ";", "N", "--", ";", "leakedSurface", "=", "true", ";", "}", "else", "if", "(", "ws", ".", "mAppToken", "!=", "null", "&&", "ws", ".", "mAppToken", ".", "clientHidden", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "ws", "+", "\"", "surface=\"", "+", "ws", ".", "mSurface", "+", "\"", "token=\"", "+", "win", ".", "mAppToken", ")", ";", "if", "(", "SHOW_TRANSACTIONS", ")", "logSurface", "(", "ws", ",", "\"LEAK", "DESTROY\"", ",", "null", ")", ";", "ws", ".", "mSurface", ".", "destroy", "(", ")", ";", "ws", ".", "mSurfaceShown", "=", "false", ";", "ws", ".", "mSurface", "=", "null", ";", "leakedSurface", "=", "true", ";", "}", "}", "}", "if", "(", "!", "leakedSurface", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "SparseIntArray", "pidCandidates", "=", "new", "SparseIntArray", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "WindowState", "ws", "=", "mWindows", ".", "get", "(", "i", ")", ";", "if", "(", "ws", ".", "mSurface", "!=", "null", ")", "{", "pidCandidates", ".", "append", "(", "ws", ".", "mSession", ".", "mPid", ",", "ws", ".", "mSession", ".", "mPid", ")", ";", "}", "}", "if", "(", "pidCandidates", ".", "size", "(", ")", ">", "0", ")", "{", "int", "[", "]", "pids", "=", "new", "int", "[", "pidCandidates", ".", "size", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "pids", ".", "length", ";", "i", "++", ")", "{", "pids", "[", "i", "]", "=", "pidCandidates", ".", "keyAt", "(", "i", ")", ";", "}", "try", "{", "if", "(", "mActivityManager", ".", "killPids", "(", "pids", ",", "\"Free", "memory\"", ",", "secure", ")", ")", "{", "killedApps", "=", "true", ";", "}", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "}", "if", "(", "leakedSurface", "||", "killedApps", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "if", "(", "surface", "!=", "null", ")", "{", "if", "(", "SHOW_TRANSACTIONS", "||", "SHOW_SURFACE_ALLOC", ")", "logSurface", "(", "win", ",", "\"\"", ",", "null", ")", ";", "surface", ".", "destroy", "(", ")", ";", "win", ".", "mSurfaceShown", "=", "false", ";", "win", ".", "mSurface", "=", "null", ";", "}", "try", "{", "win", ".", "mClient", ".", "dispatchGetNewSurface", "(", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "}", "finally", "{", "Binder", ".", "restoreCallingIdentity", "(", "callingIdentity", ")", ";", "}", "return", "leakedSurface", "||", "killedApps", ";", "}", "private", "boolean", "updateFocusedWindowLocked", "(", "int", "mode", ",", "boolean", "updateInputWindows", ")", "{", "WindowState", "newFocus", "=", "computeFocusedWindowLocked", "(", ")", ";", "if", "(", "mCurrentFocus", "!=", "newFocus", ")", "{", "mH", ".", "removeMessages", "(", "H", ".", "REPORT_FOCUS_CHANGE", ")", ";", "mH", ".", "sendEmptyMessage", "(", "H", ".", "REPORT_FOCUS_CHANGE", ")", ";", "if", "(", "localLOGV", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "mCurrentFocus", "+", "\"", "to", "\"", "+", "newFocus", ")", ";", "final", "WindowState", "oldFocus", "=", "mCurrentFocus", ";", "mCurrentFocus", "=", "newFocus", ";", "mLosingFocus", ".", "remove", "(", "newFocus", ")", ";", "int", "focusChanged", "=", "mPolicy", ".", "focusChangedLw", "(", "oldFocus", ",", "newFocus", ")", ";", "final", "WindowState", "imWindow", "=", "mInputMethodWindow", ";", "if", "(", "newFocus", "!=", "imWindow", "&&", "oldFocus", "!=", "imWindow", ")", "{", "if", "(", "moveInputMethodWindowsIfNeededLocked", "(", "mode", "!=", "UPDATE_FOCUS_WILL_ASSIGN_LAYERS", "&&", "mode", "!=", "UPDATE_FOCUS_WILL_PLACE_SURFACES", ")", ")", "{", "mLayoutNeeded", "=", "true", ";", "}", "if", "(", "mode", "==", "UPDATE_FOCUS_PLACING_SURFACES", ")", "{", "performLayoutLockedInner", "(", "true", ",", "updateInputWindows", ")", ";", "focusChanged", "&=", "~", "WindowManagerPolicy", ".", "FINISH_LAYOUT_REDO_LAYOUT", ";", "}", "else", "if", "(", "mode", "==", "UPDATE_FOCUS_WILL_PLACE_SURFACES", ")", "{", "assignLayersLocked", "(", ")", ";", "}", "}", "if", "(", "(", "focusChanged", "&", "WindowManagerPolicy", ".", "FINISH_LAYOUT_REDO_LAYOUT", ")", "!=", "0", ")", "{", "mLayoutNeeded", "=", "true", ";", "if", "(", "mode", "==", "UPDATE_FOCUS_PLACING_SURFACES", ")", "{", "performLayoutLockedInner", "(", "true", ",", "updateInputWindows", ")", ";", "}", "}", "if", "(", "mode", "!=", "UPDATE_FOCUS_WILL_ASSIGN_LAYERS", ")", "{", "finishUpdateFocusedWindowAfterAssignLayersLocked", "(", "updateInputWindows", ")", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}", "private", "void", "finishUpdateFocusedWindowAfterAssignLayersLocked", "(", "boolean", "updateInputWindows", ")", "{", "mInputMonitor", ".", "setInputFocusLw", "(", "mCurrentFocus", ",", "updateInputWindows", ")", ";", "}", "private", "WindowState", "computeFocusedWindowLocked", "(", ")", "{", "WindowState", "result", "=", "null", ";", "WindowState", "win", ";", "int", "i", "=", "mWindows", ".", "size", "(", ")", "-", "1", ";", "int", "nextAppIndex", "=", "mAppTokens", ".", "size", "(", ")", "-", "1", ";", "WindowToken", "nextApp", "=", "nextAppIndex", ">=", "0", "?", "mAppTokens", ".", "get", "(", "nextAppIndex", ")", ":", "null", ";", "while", "(", "i", ">=", "0", ")", "{", "win", "=", "mWindows", ".", "get", "(", "i", ")", ";", "if", "(", "localLOGV", "||", "DEBUG_FOCUS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "i", "+", "\"", "=", "\"", "+", "win", "+", "\",", "flags=\"", "+", "win", ".", "mAttrs", ".", "flags", "+", "\"\"", "+", "win", ".", "canReceiveKeys", "(", ")", ")", ";", "AppWindowToken", "thisApp", "=", "win", ".", "mAppToken", ";", "if", "(", "thisApp", "!=", "null", "&&", "thisApp", ".", "removed", ")", "{", "i", "--", ";", "continue", ";", "}", "if", "(", "thisApp", "!=", "null", "&&", "nextApp", "!=", "null", "&&", "thisApp", "!=", "nextApp", "&&", "win", ".", "mAttrs", ".", "type", "!=", "TYPE_APPLICATION_STARTING", ")", "{", "int", "origAppIndex", "=", "nextAppIndex", ";", "while", "(", "nextAppIndex", ">", "0", ")", "{", "if", "(", "nextApp", "==", "mFocusedApp", ")", "{", "if", "(", "localLOGV", "||", "DEBUG_FOCUS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "mFocusedApp", ")", ";", "return", "null", ";", "}", "nextAppIndex", "--", ";", "nextApp", "=", "mAppTokens", ".", "get", "(", "nextAppIndex", ")", ";", "if", "(", "nextApp", "==", "thisApp", ")", "{", "break", ";", "}", "}", "if", "(", "thisApp", "!=", "nextApp", ")", "{", "nextAppIndex", "=", "origAppIndex", ";", "nextApp", "=", "mAppTokens", ".", "get", "(", "nextAppIndex", ")", ";", "}", "}", "if", "(", "win", ".", "canReceiveKeys", "(", ")", ")", "{", "if", "(", "DEBUG_FOCUS", ")", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "i", "+", "\"", "=", "\"", "+", "win", ")", ";", "result", "=", "win", ";", "break", ";", "}", "i", "--", ";", "}", "return", "result", ";", "}", "private", "void", "startFreezingDisplayLocked", "(", "boolean", "inTransaction", ")", "{", "if", "(", "mDisplayFrozen", ")", "{", "return", ";", "}", "if", "(", "mDisplay", "==", "null", "||", "!", "mPolicy", ".", "isScreenOnFully", "(", ")", ")", "{", "return", ";", "}", "mScreenFrozenLock", ".", "acquire", "(", ")", ";", "mDisplayFrozen", "=", "true", ";", "mInputMonitor", ".", "freezeInputDispatchingLw", "(", ")", ";", "if", "(", "mNextAppTransition", "!=", "WindowManagerPolicy", ".", "TRANSIT_UNSET", ")", "{", "mNextAppTransition", "=", "WindowManagerPolicy", ".", "TRANSIT_UNSET", ";", "mNextAppTransitionPackage", "=", "null", ";", "mAppTransitionReady", "=", "true", ";", "}", "if", "(", "PROFILE_ORIENTATION", ")", "{", "File", "file", "=", "new", "File", "(", "\"\"", ")", ";", "Debug", ".", "startMethodTracing", "(", "file", ".", "toString", "(", ")", ",", "8", "*", "1024", "*", "1024", ")", ";", "}", "if", "(", "CUSTOM_SCREEN_ROTATION", ")", "{", "if", "(", "mScreenRotationAnimation", "!=", "null", "&&", "mScreenRotationAnimation", ".", "isAnimating", "(", ")", ")", "{", "mScreenRotationAnimation", ".", "kill", "(", ")", ";", "mScreenRotationAnimation", "=", "null", ";", "}", "if", "(", "mScreenRotationAnimation", "==", "null", ")", "{", "mScreenRotationAnimation", "=", "new", "ScreenRotationAnimation", "(", "mContext", ",", "mFxSession", ",", "inTransaction", ",", "mCurDisplayWidth", ",", "mCurDisplayHeight", ",", "mDisplay", ".", "getRotation", "(", ")", ")", ";", "}", "if", "(", "!", "mScreenRotationAnimation", ".", "hasScreenshot", "(", ")", ")", "{", "Surface", ".", "freezeDisplay", "(", "0", ")", ";", "}", "}", "else", "{", "Surface", ".", "freezeDisplay", "(", "0", ")", ";", "}", "}", "private", "void", "stopFreezingDisplayLocked", "(", ")", "{", "if", "(", "!", "mDisplayFrozen", ")", "{", "return", ";", "}", "if", "(", "mWaitingForConfig", "||", "mAppsFreezingScreen", ">", "0", "||", "mWindowsFreezingScreen", ")", "{", "return", ";", "}", "mDisplayFrozen", "=", "false", ";", "mH", ".", "removeMessages", "(", "H", ".", "APP_FREEZE_TIMEOUT", ")", ";", "if", "(", "PROFILE_ORIENTATION", ")", "{", "Debug", ".", "stopMethodTracing", "(", ")", ";", "}", "boolean", "updateRotation", "=", "false", ";", "if", "(", "CUSTOM_SCREEN_ROTATION", "&&", "mScreenRotationAnimation", "!=", "null", "&&", "mScreenRotationAnimation", ".", "hasScreenshot", "(", ")", ")", "{", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "i", "(", "TAG", ",", "\"\"", ")", ";", "if", "(", "mScreenRotationAnimation", ".", "dismiss", "(", "mFxSession", ",", "MAX_ANIMATION_DURATION", ",", "mTransitionAnimationScale", ",", "mCurDisplayWidth", ",", "mCurDisplayHeight", ")", ")", "{", "requestAnimationLocked", "(", "0", ")", ";", "}", "else", "{", "mScreenRotationAnimation", "=", "null", ";", "updateRotation", "=", "true", ";", "}", "}", "else", "{", "if", "(", "mScreenRotationAnimation", "!=", "null", ")", "{", "mScreenRotationAnimation", ".", "kill", "(", ")", ";", "mScreenRotationAnimation", "=", "null", ";", "}", "updateRotation", "=", "true", ";", "}", "Surface", ".", "unfreezeDisplay", "(", "0", ")", ";", "mInputMonitor", ".", "thawInputDispatchingLw", "(", ")", ";", "boolean", "configChanged", ";", "configChanged", "=", "updateOrientationFromAppTokensLocked", "(", "false", ")", ";", "mH", ".", "removeMessages", "(", "H", ".", "FORCE_GC", ")", ";", "mH", ".", "sendMessageDelayed", "(", "mH", ".", "obtainMessage", "(", "H", ".", "FORCE_GC", ")", ",", "2000", ")", ";", "mScreenFrozenLock", ".", "release", "(", ")", ";", "if", "(", "updateRotation", ")", "{", "if", "(", "DEBUG_ORIENTATION", ")", "Slog", ".", "d", "(", "TAG", ",", "\"\"", ")", ";", "configChanged", "|=", "updateRotationUncheckedLocked", "(", "false", ")", ";", "}", "if", "(", "configChanged", ")", "{", "mH", ".", "sendEmptyMessage", "(", "H", ".", "SEND_NEW_CONFIGURATION", ")", ";", "}", "}", "static", "int", "getPropertyInt", "(", "String", "[", "]", "tokens", ",", "int", "index", ",", "int", "defUnits", ",", "int", "defDps", ",", "DisplayMetrics", "dm", ")", "{", "if", "(", "index", "<", "tokens", ".", "length", ")", "{", "String", "str", "=", "tokens", "[", "index", "]", ";", "if", "(", "str", "!=", "null", "&&", "str", ".", "length", "(", ")", ">", "0", ")", "{", "try", "{", "int", "val", "=", "Integer", ".", "parseInt", "(", "str", ")", ";", "return", "val", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "}", "if", "(", "defUnits", "==", "TypedValue", ".", "COMPLEX_UNIT_PX", ")", "{", "return", "defDps", ";", "}", "int", "val", "=", "(", "int", ")", "TypedValue", ".", "applyDimension", "(", "defUnits", ",", "defDps", ",", "dm", ")", ";", "return", "val", ";", "}", "void", "createWatermark", "(", ")", "{", "if", "(", "mWatermark", "!=", "null", ")", "{", "return", ";", "}", "File", "file", "=", "new", "File", "(", "\"\"", ")", ";", "FileInputStream", "in", "=", "null", ";", "try", "{", "in", "=", "new", "FileInputStream", "(", "file", ")", ";", "DataInputStream", "ind", "=", "new", "DataInputStream", "(", "in", ")", ";", "String", "line", "=", "ind", ".", "readLine", "(", ")", ";", "if", "(", "line", "!=", "null", ")", "{", "String", "[", "]", "toks", "=", "line", ".", "split", "(", "\"%\"", ")", ";", "if", "(", "toks", "!=", "null", "&&", "toks", ".", "length", ">", "0", ")", "{", "mWatermark", "=", "new", "Watermark", "(", "mRealDisplayMetrics", ",", "mFxSession", ",", "toks", ")", ";", "}", "}", "}", "catch", "(", "FileNotFoundException", "e", ")", "{", "}", "catch", "(", "IOException", "e", ")", "{", "}", "finally", "{", "if", "(", "in", "!=", "null", ")", "{", "try", "{", "in", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "}", "}", "}", "}", "@", "Override", "public", "void", "statusBarVisibilityChanged", "(", "int", "visibility", ")", "{", "if", "(", "mContext", ".", "checkCallingOrSelfPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "STATUS_BAR", ")", "!=", "PackageManager", ".", "PERMISSION_GRANTED", ")", "{", "throw", "new", "SecurityException", "(", "\"\"", "+", "android", ".", "Manifest", ".", "permission", ".", "STATUS_BAR", ")", ";", "}", "synchronized", "(", "mWindowMap", ")", "{", "mLastStatusBarVisibility", "=", "visibility", ";", "visibility", "=", "mPolicy", ".", "adjustSystemUiVisibilityLw", "(", "visibility", ")", ";", "updateStatusBarVisibilityLocked", "(", "visibility", ")", ";", "}", "}", "void", "updateStatusBarVisibilityLocked", "(", "int", "visibility", ")", "{", "mInputManager", ".", "setSystemUiVisibility", "(", "visibility", ")", ";", "final", "int", "N", "=", "mWindows", ".", "size", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "WindowState", "ws", "=", "mWindows", ".", "get", "(", "i", ")", ";", "try", "{", "int", "curValue", "=", "ws", ".", "mSystemUiVisibility", ";", "int", "diff", "=", "curValue", "^", "visibility", ";", "diff", "&=", "View", ".", "SYSTEM_UI_CLEARABLE_FLAGS", ";", "diff", "&=", "~", "visibility", ";", "int", "newValue", "=", "(", "curValue", "&", "~", "diff", ")", "|", "(", "visibility", "&", "diff", ")", ";", "if", "(", "newValue", "!=", "curValue", ")", "{", "ws", ".", "mSeq", "++", ";", "ws", ".", "mSystemUiVisibility", "=", "newValue", ";", "}", "if", "(", "newValue", "!=", "curValue", "||", "ws", ".", "mAttrs", ".", "hasSystemUiListeners", ")", "{", "ws", ".", "mClient", ".", "dispatchSystemUiVisibilityChanged", "(", "ws", ".", "mSeq", ",", "visibility", ",", "newValue", ",", "diff", ")", ";", "}", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "}", "@", "Override", "public", "void", "reevaluateStatusBarVisibility", "(", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "int", "visibility", "=", "mPolicy", ".", "adjustSystemUiVisibilityLw", "(", "mLastStatusBarVisibility", ")", ";", "updateStatusBarVisibilityLocked", "(", "visibility", ")", ";", "performLayoutAndPlaceSurfacesLocked", "(", ")", ";", "}", "}", "@", "Override", "public", "FakeWindow", "addFakeWindow", "(", "Looper", "looper", ",", "InputHandler", "inputHandler", ",", "String", "name", ",", "int", "windowType", ",", "int", "layoutParamsFlags", ",", "boolean", "canReceiveKeys", ",", "boolean", "hasFocus", ",", "boolean", "touchFullscreen", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "FakeWindowImpl", "fw", "=", "new", "FakeWindowImpl", "(", "this", ",", "looper", ",", "inputHandler", ",", "name", ",", "windowType", ",", "layoutParamsFlags", ",", "canReceiveKeys", ",", "hasFocus", ",", "touchFullscreen", ")", ";", "int", "i", "=", "0", ";", "while", "(", "i", "<", "mFakeWindows", ".", "size", "(", ")", ")", "{", "if", "(", "mFakeWindows", ".", "get", "(", "i", ")", ".", "mWindowLayer", "<=", "fw", ".", "mWindowLayer", ")", "{", "break", ";", "}", "}", "mFakeWindows", ".", "add", "(", "i", ",", "fw", ")", ";", "mInputMonitor", ".", "updateInputWindowsLw", "(", "true", ")", ";", "return", "fw", ";", "}", "}", "boolean", "removeFakeWindowLocked", "(", "FakeWindow", "window", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "mFakeWindows", ".", "remove", "(", "window", ")", ")", "{", "mInputMonitor", ".", "updateInputWindowsLw", "(", "true", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}", "}", "@", "Override", "public", "boolean", "hasNavigationBar", "(", ")", "{", "return", "mPolicy", ".", "hasNavigationBar", "(", ")", ";", "}", "public", "void", "lockNow", "(", ")", "{", "mPolicy", ".", "lockNow", "(", ")", ";", "}", "void", "dumpInput", "(", "FileDescriptor", "fd", ",", "PrintWriter", "pw", ",", "boolean", "dumpAll", ")", "{", "pw", ".", "println", "(", "\"\"", ")", ";", "mInputManager", ".", "dump", "(", "pw", ")", ";", "}", "void", "dumpPolicyLocked", "(", "FileDescriptor", "fd", ",", "PrintWriter", "pw", ",", "String", "[", "]", "args", ",", "boolean", "dumpAll", ")", "{", "pw", ".", "println", "(", "\"\"", ")", ";", "mPolicy", ".", "dump", "(", "\"", "\"", ",", "fd", ",", "pw", ",", "args", ")", ";", "}", "void", "dumpTokensLocked", "(", "FileDescriptor", "fd", ",", "PrintWriter", "pw", ",", "boolean", "dumpAll", ")", "{", "pw", ".", "println", "(", "\"\"", ")", ";", "if", "(", "mTokenMap", ".", "size", "(", ")", ">", "0", ")", "{", "pw", ".", "println", "(", "\"\"", ")", ";", "Iterator", "<", "WindowToken", ">", "it", "=", "mTokenMap", ".", "values", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "WindowToken", "token", "=", "it", ".", "next", "(", ")", ";", "pw", ".", "print", "(", "\"", "Token", "\"", ")", ";", "pw", ".", "print", "(", "token", ".", "token", ")", ";", "if", "(", "dumpAll", ")", "{", "pw", ".", "println", "(", "':'", ")", ";", "token", ".", "dump", "(", "pw", ",", "\"", "\"", ")", ";", "}", "else", "{", "pw", ".", "println", "(", ")", ";", "}", "}", "}", "if", "(", "mWallpaperTokens", ".", "size", "(", ")", ">", "0", ")", "{", "pw", ".", "println", "(", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "for", "(", "int", "i", "=", "mWallpaperTokens", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowToken", "token", "=", "mWallpaperTokens", ".", "get", "(", "i", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "i", ")", ";", "pw", ".", "print", "(", "'", "'", ")", ";", "pw", ".", "print", "(", "token", ")", ";", "if", "(", "dumpAll", ")", "{", "pw", ".", "println", "(", "':'", ")", ";", "token", ".", "dump", "(", "pw", ",", "\"", "\"", ")", ";", "}", "else", "{", "pw", ".", "println", "(", ")", ";", "}", "}", "}", "if", "(", "mAppTokens", ".", "size", "(", ")", ">", "0", ")", "{", "pw", ".", "println", "(", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "for", "(", "int", "i", "=", "mAppTokens", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "pw", ".", "print", "(", "\"", "App", "#\"", ")", ";", "pw", ".", "print", "(", "i", ")", ";", "pw", ".", "print", "(", "\":", "\"", ")", ";", "pw", ".", "println", "(", "mAppTokens", ".", "get", "(", "i", ")", ")", ";", "}", "}", "if", "(", "mFinishedStarting", ".", "size", "(", ")", ">", "0", ")", "{", "pw", ".", "println", "(", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "for", "(", "int", "i", "=", "mFinishedStarting", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowToken", "token", "=", "mFinishedStarting", ".", "get", "(", "i", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "i", ")", ";", "pw", ".", "print", "(", "'", "'", ")", ";", "pw", ".", "print", "(", "token", ")", ";", "if", "(", "dumpAll", ")", "{", "pw", ".", "println", "(", "':'", ")", ";", "token", ".", "dump", "(", "pw", ",", "\"", "\"", ")", ";", "}", "else", "{", "pw", ".", "println", "(", ")", ";", "}", "}", "}", "if", "(", "mExitingTokens", ".", "size", "(", ")", ">", "0", ")", "{", "pw", ".", "println", "(", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "for", "(", "int", "i", "=", "mExitingTokens", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowToken", "token", "=", "mExitingTokens", ".", "get", "(", "i", ")", ";", "pw", ".", "print", "(", "\"", "Exiting", "#\"", ")", ";", "pw", ".", "print", "(", "i", ")", ";", "pw", ".", "print", "(", "'", "'", ")", ";", "pw", ".", "print", "(", "token", ")", ";", "if", "(", "dumpAll", ")", "{", "pw", ".", "println", "(", "':'", ")", ";", "token", ".", "dump", "(", "pw", ",", "\"", "\"", ")", ";", "}", "else", "{", "pw", ".", "println", "(", ")", ";", "}", "}", "}", "if", "(", "mExitingAppTokens", ".", "size", "(", ")", ">", "0", ")", "{", "pw", ".", "println", "(", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "for", "(", "int", "i", "=", "mExitingAppTokens", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowToken", "token", "=", "mExitingAppTokens", ".", "get", "(", "i", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "i", ")", ";", "pw", ".", "print", "(", "'", "'", ")", ";", "pw", ".", "print", "(", "token", ")", ";", "if", "(", "dumpAll", ")", "{", "pw", ".", "println", "(", "':'", ")", ";", "token", ".", "dump", "(", "pw", ",", "\"", "\"", ")", ";", "}", "else", "{", "pw", ".", "println", "(", ")", ";", "}", "}", "}", "pw", ".", "println", "(", ")", ";", "if", "(", "mOpeningApps", ".", "size", "(", ")", ">", "0", ")", "{", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mOpeningApps", ")", ";", "}", "if", "(", "mClosingApps", ".", "size", "(", ")", ">", "0", ")", "{", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mClosingApps", ")", ";", "}", "if", "(", "mToTopApps", ".", "size", "(", ")", ">", "0", ")", "{", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mToTopApps", ")", ";", "}", "if", "(", "mToBottomApps", ".", "size", "(", ")", ">", "0", ")", "{", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mToBottomApps", ")", ";", "}", "}", "void", "dumpSessionsLocked", "(", "FileDescriptor", "fd", ",", "PrintWriter", "pw", ",", "boolean", "dumpAll", ")", "{", "pw", ".", "println", "(", "\"\"", ")", ";", "if", "(", "mSessions", ".", "size", "(", ")", ">", "0", ")", "{", "Iterator", "<", "Session", ">", "it", "=", "mSessions", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "Session", "s", "=", "it", ".", "next", "(", ")", ";", "pw", ".", "print", "(", "\"", "Session", "\"", ")", ";", "pw", ".", "print", "(", "s", ")", ";", "pw", ".", "println", "(", "':'", ")", ";", "s", ".", "dump", "(", "pw", ",", "\"", "\"", ")", ";", "}", "}", "}", "void", "dumpWindowsLocked", "(", "FileDescriptor", "fd", ",", "PrintWriter", "pw", ",", "boolean", "dumpAll", ",", "ArrayList", "<", "WindowState", ">", "windows", ")", "{", "pw", ".", "println", "(", "\"\"", ")", ";", "for", "(", "int", "i", "=", "mWindows", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowState", "w", "=", "mWindows", ".", "get", "(", "i", ")", ";", "if", "(", "windows", "==", "null", "||", "windows", ".", "contains", "(", "w", ")", ")", "{", "pw", ".", "print", "(", "\"", "Window", "#\"", ")", ";", "pw", ".", "print", "(", "i", ")", ";", "pw", ".", "print", "(", "'", "'", ")", ";", "pw", ".", "print", "(", "w", ")", ";", "pw", ".", "println", "(", "\":\"", ")", ";", "w", ".", "dump", "(", "pw", ",", "\"", "\"", ",", "dumpAll", "||", "windows", "!=", "null", ")", ";", "}", "}", "if", "(", "mInputMethodDialogs", ".", "size", "(", ")", ">", "0", ")", "{", "pw", ".", "println", "(", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "for", "(", "int", "i", "=", "mInputMethodDialogs", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowState", "w", "=", "mInputMethodDialogs", ".", "get", "(", "i", ")", ";", "if", "(", "windows", "==", "null", "||", "windows", ".", "contains", "(", "w", ")", ")", "{", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "i", ")", ";", "pw", ".", "print", "(", "\":", "\"", ")", ";", "pw", ".", "println", "(", "w", ")", ";", "}", "}", "}", "if", "(", "mPendingRemove", ".", "size", "(", ")", ">", "0", ")", "{", "pw", ".", "println", "(", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "for", "(", "int", "i", "=", "mPendingRemove", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowState", "w", "=", "mPendingRemove", ".", "get", "(", "i", ")", ";", "if", "(", "windows", "==", "null", "||", "windows", ".", "contains", "(", "w", ")", ")", "{", "pw", ".", "print", "(", "\"", "Remove", "#\"", ")", ";", "pw", ".", "print", "(", "i", ")", ";", "pw", ".", "print", "(", "'", "'", ")", ";", "pw", ".", "print", "(", "w", ")", ";", "if", "(", "dumpAll", ")", "{", "pw", ".", "println", "(", "\":\"", ")", ";", "w", ".", "dump", "(", "pw", ",", "\"", "\"", ",", "true", ")", ";", "}", "else", "{", "pw", ".", "println", "(", ")", ";", "}", "}", "}", "}", "if", "(", "mForceRemoves", "!=", "null", "&&", "mForceRemoves", ".", "size", "(", ")", ">", "0", ")", "{", "pw", ".", "println", "(", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "for", "(", "int", "i", "=", "mForceRemoves", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowState", "w", "=", "mForceRemoves", ".", "get", "(", "i", ")", ";", "pw", ".", "print", "(", "\"", "Removing", "#\"", ")", ";", "pw", ".", "print", "(", "i", ")", ";", "pw", ".", "print", "(", "'", "'", ")", ";", "pw", ".", "print", "(", "w", ")", ";", "if", "(", "dumpAll", ")", "{", "pw", ".", "println", "(", "\":\"", ")", ";", "w", ".", "dump", "(", "pw", ",", "\"", "\"", ",", "true", ")", ";", "}", "else", "{", "pw", ".", "println", "(", ")", ";", "}", "}", "}", "if", "(", "mDestroySurface", ".", "size", "(", ")", ">", "0", ")", "{", "pw", ".", "println", "(", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "for", "(", "int", "i", "=", "mDestroySurface", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowState", "w", "=", "mDestroySurface", ".", "get", "(", "i", ")", ";", "if", "(", "windows", "==", "null", "||", "windows", ".", "contains", "(", "w", ")", ")", "{", "pw", ".", "print", "(", "\"", "Destroy", "#\"", ")", ";", "pw", ".", "print", "(", "i", ")", ";", "pw", ".", "print", "(", "'", "'", ")", ";", "pw", ".", "print", "(", "w", ")", ";", "if", "(", "dumpAll", ")", "{", "pw", ".", "println", "(", "\":\"", ")", ";", "w", ".", "dump", "(", "pw", ",", "\"", "\"", ",", "true", ")", ";", "}", "else", "{", "pw", ".", "println", "(", ")", ";", "}", "}", "}", "}", "if", "(", "mLosingFocus", ".", "size", "(", ")", ">", "0", ")", "{", "pw", ".", "println", "(", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "for", "(", "int", "i", "=", "mLosingFocus", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowState", "w", "=", "mLosingFocus", ".", "get", "(", "i", ")", ";", "if", "(", "windows", "==", "null", "||", "windows", ".", "contains", "(", "w", ")", ")", "{", "pw", ".", "print", "(", "\"", "Losing", "#\"", ")", ";", "pw", ".", "print", "(", "i", ")", ";", "pw", ".", "print", "(", "'", "'", ")", ";", "pw", ".", "print", "(", "w", ")", ";", "if", "(", "dumpAll", ")", "{", "pw", ".", "println", "(", "\":\"", ")", ";", "w", ".", "dump", "(", "pw", ",", "\"", "\"", ",", "true", ")", ";", "}", "else", "{", "pw", ".", "println", "(", ")", ";", "}", "}", "}", "}", "if", "(", "mResizingWindows", ".", "size", "(", ")", ">", "0", ")", "{", "pw", ".", "println", "(", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "for", "(", "int", "i", "=", "mResizingWindows", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowState", "w", "=", "mResizingWindows", ".", "get", "(", "i", ")", ";", "if", "(", "windows", "==", "null", "||", "windows", ".", "contains", "(", "w", ")", ")", "{", "pw", ".", "print", "(", "\"", "Resizing", "#\"", ")", ";", "pw", ".", "print", "(", "i", ")", ";", "pw", ".", "print", "(", "'", "'", ")", ";", "pw", ".", "print", "(", "w", ")", ";", "if", "(", "dumpAll", ")", "{", "pw", ".", "println", "(", "\":\"", ")", ";", "w", ".", "dump", "(", "pw", ",", "\"", "\"", ",", "true", ")", ";", "}", "else", "{", "pw", ".", "println", "(", ")", ";", "}", "}", "}", "}", "if", "(", "mWaitingForDrawn", ".", "size", "(", ")", ">", "0", ")", "{", "pw", ".", "println", "(", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "for", "(", "int", "i", "=", "mWaitingForDrawn", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "Pair", "<", "WindowState", ",", "IRemoteCallback", ">", "pair", "=", "mWaitingForDrawn", ".", "get", "(", "i", ")", ";", "pw", ".", "print", "(", "\"", "Waiting", "#\"", ")", ";", "pw", ".", "print", "(", "i", ")", ";", "pw", ".", "print", "(", "'", "'", ")", ";", "pw", ".", "print", "(", "pair", ".", "first", ")", ";", "pw", ".", "print", "(", "\":", "\"", ")", ";", "pw", ".", "println", "(", "pair", ".", "second", ")", ";", "}", "}", "pw", ".", "println", "(", ")", ";", "if", "(", "mDisplay", "!=", "null", ")", "{", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mInitialDisplayWidth", ")", ";", "pw", ".", "print", "(", "\"x\"", ")", ";", "pw", ".", "print", "(", "mInitialDisplayHeight", ")", ";", "pw", ".", "print", "(", "\"", "base=\"", ")", ";", "pw", ".", "print", "(", "mBaseDisplayWidth", ")", ";", "pw", ".", "print", "(", "\"x\"", ")", ";", "pw", ".", "print", "(", "mBaseDisplayHeight", ")", ";", "pw", ".", "print", "(", "\"", "cur=\"", ")", ";", "pw", ".", "print", "(", "mCurDisplayWidth", ")", ";", "pw", ".", "print", "(", "\"x\"", ")", ";", "pw", ".", "print", "(", "mCurDisplayHeight", ")", ";", "pw", ".", "print", "(", "\"", "app=\"", ")", ";", "pw", ".", "print", "(", "mAppDisplayWidth", ")", ";", "pw", ".", "print", "(", "\"x\"", ")", ";", "pw", ".", "print", "(", "mAppDisplayHeight", ")", ";", "pw", ".", "print", "(", "\"", "raw=\"", ")", ";", "pw", ".", "print", "(", "mDisplay", ".", "getRawWidth", "(", ")", ")", ";", "pw", ".", "print", "(", "\"x\"", ")", ";", "pw", ".", "println", "(", "mDisplay", ".", "getRawHeight", "(", ")", ")", ";", "}", "else", "{", "pw", ".", "println", "(", "\"", "NO", "DISPLAY\"", ")", ";", "}", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "this", ".", "mCurConfiguration", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mCurrentFocus", ")", ";", "if", "(", "mLastFocus", "!=", "mCurrentFocus", ")", "{", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mLastFocus", ")", ";", "}", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mFocusedApp", ")", ";", "if", "(", "mInputMethodTarget", "!=", "null", ")", "{", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mInputMethodTarget", ")", ";", "}", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mInTouchMode", ")", ";", "pw", ".", "print", "(", "\"", "mLayoutSeq=\"", ")", ";", "pw", ".", "println", "(", "mLayoutSeq", ")", ";", "if", "(", "dumpAll", ")", "{", "if", "(", "mLastStatusBarVisibility", "!=", "0", ")", "{", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "Integer", ".", "toHexString", "(", "mLastStatusBarVisibility", ")", ")", ";", "}", "if", "(", "mInputMethodWindow", "!=", "null", ")", "{", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mInputMethodWindow", ")", ";", "}", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mWallpaperTarget", ")", ";", "if", "(", "mLowerWallpaperTarget", "!=", "null", "&&", "mUpperWallpaperTarget", "!=", "null", ")", "{", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mLowerWallpaperTarget", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mUpperWallpaperTarget", ")", ";", "}", "if", "(", "mWindowDetachedWallpaper", "!=", "null", ")", "{", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mWindowDetachedWallpaper", ")", ";", "}", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mLastWallpaperX", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mLastWallpaperY", ")", ";", "if", "(", "mInputMethodAnimLayerAdjustment", "!=", "0", "||", "mWallpaperAnimLayerAdjustment", "!=", "0", ")", "{", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mInputMethodAnimLayerAdjustment", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mWallpaperAnimLayerAdjustment", ")", ";", "}", "if", "(", "mWindowAnimationBackgroundSurface", "!=", "null", ")", "{", "pw", ".", "println", "(", "\"\"", ")", ";", "mWindowAnimationBackgroundSurface", ".", "printTo", "(", "\"", "\"", ",", "pw", ")", ";", "}", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mSystemBooted", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mDisplayEnabled", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mLayoutNeeded", ")", ";", "pw", ".", "print", "(", "\"", "mBlurShown=\"", ")", ";", "pw", ".", "println", "(", "mBlurShown", ")", ";", "if", "(", "mDimAnimator", "!=", "null", ")", "{", "pw", ".", "println", "(", "\"\"", ")", ";", "mDimAnimator", ".", "printTo", "(", "\"", "\"", ",", "pw", ")", ";", "}", "else", "{", "pw", ".", "println", "(", "\"\"", ")", ";", "}", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mDisplayFrozen", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mWindowsFreezingScreen", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mAppsFreezingScreen", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mWaitingForConfig", ")", ";", "pw", ".", "print", "(", "\"", "mRotation=\"", ")", ";", "pw", ".", "print", "(", "mRotation", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mAltOrientation", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mLastWindowForcedOrientation", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mForcedAppOrientation", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mDeferredRotationPauseCount", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mAnimationPending", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mWindowAnimationScale", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mTransitionAnimationScale", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "Integer", ".", "toHexString", "(", "mNextAppTransition", ")", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mAppTransitionReady", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mAppTransitionRunning", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mAppTransitionTimeout", ")", ";", "if", "(", "mNextAppTransitionPackage", "!=", "null", ")", "{", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mNextAppTransitionPackage", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "Integer", ".", "toHexString", "(", "mNextAppTransitionEnter", ")", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "Integer", ".", "toHexString", "(", "mNextAppTransitionExit", ")", ")", ";", "}", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mStartingIconInTransition", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mSkipAppTransitionAnimation", ")", ";", "}", "}", "boolean", "dumpWindows", "(", "FileDescriptor", "fd", ",", "PrintWriter", "pw", ",", "String", "name", ",", "String", "[", "]", "args", ",", "int", "opti", ",", "boolean", "dumpAll", ")", "{", "ArrayList", "<", "WindowState", ">", "windows", "=", "new", "ArrayList", "<", "WindowState", ">", "(", ")", ";", "if", "(", "\"visible\"", ".", "equals", "(", "name", ")", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "for", "(", "int", "i", "=", "mWindows", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowState", "w", "=", "mWindows", ".", "get", "(", "i", ")", ";", "if", "(", "w", ".", "mSurfaceShown", ")", "{", "windows", ".", "add", "(", "w", ")", ";", "}", "}", "}", "}", "else", "{", "int", "objectId", "=", "0", ";", "try", "{", "objectId", "=", "Integer", ".", "parseInt", "(", "name", ",", "16", ")", ";", "name", "=", "null", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "}", "synchronized", "(", "mWindowMap", ")", "{", "for", "(", "int", "i", "=", "mWindows", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowState", "w", "=", "mWindows", ".", "get", "(", "i", ")", ";", "if", "(", "name", "!=", "null", ")", "{", "if", "(", "w", ".", "mAttrs", ".", "getTitle", "(", ")", ".", "toString", "(", ")", ".", "contains", "(", "name", ")", ")", "{", "windows", ".", "add", "(", "w", ")", ";", "}", "}", "else", "if", "(", "System", ".", "identityHashCode", "(", "w", ")", "==", "objectId", ")", "{", "windows", ".", "add", "(", "w", ")", ";", "}", "}", "}", "}", "if", "(", "windows", ".", "size", "(", ")", "<=", "0", ")", "{", "return", "false", ";", "}", "synchronized", "(", "mWindowMap", ")", "{", "dumpWindowsLocked", "(", "fd", ",", "pw", ",", "dumpAll", ",", "windows", ")", ";", "}", "return", "true", ";", "}", "@", "Override", "public", "void", "dump", "(", "FileDescriptor", "fd", ",", "PrintWriter", "pw", ",", "String", "[", "]", "args", ")", "{", "if", "(", "mContext", ".", "checkCallingOrSelfPermission", "(", "\"\"", ")", "!=", "PackageManager", ".", "PERMISSION_GRANTED", ")", "{", "pw", ".", "println", "(", "\"\"", "+", "Binder", ".", "getCallingPid", "(", ")", "+", "\",", "uid=\"", "+", "Binder", ".", "getCallingUid", "(", ")", ")", ";", "return", ";", "}", "boolean", "dumpAll", "=", "false", ";", "int", "opti", "=", "0", ";", "while", "(", "opti", "<", "args", ".", "length", ")", "{", "String", "opt", "=", "args", "[", "opti", "]", ";", "if", "(", "opt", "==", "null", "||", "opt", ".", "length", "(", ")", "<=", "0", "||", "opt", ".", "charAt", "(", "0", ")", "!=", "'-'", ")", "{", "break", ";", "}", "opti", "++", ";", "if", "(", "\"-a\"", ".", "equals", "(", "opt", ")", ")", "{", "dumpAll", "=", "true", ";", "}", "else", "if", "(", "\"-h\"", ".", "equals", "(", "opt", ")", ")", "{", "pw", ".", "println", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "return", ";", "}", "else", "{", "pw", ".", "println", "(", "\"\"", "+", "opt", "+", "\"\"", ")", ";", "}", "}", "if", "(", "opti", "<", "args", ".", "length", ")", "{", "String", "cmd", "=", "args", "[", "opti", "]", ";", "opti", "++", ";", "if", "(", "\"input\"", ".", "equals", "(", "cmd", ")", "||", "\"i\"", ".", "equals", "(", "cmd", ")", ")", "{", "dumpInput", "(", "fd", ",", "pw", ",", "true", ")", ";", "return", ";", "}", "else", "if", "(", "\"policy\"", ".", "equals", "(", "cmd", ")", "||", "\"p\"", ".", "equals", "(", "cmd", ")", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "dumpPolicyLocked", "(", "fd", ",", "pw", ",", "args", ",", "true", ")", ";", "}", "return", ";", "}", "else", "if", "(", "\"sessions\"", ".", "equals", "(", "cmd", ")", "||", "\"s\"", ".", "equals", "(", "cmd", ")", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "dumpSessionsLocked", "(", "fd", ",", "pw", ",", "true", ")", ";", "}", "return", ";", "}", "else", "if", "(", "\"tokens\"", ".", "equals", "(", "cmd", ")", "||", "\"t\"", ".", "equals", "(", "cmd", ")", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "dumpTokensLocked", "(", "fd", ",", "pw", ",", "true", ")", ";", "}", "return", ";", "}", "else", "if", "(", "\"windows\"", ".", "equals", "(", "cmd", ")", "||", "\"w\"", ".", "equals", "(", "cmd", ")", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "dumpWindowsLocked", "(", "fd", ",", "pw", ",", "true", ",", "null", ")", ";", "}", "return", ";", "}", "else", "if", "(", "\"all\"", ".", "equals", "(", "cmd", ")", "||", "\"a\"", ".", "equals", "(", "cmd", ")", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "dumpWindowsLocked", "(", "fd", ",", "pw", ",", "true", ",", "null", ")", ";", "}", "return", ";", "}", "else", "{", "if", "(", "!", "dumpWindows", "(", "fd", ",", "pw", ",", "cmd", ",", "args", ",", "opti", ",", "dumpAll", ")", ")", "{", "pw", ".", "println", "(", "\"\"", "+", "cmd", ")", ";", "pw", ".", "println", "(", "\"\"", ")", ";", "}", "return", ";", "}", "}", "dumpInput", "(", "fd", ",", "pw", ",", "dumpAll", ")", ";", "synchronized", "(", "mWindowMap", ")", "{", "if", "(", "dumpAll", ")", "{", "pw", ".", "println", "(", "\"\"", ")", ";", "}", "dumpPolicyLocked", "(", "fd", ",", "pw", ",", "args", ",", "dumpAll", ")", ";", "pw", ".", "println", "(", ")", ";", "if", "(", "dumpAll", ")", "{", "pw", ".", "println", "(", "\"\"", ")", ";", "}", "dumpSessionsLocked", "(", "fd", ",", "pw", ",", "dumpAll", ")", ";", "pw", ".", "println", "(", ")", ";", "if", "(", "dumpAll", ")", "{", "pw", ".", "println", "(", "\"\"", ")", ";", "}", "dumpTokensLocked", "(", "fd", ",", "pw", ",", "dumpAll", ")", ";", "pw", ".", "println", "(", ")", ";", "if", "(", "dumpAll", ")", "{", "pw", ".", "println", "(", "\"\"", ")", ";", "}", "dumpWindowsLocked", "(", "fd", ",", "pw", ",", "dumpAll", ",", "null", ")", ";", "}", "}", "public", "void", "monitor", "(", ")", "{", "synchronized", "(", "mWindowMap", ")", "{", "}", "synchronized", "(", "mKeyguardTokenWatcher", ")", "{", "}", "}", "public", "interface", "OnHardKeyboardStatusChangeListener", "{", "public", "void", "onHardKeyboardStatusChange", "(", "boolean", "available", ",", "boolean", "enabled", ")", ";", "}", "}", "</s>" ]
8,201
[ "<s>", "package", "android", ".", "app", ";", "import", "com", ".", "android", ".", "internal", ".", "app", ".", "IUsageStats", ";", "import", "com", ".", "android", ".", "internal", ".", "os", ".", "PkgUsageStats", ";", "import", "com", ".", "android", ".", "internal", ".", "util", ".", "MemInfoReader", ";", "import", "android", ".", "content", ".", "ComponentName", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "content", ".", "pm", ".", "ApplicationInfo", ";", "import", "android", ".", "content", ".", "pm", ".", "ConfigurationInfo", ";", "import", "android", ".", "content", ".", "pm", ".", "IPackageDataObserver", ";", "import", "android", ".", "content", ".", "res", ".", "Configuration", ";", "import", "android", ".", "content", ".", "res", ".", "Resources", ";", "import", "android", ".", "graphics", ".", "Bitmap", ";", "import", "android", ".", "graphics", ".", "Point", ";", "import", "android", ".", "os", ".", "Debug", ";", "import", "android", ".", "os", ".", "Handler", ";", "import", "android", ".", "os", ".", "Parcel", ";", "import", "android", ".", "os", ".", "Parcelable", ";", "import", "android", ".", "os", ".", "RemoteException", ";", "import", "android", ".", "os", ".", "ServiceManager", ";", "import", "android", ".", "os", ".", "SystemProperties", ";", "import", "android", ".", "text", ".", "TextUtils", ";", "import", "android", ".", "util", ".", "DisplayMetrics", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "util", ".", "Slog", ";", "import", "android", ".", "view", ".", "Display", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "public", "class", "ActivityManager", "{", "private", "static", "String", "TAG", "=", "\"\"", ";", "private", "static", "boolean", "localLOGV", "=", "false", ";", "private", "final", "Context", "mContext", ";", "private", "final", "Handler", "mHandler", ";", "ActivityManager", "(", "Context", "context", ",", "Handler", "handler", ")", "{", "mContext", "=", "context", ";", "mHandler", "=", "handler", ";", "}", "public", "static", "final", "int", "COMPAT_MODE_ALWAYS", "=", "-", "1", ";", "public", "static", "final", "int", "COMPAT_MODE_NEVER", "=", "-", "2", ";", "public", "static", "final", "int", "COMPAT_MODE_UNKNOWN", "=", "-", "3", ";", "public", "static", "final", "int", "COMPAT_MODE_DISABLED", "=", "0", ";", "public", "static", "final", "int", "COMPAT_MODE_ENABLED", "=", "1", ";", "public", "static", "final", "int", "COMPAT_MODE_TOGGLE", "=", "2", ";", "public", "int", "getFrontActivityScreenCompatMode", "(", ")", "{", "try", "{", "return", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "getFrontActivityScreenCompatMode", "(", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "return", "0", ";", "}", "}", "public", "void", "setFrontActivityScreenCompatMode", "(", "int", "mode", ")", "{", "try", "{", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "setFrontActivityScreenCompatMode", "(", "mode", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "public", "int", "getPackageScreenCompatMode", "(", "String", "packageName", ")", "{", "try", "{", "return", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "getPackageScreenCompatMode", "(", "packageName", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "return", "0", ";", "}", "}", "public", "void", "setPackageScreenCompatMode", "(", "String", "packageName", ",", "int", "mode", ")", "{", "try", "{", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "setPackageScreenCompatMode", "(", "packageName", ",", "mode", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "public", "boolean", "getPackageAskScreenCompat", "(", "String", "packageName", ")", "{", "try", "{", "return", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "getPackageAskScreenCompat", "(", "packageName", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "return", "false", ";", "}", "}", "public", "void", "setPackageAskScreenCompat", "(", "String", "packageName", ",", "boolean", "ask", ")", "{", "try", "{", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "setPackageAskScreenCompat", "(", "packageName", ",", "ask", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "public", "int", "getMemoryClass", "(", ")", "{", "return", "staticGetMemoryClass", "(", ")", ";", "}", "static", "public", "int", "staticGetMemoryClass", "(", ")", "{", "String", "vmHeapSize", "=", "SystemProperties", ".", "get", "(", "\"\"", ",", "\"\"", ")", ";", "if", "(", "vmHeapSize", "!=", "null", "&&", "!", "\"\"", ".", "equals", "(", "vmHeapSize", ")", ")", "{", "return", "Integer", ".", "parseInt", "(", "vmHeapSize", ".", "substring", "(", "0", ",", "vmHeapSize", ".", "length", "(", ")", "-", "1", ")", ")", ";", "}", "return", "staticGetLargeMemoryClass", "(", ")", ";", "}", "public", "int", "getLargeMemoryClass", "(", ")", "{", "return", "staticGetLargeMemoryClass", "(", ")", ";", "}", "static", "public", "int", "staticGetLargeMemoryClass", "(", ")", "{", "String", "vmHeapSize", "=", "SystemProperties", ".", "get", "(", "\"\"", ",", "\"16m\"", ")", ";", "return", "Integer", ".", "parseInt", "(", "vmHeapSize", ".", "substring", "(", "0", ",", "vmHeapSize", ".", "length", "(", ")", "-", "1", ")", ")", ";", "}", "static", "public", "boolean", "isHighEndGfx", "(", "Display", "display", ")", "{", "if", "(", "SystemProperties", ".", "get", "(", "\"\"", ")", ".", "equals", "(", "\"true\"", ")", ")", "{", "return", "false", ";", "}", "else", "{", "MemInfoReader", "reader", "=", "new", "MemInfoReader", "(", ")", ";", "reader", ".", "readMemInfo", "(", ")", ";", "if", "(", "reader", ".", "getTotalSize", "(", ")", ">=", "(", "512", "*", "1024", "*", "1024", ")", ")", "{", "return", "true", ";", "}", "Point", "p", "=", "new", "Point", "(", ")", ";", "display", ".", "getRealSize", "(", "p", ")", ";", "int", "pixels", "=", "p", ".", "x", "*", "p", ".", "y", ";", "if", "(", "pixels", ">=", "(", "800", "*", "480", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "}", "static", "public", "boolean", "isLargeRAM", "(", ")", "{", "MemInfoReader", "reader", "=", "new", "MemInfoReader", "(", ")", ";", "reader", ".", "readMemInfo", "(", ")", ";", "if", "(", "reader", ".", "getTotalSize", "(", ")", ">=", "(", "640", "*", "1024", "*", "1024", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "public", "static", "class", "RecentTaskInfo", "implements", "Parcelable", "{", "public", "int", "id", ";", "public", "int", "persistentId", ";", "public", "Intent", "baseIntent", ";", "public", "ComponentName", "origActivity", ";", "public", "CharSequence", "description", ";", "public", "RecentTaskInfo", "(", ")", "{", "}", "public", "int", "describeContents", "(", ")", "{", "return", "0", ";", "}", "public", "void", "writeToParcel", "(", "Parcel", "dest", ",", "int", "flags", ")", "{", "dest", ".", "writeInt", "(", "id", ")", ";", "dest", ".", "writeInt", "(", "persistentId", ")", ";", "if", "(", "baseIntent", "!=", "null", ")", "{", "dest", ".", "writeInt", "(", "1", ")", ";", "baseIntent", ".", "writeToParcel", "(", "dest", ",", "0", ")", ";", "}", "else", "{", "dest", ".", "writeInt", "(", "0", ")", ";", "}", "ComponentName", ".", "writeToParcel", "(", "origActivity", ",", "dest", ")", ";", "TextUtils", ".", "writeToParcel", "(", "description", ",", "dest", ",", "Parcelable", ".", "PARCELABLE_WRITE_RETURN_VALUE", ")", ";", "}", "public", "void", "readFromParcel", "(", "Parcel", "source", ")", "{", "id", "=", "source", ".", "readInt", "(", ")", ";", "persistentId", "=", "source", ".", "readInt", "(", ")", ";", "if", "(", "source", ".", "readInt", "(", ")", "!=", "0", ")", "{", "baseIntent", "=", "Intent", ".", "CREATOR", ".", "createFromParcel", "(", "source", ")", ";", "}", "else", "{", "baseIntent", "=", "null", ";", "}", "origActivity", "=", "ComponentName", ".", "readFromParcel", "(", "source", ")", ";", "description", "=", "TextUtils", ".", "CHAR_SEQUENCE_CREATOR", ".", "createFromParcel", "(", "source", ")", ";", "}", "public", "static", "final", "Creator", "<", "RecentTaskInfo", ">", "CREATOR", "=", "new", "Creator", "<", "RecentTaskInfo", ">", "(", ")", "{", "public", "RecentTaskInfo", "createFromParcel", "(", "Parcel", "source", ")", "{", "return", "new", "RecentTaskInfo", "(", "source", ")", ";", "}", "public", "RecentTaskInfo", "[", "]", "newArray", "(", "int", "size", ")", "{", "return", "new", "RecentTaskInfo", "[", "size", "]", ";", "}", "}", ";", "private", "RecentTaskInfo", "(", "Parcel", "source", ")", "{", "readFromParcel", "(", "source", ")", ";", "}", "}", "public", "static", "final", "int", "RECENT_WITH_EXCLUDED", "=", "0x0001", ";", "public", "static", "final", "int", "RECENT_IGNORE_UNAVAILABLE", "=", "0x0002", ";", "public", "List", "<", "RecentTaskInfo", ">", "getRecentTasks", "(", "int", "maxNum", ",", "int", "flags", ")", "throws", "SecurityException", "{", "try", "{", "return", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "getRecentTasks", "(", "maxNum", ",", "flags", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "return", "null", ";", "}", "}", "public", "static", "class", "RunningTaskInfo", "implements", "Parcelable", "{", "public", "int", "id", ";", "public", "ComponentName", "baseActivity", ";", "public", "ComponentName", "topActivity", ";", "public", "Bitmap", "thumbnail", ";", "public", "CharSequence", "description", ";", "public", "int", "numActivities", ";", "public", "int", "numRunning", ";", "public", "RunningTaskInfo", "(", ")", "{", "}", "public", "int", "describeContents", "(", ")", "{", "return", "0", ";", "}", "public", "void", "writeToParcel", "(", "Parcel", "dest", ",", "int", "flags", ")", "{", "dest", ".", "writeInt", "(", "id", ")", ";", "ComponentName", ".", "writeToParcel", "(", "baseActivity", ",", "dest", ")", ";", "ComponentName", ".", "writeToParcel", "(", "topActivity", ",", "dest", ")", ";", "if", "(", "thumbnail", "!=", "null", ")", "{", "dest", ".", "writeInt", "(", "1", ")", ";", "thumbnail", ".", "writeToParcel", "(", "dest", ",", "0", ")", ";", "}", "else", "{", "dest", ".", "writeInt", "(", "0", ")", ";", "}", "TextUtils", ".", "writeToParcel", "(", "description", ",", "dest", ",", "Parcelable", ".", "PARCELABLE_WRITE_RETURN_VALUE", ")", ";", "dest", ".", "writeInt", "(", "numActivities", ")", ";", "dest", ".", "writeInt", "(", "numRunning", ")", ";", "}", "public", "void", "readFromParcel", "(", "Parcel", "source", ")", "{", "id", "=", "source", ".", "readInt", "(", ")", ";", "baseActivity", "=", "ComponentName", ".", "readFromParcel", "(", "source", ")", ";", "topActivity", "=", "ComponentName", ".", "readFromParcel", "(", "source", ")", ";", "if", "(", "source", ".", "readInt", "(", ")", "!=", "0", ")", "{", "thumbnail", "=", "Bitmap", ".", "CREATOR", ".", "createFromParcel", "(", "source", ")", ";", "}", "else", "{", "thumbnail", "=", "null", ";", "}", "description", "=", "TextUtils", ".", "CHAR_SEQUENCE_CREATOR", ".", "createFromParcel", "(", "source", ")", ";", "numActivities", "=", "source", ".", "readInt", "(", ")", ";", "numRunning", "=", "source", ".", "readInt", "(", ")", ";", "}", "public", "static", "final", "Creator", "<", "RunningTaskInfo", ">", "CREATOR", "=", "new", "Creator", "<", "RunningTaskInfo", ">", "(", ")", "{", "public", "RunningTaskInfo", "createFromParcel", "(", "Parcel", "source", ")", "{", "return", "new", "RunningTaskInfo", "(", "source", ")", ";", "}", "public", "RunningTaskInfo", "[", "]", "newArray", "(", "int", "size", ")", "{", "return", "new", "RunningTaskInfo", "[", "size", "]", ";", "}", "}", ";", "private", "RunningTaskInfo", "(", "Parcel", "source", ")", "{", "readFromParcel", "(", "source", ")", ";", "}", "}", "public", "List", "<", "RunningTaskInfo", ">", "getRunningTasks", "(", "int", "maxNum", ",", "int", "flags", ",", "IThumbnailReceiver", "receiver", ")", "throws", "SecurityException", "{", "try", "{", "return", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "getTasks", "(", "maxNum", ",", "flags", ",", "receiver", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "return", "null", ";", "}", "}", "public", "List", "<", "RunningTaskInfo", ">", "getRunningTasks", "(", "int", "maxNum", ")", "throws", "SecurityException", "{", "return", "getRunningTasks", "(", "maxNum", ",", "0", ",", "null", ")", ";", "}", "public", "boolean", "removeSubTask", "(", "int", "taskId", ",", "int", "subTaskIndex", ")", "throws", "SecurityException", "{", "try", "{", "return", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "removeSubTask", "(", "taskId", ",", "subTaskIndex", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "return", "false", ";", "}", "}", "public", "static", "final", "int", "REMOVE_TASK_KILL_PROCESS", "=", "0x0001", ";", "public", "boolean", "removeTask", "(", "int", "taskId", ",", "int", "flags", ")", "throws", "SecurityException", "{", "try", "{", "return", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "removeTask", "(", "taskId", ",", "flags", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "return", "false", ";", "}", "}", "public", "static", "class", "TaskThumbnails", "implements", "Parcelable", "{", "public", "Bitmap", "mainThumbnail", ";", "public", "int", "numSubThumbbails", ";", "public", "IThumbnailRetriever", "retriever", ";", "public", "TaskThumbnails", "(", ")", "{", "}", "public", "Bitmap", "getSubThumbnail", "(", "int", "index", ")", "{", "try", "{", "return", "retriever", ".", "getThumbnail", "(", "index", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "return", "null", ";", "}", "}", "public", "int", "describeContents", "(", ")", "{", "return", "0", ";", "}", "public", "void", "writeToParcel", "(", "Parcel", "dest", ",", "int", "flags", ")", "{", "if", "(", "mainThumbnail", "!=", "null", ")", "{", "dest", ".", "writeInt", "(", "1", ")", ";", "mainThumbnail", ".", "writeToParcel", "(", "dest", ",", "0", ")", ";", "}", "else", "{", "dest", ".", "writeInt", "(", "0", ")", ";", "}", "dest", ".", "writeInt", "(", "numSubThumbbails", ")", ";", "dest", ".", "writeStrongInterface", "(", "retriever", ")", ";", "}", "public", "void", "readFromParcel", "(", "Parcel", "source", ")", "{", "if", "(", "source", ".", "readInt", "(", ")", "!=", "0", ")", "{", "mainThumbnail", "=", "Bitmap", ".", "CREATOR", ".", "createFromParcel", "(", "source", ")", ";", "}", "else", "{", "mainThumbnail", "=", "null", ";", "}", "numSubThumbbails", "=", "source", ".", "readInt", "(", ")", ";", "retriever", "=", "IThumbnailRetriever", ".", "Stub", ".", "asInterface", "(", "source", ".", "readStrongBinder", "(", ")", ")", ";", "}", "public", "static", "final", "Creator", "<", "TaskThumbnails", ">", "CREATOR", "=", "new", "Creator", "<", "TaskThumbnails", ">", "(", ")", "{", "public", "TaskThumbnails", "createFromParcel", "(", "Parcel", "source", ")", "{", "return", "new", "TaskThumbnails", "(", "source", ")", ";", "}", "public", "TaskThumbnails", "[", "]", "newArray", "(", "int", "size", ")", "{", "return", "new", "TaskThumbnails", "[", "size", "]", ";", "}", "}", ";", "private", "TaskThumbnails", "(", "Parcel", "source", ")", "{", "readFromParcel", "(", "source", ")", ";", "}", "}", "public", "TaskThumbnails", "getTaskThumbnails", "(", "int", "id", ")", "throws", "SecurityException", "{", "try", "{", "return", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "getTaskThumbnails", "(", "id", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "return", "null", ";", "}", "}", "public", "static", "final", "int", "MOVE_TASK_WITH_HOME", "=", "0x00000001", ";", "public", "static", "final", "int", "MOVE_TASK_NO_USER_ACTION", "=", "0x00000002", ";", "public", "void", "moveTaskToFront", "(", "int", "taskId", ",", "int", "flags", ")", "{", "try", "{", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "moveTaskToFront", "(", "taskId", ",", "flags", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "public", "static", "class", "RunningServiceInfo", "implements", "Parcelable", "{", "public", "ComponentName", "service", ";", "public", "int", "pid", ";", "public", "int", "uid", ";", "public", "String", "process", ";", "public", "boolean", "foreground", ";", "public", "long", "activeSince", ";", "public", "boolean", "started", ";", "public", "int", "clientCount", ";", "public", "int", "crashCount", ";", "public", "long", "lastActivityTime", ";", "public", "long", "restarting", ";", "public", "static", "final", "int", "FLAG_STARTED", "=", "1", "<<", "0", ";", "public", "static", "final", "int", "FLAG_FOREGROUND", "=", "1", "<<", "1", ";", "public", "static", "final", "int", "FLAG_SYSTEM_PROCESS", "=", "1", "<<", "2", ";", "public", "static", "final", "int", "FLAG_PERSISTENT_PROCESS", "=", "1", "<<", "3", ";", "public", "int", "flags", ";", "public", "String", "clientPackage", ";", "public", "int", "clientLabel", ";", "public", "RunningServiceInfo", "(", ")", "{", "}", "public", "int", "describeContents", "(", ")", "{", "return", "0", ";", "}", "public", "void", "writeToParcel", "(", "Parcel", "dest", ",", "int", "flags", ")", "{", "ComponentName", ".", "writeToParcel", "(", "service", ",", "dest", ")", ";", "dest", ".", "writeInt", "(", "pid", ")", ";", "dest", ".", "writeInt", "(", "uid", ")", ";", "dest", ".", "writeString", "(", "process", ")", ";", "dest", ".", "writeInt", "(", "foreground", "?", "1", ":", "0", ")", ";", "dest", ".", "writeLong", "(", "activeSince", ")", ";", "dest", ".", "writeInt", "(", "started", "?", "1", ":", "0", ")", ";", "dest", ".", "writeInt", "(", "clientCount", ")", ";", "dest", ".", "writeInt", "(", "crashCount", ")", ";", "dest", ".", "writeLong", "(", "lastActivityTime", ")", ";", "dest", ".", "writeLong", "(", "restarting", ")", ";", "dest", ".", "writeInt", "(", "this", ".", "flags", ")", ";", "dest", ".", "writeString", "(", "clientPackage", ")", ";", "dest", ".", "writeInt", "(", "clientLabel", ")", ";", "}", "public", "void", "readFromParcel", "(", "Parcel", "source", ")", "{", "service", "=", "ComponentName", ".", "readFromParcel", "(", "source", ")", ";", "pid", "=", "source", ".", "readInt", "(", ")", ";", "uid", "=", "source", ".", "readInt", "(", ")", ";", "process", "=", "source", ".", "readString", "(", ")", ";", "foreground", "=", "source", ".", "readInt", "(", ")", "!=", "0", ";", "activeSince", "=", "source", ".", "readLong", "(", ")", ";", "started", "=", "source", ".", "readInt", "(", ")", "!=", "0", ";", "clientCount", "=", "source", ".", "readInt", "(", ")", ";", "crashCount", "=", "source", ".", "readInt", "(", ")", ";", "lastActivityTime", "=", "source", ".", "readLong", "(", ")", ";", "restarting", "=", "source", ".", "readLong", "(", ")", ";", "flags", "=", "source", ".", "readInt", "(", ")", ";", "clientPackage", "=", "source", ".", "readString", "(", ")", ";", "clientLabel", "=", "source", ".", "readInt", "(", ")", ";", "}", "public", "static", "final", "Creator", "<", "RunningServiceInfo", ">", "CREATOR", "=", "new", "Creator", "<", "RunningServiceInfo", ">", "(", ")", "{", "public", "RunningServiceInfo", "createFromParcel", "(", "Parcel", "source", ")", "{", "return", "new", "RunningServiceInfo", "(", "source", ")", ";", "}", "public", "RunningServiceInfo", "[", "]", "newArray", "(", "int", "size", ")", "{", "return", "new", "RunningServiceInfo", "[", "size", "]", ";", "}", "}", ";", "private", "RunningServiceInfo", "(", "Parcel", "source", ")", "{", "readFromParcel", "(", "source", ")", ";", "}", "}", "public", "List", "<", "RunningServiceInfo", ">", "getRunningServices", "(", "int", "maxNum", ")", "throws", "SecurityException", "{", "try", "{", "return", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "getServices", "(", "maxNum", ",", "0", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "return", "null", ";", "}", "}", "public", "PendingIntent", "getRunningServiceControlPanel", "(", "ComponentName", "service", ")", "throws", "SecurityException", "{", "try", "{", "return", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "getRunningServiceControlPanel", "(", "service", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "return", "null", ";", "}", "}", "public", "static", "class", "MemoryInfo", "implements", "Parcelable", "{", "public", "long", "availMem", ";", "public", "long", "threshold", ";", "public", "boolean", "lowMemory", ";", "public", "long", "hiddenAppThreshold", ";", "public", "long", "secondaryServerThreshold", ";", "public", "long", "visibleAppThreshold", ";", "public", "long", "foregroundAppThreshold", ";", "public", "MemoryInfo", "(", ")", "{", "}", "public", "int", "describeContents", "(", ")", "{", "return", "0", ";", "}", "public", "void", "writeToParcel", "(", "Parcel", "dest", ",", "int", "flags", ")", "{", "dest", ".", "writeLong", "(", "availMem", ")", ";", "dest", ".", "writeLong", "(", "threshold", ")", ";", "dest", ".", "writeInt", "(", "lowMemory", "?", "1", ":", "0", ")", ";", "dest", ".", "writeLong", "(", "hiddenAppThreshold", ")", ";", "dest", ".", "writeLong", "(", "secondaryServerThreshold", ")", ";", "dest", ".", "writeLong", "(", "visibleAppThreshold", ")", ";", "dest", ".", "writeLong", "(", "foregroundAppThreshold", ")", ";", "}", "public", "void", "readFromParcel", "(", "Parcel", "source", ")", "{", "availMem", "=", "source", ".", "readLong", "(", ")", ";", "threshold", "=", "source", ".", "readLong", "(", ")", ";", "lowMemory", "=", "source", ".", "readInt", "(", ")", "!=", "0", ";", "hiddenAppThreshold", "=", "source", ".", "readLong", "(", ")", ";", "secondaryServerThreshold", "=", "source", ".", "readLong", "(", ")", ";", "visibleAppThreshold", "=", "source", ".", "readLong", "(", ")", ";", "foregroundAppThreshold", "=", "source", ".", "readLong", "(", ")", ";", "}", "public", "static", "final", "Creator", "<", "MemoryInfo", ">", "CREATOR", "=", "new", "Creator", "<", "MemoryInfo", ">", "(", ")", "{", "public", "MemoryInfo", "createFromParcel", "(", "Parcel", "source", ")", "{", "return", "new", "MemoryInfo", "(", "source", ")", ";", "}", "public", "MemoryInfo", "[", "]", "newArray", "(", "int", "size", ")", "{", "return", "new", "MemoryInfo", "[", "size", "]", ";", "}", "}", ";", "private", "MemoryInfo", "(", "Parcel", "source", ")", "{", "readFromParcel", "(", "source", ")", ";", "}", "}", "public", "void", "getMemoryInfo", "(", "MemoryInfo", "outInfo", ")", "{", "try", "{", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "getMemoryInfo", "(", "outInfo", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "public", "boolean", "clearApplicationUserData", "(", "String", "packageName", ",", "IPackageDataObserver", "observer", ")", "{", "try", "{", "return", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "clearApplicationUserData", "(", "packageName", ",", "observer", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "return", "false", ";", "}", "}", "public", "static", "class", "ProcessErrorStateInfo", "implements", "Parcelable", "{", "public", "static", "final", "int", "NO_ERROR", "=", "0", ";", "public", "static", "final", "int", "CRASHED", "=", "1", ";", "public", "static", "final", "int", "NOT_RESPONDING", "=", "2", ";", "public", "int", "condition", ";", "public", "String", "processName", ";", "public", "int", "pid", ";", "public", "int", "uid", ";", "public", "String", "tag", ";", "public", "String", "shortMsg", ";", "public", "String", "longMsg", ";", "public", "String", "stackTrace", ";", "public", "byte", "[", "]", "crashData", "=", "null", ";", "public", "ProcessErrorStateInfo", "(", ")", "{", "}", "public", "int", "describeContents", "(", ")", "{", "return", "0", ";", "}", "public", "void", "writeToParcel", "(", "Parcel", "dest", ",", "int", "flags", ")", "{", "dest", ".", "writeInt", "(", "condition", ")", ";", "dest", ".", "writeString", "(", "processName", ")", ";", "dest", ".", "writeInt", "(", "pid", ")", ";", "dest", ".", "writeInt", "(", "uid", ")", ";", "dest", ".", "writeString", "(", "tag", ")", ";", "dest", ".", "writeString", "(", "shortMsg", ")", ";", "dest", ".", "writeString", "(", "longMsg", ")", ";", "dest", ".", "writeString", "(", "stackTrace", ")", ";", "}", "public", "void", "readFromParcel", "(", "Parcel", "source", ")", "{", "condition", "=", "source", ".", "readInt", "(", ")", ";", "processName", "=", "source", ".", "readString", "(", ")", ";", "pid", "=", "source", ".", "readInt", "(", ")", ";", "uid", "=", "source", ".", "readInt", "(", ")", ";", "tag", "=", "source", ".", "readString", "(", ")", ";", "shortMsg", "=", "source", ".", "readString", "(", ")", ";", "longMsg", "=", "source", ".", "readString", "(", ")", ";", "stackTrace", "=", "source", ".", "readString", "(", ")", ";", "}", "public", "static", "final", "Creator", "<", "ProcessErrorStateInfo", ">", "CREATOR", "=", "new", "Creator", "<", "ProcessErrorStateInfo", ">", "(", ")", "{", "public", "ProcessErrorStateInfo", "createFromParcel", "(", "Parcel", "source", ")", "{", "return", "new", "ProcessErrorStateInfo", "(", "source", ")", ";", "}", "public", "ProcessErrorStateInfo", "[", "]", "newArray", "(", "int", "size", ")", "{", "return", "new", "ProcessErrorStateInfo", "[", "size", "]", ";", "}", "}", ";", "private", "ProcessErrorStateInfo", "(", "Parcel", "source", ")", "{", "readFromParcel", "(", "source", ")", ";", "}", "}", "public", "List", "<", "ProcessErrorStateInfo", ">", "getProcessesInErrorState", "(", ")", "{", "try", "{", "return", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "getProcessesInErrorState", "(", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "return", "null", ";", "}", "}", "public", "static", "class", "RunningAppProcessInfo", "implements", "Parcelable", "{", "public", "String", "processName", ";", "public", "int", "pid", ";", "public", "int", "uid", ";", "public", "String", "pkgList", "[", "]", ";", "public", "static", "final", "int", "FLAG_CANT_SAVE_STATE", "=", "1", "<<", "0", ";", "public", "static", "final", "int", "FLAG_PERSISTENT", "=", "1", "<<", "1", ";", "public", "int", "flags", ";", "public", "static", "final", "int", "IMPORTANCE_FOREGROUND", "=", "100", ";", "public", "static", "final", "int", "IMPORTANCE_VISIBLE", "=", "200", ";", "public", "static", "final", "int", "IMPORTANCE_PERCEPTIBLE", "=", "130", ";", "public", "static", "final", "int", "IMPORTANCE_CANT_SAVE_STATE", "=", "170", ";", "public", "static", "final", "int", "IMPORTANCE_SERVICE", "=", "300", ";", "public", "static", "final", "int", "IMPORTANCE_BACKGROUND", "=", "400", ";", "public", "static", "final", "int", "IMPORTANCE_EMPTY", "=", "500", ";", "public", "int", "importance", ";", "public", "int", "lru", ";", "public", "static", "final", "int", "REASON_UNKNOWN", "=", "0", ";", "public", "static", "final", "int", "REASON_PROVIDER_IN_USE", "=", "1", ";", "public", "static", "final", "int", "REASON_SERVICE_IN_USE", "=", "2", ";", "public", "int", "importanceReasonCode", ";", "public", "int", "importanceReasonPid", ";", "public", "ComponentName", "importanceReasonComponent", ";", "public", "int", "importanceReasonImportance", ";", "public", "RunningAppProcessInfo", "(", ")", "{", "importance", "=", "IMPORTANCE_FOREGROUND", ";", "importanceReasonCode", "=", "REASON_UNKNOWN", ";", "}", "public", "RunningAppProcessInfo", "(", "String", "pProcessName", ",", "int", "pPid", ",", "String", "pArr", "[", "]", ")", "{", "processName", "=", "pProcessName", ";", "pid", "=", "pPid", ";", "pkgList", "=", "pArr", ";", "}", "public", "int", "describeContents", "(", ")", "{", "return", "0", ";", "}", "public", "void", "writeToParcel", "(", "Parcel", "dest", ",", "int", "flags", ")", "{", "dest", ".", "writeString", "(", "processName", ")", ";", "dest", ".", "writeInt", "(", "pid", ")", ";", "dest", ".", "writeInt", "(", "uid", ")", ";", "dest", ".", "writeStringArray", "(", "pkgList", ")", ";", "dest", ".", "writeInt", "(", "this", ".", "flags", ")", ";", "dest", ".", "writeInt", "(", "importance", ")", ";", "dest", ".", "writeInt", "(", "lru", ")", ";", "dest", ".", "writeInt", "(", "importanceReasonCode", ")", ";", "dest", ".", "writeInt", "(", "importanceReasonPid", ")", ";", "ComponentName", ".", "writeToParcel", "(", "importanceReasonComponent", ",", "dest", ")", ";", "dest", ".", "writeInt", "(", "importanceReasonImportance", ")", ";", "}", "public", "void", "readFromParcel", "(", "Parcel", "source", ")", "{", "processName", "=", "source", ".", "readString", "(", ")", ";", "pid", "=", "source", ".", "readInt", "(", ")", ";", "uid", "=", "source", ".", "readInt", "(", ")", ";", "pkgList", "=", "source", ".", "readStringArray", "(", ")", ";", "flags", "=", "source", ".", "readInt", "(", ")", ";", "importance", "=", "source", ".", "readInt", "(", ")", ";", "lru", "=", "source", ".", "readInt", "(", ")", ";", "importanceReasonCode", "=", "source", ".", "readInt", "(", ")", ";", "importanceReasonPid", "=", "source", ".", "readInt", "(", ")", ";", "importanceReasonComponent", "=", "ComponentName", ".", "readFromParcel", "(", "source", ")", ";", "importanceReasonImportance", "=", "source", ".", "readInt", "(", ")", ";", "}", "public", "static", "final", "Creator", "<", "RunningAppProcessInfo", ">", "CREATOR", "=", "new", "Creator", "<", "RunningAppProcessInfo", ">", "(", ")", "{", "public", "RunningAppProcessInfo", "createFromParcel", "(", "Parcel", "source", ")", "{", "return", "new", "RunningAppProcessInfo", "(", "source", ")", ";", "}", "public", "RunningAppProcessInfo", "[", "]", "newArray", "(", "int", "size", ")", "{", "return", "new", "RunningAppProcessInfo", "[", "size", "]", ";", "}", "}", ";", "private", "RunningAppProcessInfo", "(", "Parcel", "source", ")", "{", "readFromParcel", "(", "source", ")", ";", "}", "}", "public", "List", "<", "ApplicationInfo", ">", "getRunningExternalApplications", "(", ")", "{", "try", "{", "return", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "getRunningExternalApplications", "(", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "return", "null", ";", "}", "}", "public", "List", "<", "RunningAppProcessInfo", ">", "getRunningAppProcesses", "(", ")", "{", "try", "{", "return", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "getRunningAppProcesses", "(", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "return", "null", ";", "}", "}", "public", "Debug", ".", "MemoryInfo", "[", "]", "getProcessMemoryInfo", "(", "int", "[", "]", "pids", ")", "{", "try", "{", "return", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "getProcessMemoryInfo", "(", "pids", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "return", "null", ";", "}", "}", "@", "Deprecated", "public", "void", "restartPackage", "(", "String", "packageName", ")", "{", "killBackgroundProcesses", "(", "packageName", ")", ";", "}", "public", "void", "killBackgroundProcesses", "(", "String", "packageName", ")", "{", "try", "{", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "killBackgroundProcesses", "(", "packageName", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "public", "void", "forceStopPackage", "(", "String", "packageName", ")", "{", "try", "{", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "forceStopPackage", "(", "packageName", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "public", "ConfigurationInfo", "getDeviceConfigurationInfo", "(", ")", "{", "try", "{", "return", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "getDeviceConfigurationInfo", "(", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "return", "null", ";", "}", "public", "int", "getLauncherLargeIconDensity", "(", ")", "{", "final", "Resources", "res", "=", "mContext", ".", "getResources", "(", ")", ";", "final", "int", "density", "=", "res", ".", "getDisplayMetrics", "(", ")", ".", "densityDpi", ";", "if", "(", "(", "res", ".", "getConfiguration", "(", ")", ".", "screenLayout", "&", "Configuration", ".", "SCREENLAYOUT_SIZE_MASK", ")", "!=", "Configuration", ".", "SCREENLAYOUT_SIZE_XLARGE", ")", "{", "return", "density", ";", "}", "switch", "(", "density", ")", "{", "case", "DisplayMetrics", ".", "DENSITY_LOW", ":", "return", "DisplayMetrics", ".", "DENSITY_MEDIUM", ";", "case", "DisplayMetrics", ".", "DENSITY_MEDIUM", ":", "return", "DisplayMetrics", ".", "DENSITY_HIGH", ";", "case", "DisplayMetrics", ".", "DENSITY_HIGH", ":", "return", "DisplayMetrics", ".", "DENSITY_XHIGH", ";", "case", "DisplayMetrics", ".", "DENSITY_XHIGH", ":", "return", "DisplayMetrics", ".", "DENSITY_MEDIUM", "*", "2", ";", "default", ":", "return", "density", ";", "}", "}", "public", "int", "getLauncherLargeIconSize", "(", ")", "{", "final", "Resources", "res", "=", "mContext", ".", "getResources", "(", ")", ";", "final", "int", "size", "=", "res", ".", "getDimensionPixelSize", "(", "android", ".", "R", ".", "dimen", ".", "app_icon_size", ")", ";", "if", "(", "(", "res", ".", "getConfiguration", "(", ")", ".", "screenLayout", "&", "Configuration", ".", "SCREENLAYOUT_SIZE_MASK", ")", "!=", "Configuration", ".", "SCREENLAYOUT_SIZE_XLARGE", ")", "{", "return", "size", ";", "}", "final", "int", "density", "=", "res", ".", "getDisplayMetrics", "(", ")", ".", "densityDpi", ";", "switch", "(", "density", ")", "{", "case", "DisplayMetrics", ".", "DENSITY_LOW", ":", "return", "(", "size", "*", "DisplayMetrics", ".", "DENSITY_MEDIUM", ")", "/", "DisplayMetrics", ".", "DENSITY_LOW", ";", "case", "DisplayMetrics", ".", "DENSITY_MEDIUM", ":", "return", "(", "size", "*", "DisplayMetrics", ".", "DENSITY_HIGH", ")", "/", "DisplayMetrics", ".", "DENSITY_MEDIUM", ";", "case", "DisplayMetrics", ".", "DENSITY_HIGH", ":", "return", "(", "size", "*", "DisplayMetrics", ".", "DENSITY_XHIGH", ")", "/", "DisplayMetrics", ".", "DENSITY_HIGH", ";", "case", "DisplayMetrics", ".", "DENSITY_XHIGH", ":", "return", "(", "size", "*", "DisplayMetrics", ".", "DENSITY_MEDIUM", "*", "2", ")", "/", "DisplayMetrics", ".", "DENSITY_XHIGH", ";", "default", ":", "return", "size", ";", "}", "}", "public", "static", "boolean", "isUserAMonkey", "(", ")", "{", "try", "{", "return", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "isUserAMonkey", "(", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "return", "false", ";", "}", "public", "static", "boolean", "isRunningInTestHarness", "(", ")", "{", "return", "SystemProperties", ".", "getBoolean", "(", "\"\"", ",", "false", ")", ";", "}", "public", "Map", "<", "String", ",", "Integer", ">", "getAllPackageLaunchCounts", "(", ")", "{", "try", "{", "IUsageStats", "usageStatsService", "=", "IUsageStats", ".", "Stub", ".", "asInterface", "(", "ServiceManager", ".", "getService", "(", "\"usagestats\"", ")", ")", ";", "if", "(", "usageStatsService", "==", "null", ")", "{", "return", "new", "HashMap", "<", "String", ",", "Integer", ">", "(", ")", ";", "}", "PkgUsageStats", "[", "]", "allPkgUsageStats", "=", "usageStatsService", ".", "getAllPkgUsageStats", "(", ")", ";", "if", "(", "allPkgUsageStats", "==", "null", ")", "{", "return", "new", "HashMap", "<", "String", ",", "Integer", ">", "(", ")", ";", "}", "Map", "<", "String", ",", "Integer", ">", "launchCounts", "=", "new", "HashMap", "<", "String", ",", "Integer", ">", "(", ")", ";", "for", "(", "PkgUsageStats", "pkgUsageStats", ":", "allPkgUsageStats", ")", "{", "launchCounts", ".", "put", "(", "pkgUsageStats", ".", "packageName", ",", "pkgUsageStats", ".", "launchCount", ")", ";", "}", "return", "launchCounts", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "Log", ".", "w", "(", "TAG", ",", "\"\"", ",", "e", ")", ";", "return", "new", "HashMap", "<", "String", ",", "Integer", ">", "(", ")", ";", "}", "}", "public", "Configuration", "getConfiguration", "(", ")", "{", "try", "{", "return", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "getConfiguration", "(", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "return", "null", ";", "}", "}", "public", "PkgUsageStats", "[", "]", "getAllPackageUsageStats", "(", ")", "{", "try", "{", "IUsageStats", "usageStatsService", "=", "IUsageStats", ".", "Stub", ".", "asInterface", "(", "ServiceManager", ".", "getService", "(", "\"usagestats\"", ")", ")", ";", "if", "(", "usageStatsService", "!=", "null", ")", "{", "return", "usageStatsService", ".", "getAllPkgUsageStats", "(", ")", ";", "}", "}", "catch", "(", "RemoteException", "e", ")", "{", "Log", ".", "w", "(", "TAG", ",", "\"\"", ",", "e", ")", ";", "}", "return", "new", "PkgUsageStats", "[", "0", "]", ";", "}", "public", "boolean", "switchUser", "(", "int", "userid", ")", "{", "try", "{", "return", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "switchUser", "(", "userid", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "return", "false", ";", "}", "}", "public", "void", "updateConfiguration", "(", "Configuration", "values", ")", "throws", "SecurityException", "{", "try", "{", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "updateConfiguration", "(", "values", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "}", "</s>" ]
8,202
[ "<s>", "package", "com", ".", "android", ".", "internal", ".", "policy", ".", "impl", ";", "import", "android", ".", "app", ".", "Activity", ";", "import", "android", ".", "app", ".", "ActivityManagerNative", ";", "import", "android", ".", "app", ".", "ActivityManager", ".", "RunningAppProcessInfo", ";", "import", "android", ".", "app", ".", "IActivityManager", ";", "import", "android", ".", "app", ".", "IUiModeManager", ";", "import", "android", ".", "app", ".", "ProgressDialog", ";", "import", "android", ".", "app", ".", "UiModeManager", ";", "import", "android", ".", "content", ".", "ActivityNotFoundException", ";", "import", "android", ".", "content", ".", "BroadcastReceiver", ";", "import", "android", ".", "content", ".", "ComponentName", ";", "import", "android", ".", "content", ".", "ContentResolver", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "ContextWrapper", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "content", ".", "IntentFilter", ";", "import", "android", ".", "content", ".", "ServiceConnection", ";", "import", "android", ".", "content", ".", "pm", ".", "ActivityInfo", ";", "import", "android", ".", "content", ".", "pm", ".", "PackageManager", ";", "import", "android", ".", "content", ".", "res", ".", "CompatibilityInfo", ";", "import", "android", ".", "content", ".", "res", ".", "Configuration", ";", "import", "android", ".", "content", ".", "res", ".", "Resources", ";", "import", "android", ".", "database", ".", "ContentObserver", ";", "import", "android", ".", "graphics", ".", "PixelFormat", ";", "import", "android", ".", "graphics", ".", "Rect", ";", "import", "android", ".", "graphics", ".", "RectF", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "os", ".", "Handler", ";", "import", "android", ".", "os", ".", "IBinder", ";", "import", "android", ".", "os", ".", "IRemoteCallback", ";", "import", "android", ".", "os", ".", "LocalPowerManager", ";", "import", "android", ".", "os", ".", "Message", ";", "import", "android", ".", "os", ".", "Messenger", ";", "import", "android", ".", "os", ".", "PowerManager", ";", "import", "android", ".", "os", ".", "Process", ";", "import", "android", ".", "os", ".", "RemoteException", ";", "import", "android", ".", "os", ".", "ServiceManager", ";", "import", "android", ".", "os", ".", "SystemClock", ";", "import", "android", ".", "os", ".", "SystemProperties", ";", "import", "android", ".", "os", ".", "UEventObserver", ";", "import", "android", ".", "os", ".", "Vibrator", ";", "import", "android", ".", "media", ".", "MediaPlayer", ";", "import", "android", ".", "provider", ".", "Settings", ";", "import", "com", ".", "android", ".", "internal", ".", "R", ";", "import", "com", ".", "android", ".", "internal", ".", "app", ".", "ShutdownThread", ";", "import", "com", ".", "android", ".", "internal", ".", "app", ".", "ThemeUtils", ";", "import", "com", ".", "android", ".", "internal", ".", "os", ".", "DeviceKeyHandler", ";", "import", "com", ".", "android", ".", "internal", ".", "policy", ".", "PolicyManager", ";", "import", "com", ".", "android", ".", "internal", ".", "statusbar", ".", "IStatusBarService", ";", "import", "com", ".", "android", ".", "internal", ".", "telephony", ".", "ITelephony", ";", "import", "com", ".", "android", ".", "internal", ".", "view", ".", "BaseInputHandler", ";", "import", "com", ".", "android", ".", "internal", ".", "widget", ".", "PointerLocationView", ";", "import", "dalvik", ".", "system", ".", "DexClassLoader", ";", "import", "android", ".", "util", ".", "DisplayMetrics", ";", "import", "android", ".", "util", ".", "EventLog", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "util", ".", "Slog", ";", "import", "android", ".", "util", ".", "SparseArray", ";", "import", "android", ".", "view", ".", "Gravity", ";", "import", "android", ".", "view", ".", "HapticFeedbackConstants", ";", "import", "android", ".", "view", ".", "IApplicationToken", ";", "import", "android", ".", "view", ".", "IWindowManager", ";", "import", "android", ".", "view", ".", "InputChannel", ";", "import", "android", ".", "view", ".", "InputDevice", ";", "import", "android", ".", "view", ".", "InputQueue", ";", "import", "android", ".", "view", ".", "InputHandler", ";", "import", "android", ".", "view", ".", "KeyCharacterMap", ";", "import", "android", ".", "view", ".", "KeyEvent", ";", "import", "android", ".", "view", ".", "MotionEvent", ";", "import", "android", ".", "view", ".", "WindowOrientationListener", ";", "import", "android", ".", "view", ".", "Surface", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "view", ".", "ViewConfiguration", ";", "import", "android", ".", "view", ".", "Window", ";", "import", "android", ".", "view", ".", "WindowManager", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "FIRST_APPLICATION_WINDOW", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "FLAG_FORCE_NOT_FULLSCREEN", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "FLAG_FULLSCREEN", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "FLAG_LAYOUT_IN_SCREEN", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "FLAG_LAYOUT_INSET_DECOR", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "FLAG_LAYOUT_NO_LIMITS", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "FLAG_SHOW_WHEN_LOCKED", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "FLAG_DISMISS_KEYGUARD", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "SOFT_INPUT_MASK_ADJUST", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "SOFT_INPUT_ADJUST_RESIZE", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "SOFT_INPUT_ADJUST_NOTHING", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "LAST_APPLICATION_WINDOW", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_APPLICATION_MEDIA", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_APPLICATION_MEDIA_OVERLAY", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_APPLICATION_PANEL", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_APPLICATION_SUB_PANEL", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_APPLICATION_ATTACHED_DIALOG", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_DRAG", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_HIDDEN_NAV_CONSUMER", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_KEYGUARD", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_KEYGUARD_DIALOG", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_PHONE", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_PRIORITY_PHONE", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_SEARCH_BAR", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_SECURE_SYSTEM_OVERLAY", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_STATUS_BAR", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_STATUS_BAR_PANEL", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_STATUS_BAR_SUB_PANEL", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_SYSTEM_DIALOG", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_SYSTEM_ALERT", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_SYSTEM_ERROR", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_INPUT_METHOD", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_INPUT_METHOD_DIALOG", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_SYSTEM_OVERLAY", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_TOAST", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_VOLUME_OVERLAY", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_WALLPAPER", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_POINTER", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_NAVIGATION_BAR", ";", "import", "static", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ".", "TYPE_BOOT_PROGRESS", ";", "import", "android", ".", "view", ".", "WindowManagerImpl", ";", "import", "android", ".", "view", ".", "WindowManagerPolicy", ";", "import", "android", ".", "view", ".", "KeyCharacterMap", ".", "FallbackAction", ";", "import", "android", ".", "view", ".", "accessibility", ".", "AccessibilityEvent", ";", "import", "android", ".", "view", ".", "animation", ".", "Animation", ";", "import", "android", ".", "view", ".", "animation", ".", "AnimationUtils", ";", "import", "android", ".", "view", ".", "VolumePanel", ";", "import", "android", ".", "widget", ".", "Toast", ";", "import", "android", ".", "media", ".", "IAudioService", ";", "import", "android", ".", "media", ".", "AudioService", ";", "import", "android", ".", "media", ".", "AudioManager", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileDescriptor", ";", "import", "java", ".", "io", ".", "FileReader", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "PrintWriter", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Constructor", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "android", ".", "view", ".", "DisplayManager", ";", "public", "class", "PhoneWindowManager", "implements", "WindowManagerPolicy", "{", "static", "final", "String", "TAG", "=", "\"\"", ";", "static", "final", "boolean", "DEBUG", "=", "false", ";", "static", "final", "boolean", "localLOGV", "=", "false", ";", "static", "final", "boolean", "DEBUG_LAYOUT", "=", "false", ";", "static", "final", "boolean", "DEBUG_FALLBACK", "=", "false", ";", "static", "final", "boolean", "SHOW_STARTING_ANIMATIONS", "=", "true", ";", "static", "final", "boolean", "SHOW_PROCESSES_ON_ALT_MENU", "=", "false", ";", "static", "final", "boolean", "ENABLE_CAR_DOCK_HOME_CAPTURE", "=", "true", ";", "static", "final", "boolean", "ENABLE_DESK_DOCK_HOME_CAPTURE", "=", "false", ";", "static", "final", "int", "LONG_PRESS_POWER_NOTHING", "=", "0", ";", "static", "final", "int", "LONG_PRESS_POWER_GLOBAL_ACTIONS", "=", "1", ";", "static", "final", "int", "LONG_PRESS_POWER_SHUT_OFF", "=", "2", ";", "static", "final", "int", "LONG_PRESS_HOME_NOTHING", "=", "0", ";", "static", "final", "int", "LONG_PRESS_HOME_RECENT_DIALOG", "=", "1", ";", "static", "final", "int", "LONG_PRESS_HOME_RECENT_SYSTEM_UI", "=", "2", ";", "static", "final", "int", "LONG_PRESS_MENU_NOTHING", "=", "0", ";", "static", "final", "int", "LONG_PRESS_MENU_SEARCH", "=", "1", ";", "private", "static", "final", "int", "KEY_MASK_HOME", "=", "0x01", ";", "private", "static", "final", "int", "KEY_MASK_BACK", "=", "0x02", ";", "private", "static", "final", "int", "KEY_MASK_MENU", "=", "0x04", ";", "private", "static", "final", "int", "KEY_MASK_SEARCH", "=", "0x08", ";", "private", "static", "final", "int", "KEY_MASK_APP_SWITCH", "=", "0x10", ";", "static", "final", "int", "WALLPAPER_LAYER", "=", "2", ";", "static", "final", "int", "APPLICATION_LAYER", "=", "2", ";", "static", "final", "int", "PHONE_LAYER", "=", "3", ";", "static", "final", "int", "SEARCH_BAR_LAYER", "=", "4", ";", "static", "final", "int", "SYSTEM_DIALOG_LAYER", "=", "5", ";", "static", "final", "int", "TOAST_LAYER", "=", "6", ";", "static", "final", "int", "PRIORITY_PHONE_LAYER", "=", "7", ";", "static", "final", "int", "SYSTEM_ALERT_LAYER", "=", "8", ";", "static", "final", "int", "INPUT_METHOD_LAYER", "=", "9", ";", "static", "final", "int", "INPUT_METHOD_DIALOG_LAYER", "=", "10", ";", "static", "final", "int", "KEYGUARD_LAYER", "=", "11", ";", "static", "final", "int", "KEYGUARD_DIALOG_LAYER", "=", "12", ";", "static", "final", "int", "STATUS_BAR_SUB_PANEL_LAYER", "=", "13", ";", "static", "final", "int", "STATUS_BAR_LAYER", "=", "14", ";", "static", "final", "int", "STATUS_BAR_PANEL_LAYER", "=", "15", ";", "static", "final", "int", "VOLUME_OVERLAY_LAYER", "=", "16", ";", "static", "final", "int", "SYSTEM_OVERLAY_LAYER", "=", "17", ";", "static", "final", "int", "NAVIGATION_BAR_LAYER", "=", "18", ";", "static", "final", "int", "SYSTEM_ERROR_LAYER", "=", "19", ";", "static", "final", "int", "DRAG_LAYER", "=", "20", ";", "static", "final", "int", "SECURE_SYSTEM_OVERLAY_LAYER", "=", "21", ";", "static", "final", "int", "BOOT_PROGRESS_LAYER", "=", "22", ";", "static", "final", "int", "POINTER_LAYER", "=", "23", ";", "static", "final", "int", "HIDDEN_NAV_CONSUMER_LAYER", "=", "24", ";", "static", "final", "int", "APPLICATION_MEDIA_SUBLAYER", "=", "-", "2", ";", "static", "final", "int", "APPLICATION_MEDIA_OVERLAY_SUBLAYER", "=", "-", "1", ";", "static", "final", "int", "APPLICATION_PANEL_SUBLAYER", "=", "1", ";", "static", "final", "int", "APPLICATION_SUB_PANEL_SUBLAYER", "=", "2", ";", "static", "public", "final", "String", "SYSTEM_DIALOG_REASON_KEY", "=", "\"reason\"", ";", "static", "public", "final", "String", "SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS", "=", "\"\"", ";", "static", "public", "final", "String", "SYSTEM_DIALOG_REASON_RECENT_APPS", "=", "\"recentapps\"", ";", "static", "public", "final", "String", "SYSTEM_DIALOG_REASON_HOME_KEY", "=", "\"homekey\"", ";", "private", "static", "final", "int", "SW_LID", "=", "0x00", ";", "private", "static", "final", "int", "BTN_MOUSE", "=", "0x110", ";", "static", "SparseArray", "<", "String", ">", "sApplicationLaunchKeyCategories", ";", "static", "{", "sApplicationLaunchKeyCategories", "=", "new", "SparseArray", "<", "String", ">", "(", ")", ";", "sApplicationLaunchKeyCategories", ".", "append", "(", "KeyEvent", ".", "KEYCODE_EXPLORER", ",", "Intent", ".", "CATEGORY_APP_BROWSER", ")", ";", "sApplicationLaunchKeyCategories", ".", "append", "(", "KeyEvent", ".", "KEYCODE_ENVELOPE", ",", "Intent", ".", "CATEGORY_APP_EMAIL", ")", ";", "sApplicationLaunchKeyCategories", ".", "append", "(", "KeyEvent", ".", "KEYCODE_CONTACTS", ",", "Intent", ".", "CATEGORY_APP_CONTACTS", ")", ";", "sApplicationLaunchKeyCategories", ".", "append", "(", "KeyEvent", ".", "KEYCODE_CALENDAR", ",", "Intent", ".", "CATEGORY_APP_CALENDAR", ")", ";", "sApplicationLaunchKeyCategories", ".", "append", "(", "KeyEvent", ".", "KEYCODE_MUSIC", ",", "Intent", ".", "CATEGORY_APP_MUSIC", ")", ";", "sApplicationLaunchKeyCategories", ".", "append", "(", "KeyEvent", ".", "KEYCODE_CALCULATOR", ",", "Intent", ".", "CATEGORY_APP_CALCULATOR", ")", ";", "}", "DeviceKeyHandler", "mDeviceKeyHandler", ";", "final", "Object", "mLock", "=", "new", "Object", "(", ")", ";", "Context", "mContext", ";", "Context", "mUiContext", ";", "IWindowManager", "mWindowManager", ";", "WindowManagerFuncs", "mWindowManagerFuncs", ";", "LocalPowerManager", "mPowerManager", ";", "IStatusBarService", "mStatusBarService", ";", "Vibrator", "mVibrator", ";", "long", "[", "]", "mLongPressVibePattern", ";", "long", "[", "]", "mVirtualKeyVibePattern", ";", "long", "[", "]", "mKeyboardTapVibePattern", ";", "long", "[", "]", "mSafeModeDisabledVibePattern", ";", "long", "[", "]", "mSafeModeEnabledVibePattern", ";", "boolean", "mEnableShiftMenuBugReports", "=", "false", ";", "boolean", "mSafeMode", ";", "WindowState", "mStatusBar", "=", "null", ";", "boolean", "mStatusBarCanHide", ";", "int", "mStatusBarHeight", ";", "final", "ArrayList", "<", "WindowState", ">", "mStatusBarPanels", "=", "new", "ArrayList", "<", "WindowState", ">", "(", ")", ";", "WindowState", "mNavigationBar", "=", "null", ";", "boolean", "mHasNavigationBar", "=", "false", ";", "int", "mNavigationBarWidth", "=", "0", ",", "mNavigationBarHeight", "=", "0", ";", "WindowState", "mKeyguard", "=", "null", ";", "KeyguardViewMediator", "mKeyguardMediator", ";", "GlobalActions", "mGlobalActions", ";", "volatile", "boolean", "mPowerKeyHandled", ";", "boolean", "mPendingPowerKeyUpCanceled", ";", "Handler", "mHandler", ";", "static", "final", "int", "RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS", "=", "0", ";", "static", "final", "int", "RECENT_APPS_BEHAVIOR_EXIT_TOUCH_MODE_AND_SHOW", "=", "1", ";", "static", "final", "int", "RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH", "=", "2", ";", "RecentApplicationsDialog", "mRecentAppsDialog", ";", "int", "mRecentAppsDialogHeldModifiers", ";", "private", "static", "final", "int", "LID_ABSENT", "=", "-", "1", ";", "private", "static", "final", "int", "LID_CLOSED", "=", "0", ";", "private", "static", "final", "int", "LID_OPEN", "=", "1", ";", "int", "mLidOpen", "=", "LID_ABSENT", ";", "boolean", "mSystemReady", ";", "boolean", "mSystemBooted", ";", "boolean", "mHdmiPlugged", ";", "int", "mUiMode", "=", "Configuration", ".", "UI_MODE_TYPE_NORMAL", ";", "int", "mDockMode", "=", "Intent", ".", "EXTRA_DOCK_STATE_UNDOCKED", ";", "int", "mLidOpenRotation", ";", "int", "mCarDockRotation", ";", "int", "mDeskDockRotation", ";", "int", "mHdmiRotation", ";", "int", "mUserRotationMode", "=", "WindowManagerPolicy", ".", "USER_ROTATION_FREE", ";", "int", "mUserRotation", "=", "Surface", ".", "ROTATION_0", ";", "int", "mUserRotationAngles", "=", "-", "1", ";", "int", "mAllowAllRotations", "=", "-", "1", ";", "boolean", "mCarDockEnablesAccelerometer", ";", "boolean", "mDeskDockEnablesAccelerometer", ";", "int", "mLidKeyboardAccessibility", ";", "int", "mLidNavigationAccessibility", ";", "int", "mLongPressOnPowerBehavior", "=", "-", "1", ";", "boolean", "mScreenOnEarly", "=", "false", ";", "boolean", "mScreenOnFully", "=", "false", ";", "boolean", "mOrientationSensorEnabled", "=", "false", ";", "int", "mCurrentAppOrientation", "=", "ActivityInfo", ".", "SCREEN_ORIENTATION_UNSPECIFIED", ";", "static", "final", "int", "DEFAULT_ACCELEROMETER_ROTATION", "=", "0", ";", "int", "mAccelerometerDefault", "=", "DEFAULT_ACCELEROMETER_ROTATION", ";", "boolean", "mHasSoftInput", "=", "false", ";", "int", "mPointerLocationMode", "=", "0", ";", "PointerLocationView", "mPointerLocationView", "=", "null", ";", "InputChannel", "mPointerLocationInputChannel", ";", "WindowState", "mFocusedWindow", ";", "IApplicationToken", "mFocusedApp", ";", "boolean", "mVolumeWakeScreen", ";", "boolean", "mVolBtnMusicControls", ";", "boolean", "mIsLongPress", ";", "private", "final", "InputHandler", "mPointerLocationInputHandler", "=", "new", "BaseInputHandler", "(", ")", "{", "@", "Override", "public", "void", "handleMotion", "(", "MotionEvent", "event", ",", "InputQueue", ".", "FinishedCallback", "finishedCallback", ")", "{", "boolean", "handled", "=", "false", ";", "try", "{", "if", "(", "(", "event", ".", "getSource", "(", ")", "&", "InputDevice", ".", "SOURCE_CLASS_POINTER", ")", "!=", "0", ")", "{", "synchronized", "(", "mLock", ")", "{", "if", "(", "mPointerLocationView", "!=", "null", ")", "{", "mPointerLocationView", ".", "addPointerEvent", "(", "event", ")", ";", "handled", "=", "true", ";", "}", "}", "}", "}", "finally", "{", "finishedCallback", ".", "finished", "(", "handled", ")", ";", "}", "}", "}", ";", "int", "mUnrestrictedScreenLeft", ",", "mUnrestrictedScreenTop", ";", "int", "mUnrestrictedScreenWidth", ",", "mUnrestrictedScreenHeight", ";", "int", "mRestrictedScreenLeft", ",", "mRestrictedScreenTop", ";", "int", "mRestrictedScreenWidth", ",", "mRestrictedScreenHeight", ";", "int", "mCurLeft", ",", "mCurTop", ",", "mCurRight", ",", "mCurBottom", ";", "int", "mContentLeft", ",", "mContentTop", ",", "mContentRight", ",", "mContentBottom", ";", "int", "mDockLeft", ",", "mDockTop", ",", "mDockRight", ",", "mDockBottom", ";", "int", "mDockLayer", ";", "int", "mLastSystemUiFlags", ";", "int", "mResettingSystemUiFlags", "=", "0", ";", "int", "mForceClearedSystemUiFlags", "=", "0", ";", "boolean", "mLastFocusNeedsMenu", "=", "false", ";", "FakeWindow", "mHideNavFakeWindow", "=", "null", ";", "static", "final", "Rect", "mTmpParentFrame", "=", "new", "Rect", "(", ")", ";", "static", "final", "Rect", "mTmpDisplayFrame", "=", "new", "Rect", "(", ")", ";", "static", "final", "Rect", "mTmpContentFrame", "=", "new", "Rect", "(", ")", ";", "static", "final", "Rect", "mTmpVisibleFrame", "=", "new", "Rect", "(", ")", ";", "static", "final", "Rect", "mTmpNavigationFrame", "=", "new", "Rect", "(", ")", ";", "WindowState", "mTopFullscreenOpaqueWindowState", ";", "boolean", "mTopIsFullscreen", ";", "boolean", "mForceStatusBar", ";", "boolean", "mHideLockScreen", ";", "boolean", "mDismissKeyguard", ";", "boolean", "mHomePressed", ";", "boolean", "mAppSwitchPressed", ";", "Intent", "mHomeIntent", ";", "Intent", "mCarDockIntent", ";", "Intent", "mDeskDockIntent", ";", "int", "mShortcutKeyPressed", "=", "-", "1", ";", "boolean", "mConsumeShortcutKeyUp", ";", "boolean", "mAllowLockscreenWhenOn", ";", "int", "mLockScreenTimeout", ";", "boolean", "mLockScreenTimerActive", ";", "int", "mEndcallBehavior", ";", "int", "mIncallPowerBehavior", ";", "int", "mLandscapeRotation", "=", "0", ";", "int", "mSeascapeRotation", "=", "0", ";", "int", "mPortraitRotation", "=", "0", ";", "int", "mUpsideDownRotation", "=", "0", ";", "private", "int", "mLongPressOnHomeBehavior", "=", "-", "1", ";", "private", "int", "mLongPressOnMenuBehavior", "=", "-", "1", ";", "private", "static", "final", "long", "ACTION_CHORD_DEBOUNCE_DELAY_MILLIS", "=", "150", ";", "private", "boolean", "mVolumeDownKeyTriggered", ";", "private", "long", "mVolumeDownKeyTime", ";", "private", "long", "mVolumeUpKeyTime", ";", "private", "boolean", "mVolumeDownKeyConsumedByChord", ";", "private", "boolean", "mVolumeUpKeyConsumedByChord", ";", "private", "boolean", "mVolumeUpKeyTriggered", ";", "private", "boolean", "mPowerKeyTriggered", ";", "private", "long", "mPowerKeyTime", ";", "ShortcutManager", "mShortcutManager", ";", "PowerManager", ".", "WakeLock", "mBroadcastWakeLock", ";", "final", "KeyCharacterMap", ".", "FallbackAction", "mFallbackAction", "=", "new", "KeyCharacterMap", ".", "FallbackAction", "(", ")", ";", "private", "UEventObserver", "mHDMIObserver", "=", "new", "UEventObserver", "(", ")", "{", "@", "Override", "public", "void", "onUEvent", "(", "UEventObserver", ".", "UEvent", "event", ")", "{", "setHdmiPlugged", "(", "\"1\"", ".", "equals", "(", "event", ".", "get", "(", "\"SWITCH_STATE\"", ")", ")", ")", ";", "}", "}", ";", "class", "SettingsObserver", "extends", "ContentObserver", "{", "SettingsObserver", "(", "Handler", "handler", ")", "{", "super", "(", "handler", ")", ";", "}", "void", "observe", "(", ")", "{", "ContentResolver", "resolver", "=", "mContext", ".", "getContentResolver", "(", ")", ";", "resolver", ".", "registerContentObserver", "(", "Settings", ".", "System", ".", "getUriFor", "(", "Settings", ".", "System", ".", "END_BUTTON_BEHAVIOR", ")", ",", "false", ",", "this", ")", ";", "resolver", ".", "registerContentObserver", "(", "Settings", ".", "Secure", ".", "getUriFor", "(", "Settings", ".", "Secure", ".", "INCALL_POWER_BUTTON_BEHAVIOR", ")", ",", "false", ",", "this", ")", ";", "resolver", ".", "registerContentObserver", "(", "Settings", ".", "System", ".", "getUriFor", "(", "Settings", ".", "System", ".", "VOLUME_WAKE_SCREEN", ")", ",", "false", ",", "this", ")", ";", "resolver", ".", "registerContentObserver", "(", "Settings", ".", "System", ".", "getUriFor", "(", "Settings", ".", "System", ".", "VOLBTN_MUSIC_CONTROLS", ")", ",", "false", ",", "this", ")", ";", "resolver", ".", "registerContentObserver", "(", "Settings", ".", "System", ".", "getUriFor", "(", "Settings", ".", "System", ".", "ACCELEROMETER_ROTATION", ")", ",", "false", ",", "this", ")", ";", "resolver", ".", "registerContentObserver", "(", "Settings", ".", "System", ".", "getUriFor", "(", "Settings", ".", "System", ".", "USER_ROTATION", ")", ",", "false", ",", "this", ")", ";", "resolver", ".", "registerContentObserver", "(", "Settings", ".", "System", ".", "getUriFor", "(", "Settings", ".", "System", ".", "SCREEN_OFF_TIMEOUT", ")", ",", "false", ",", "this", ")", ";", "resolver", ".", "registerContentObserver", "(", "Settings", ".", "System", ".", "getUriFor", "(", "Settings", ".", "System", ".", "WINDOW_ORIENTATION_LISTENER_LOG", ")", ",", "false", ",", "this", ")", ";", "resolver", ".", "registerContentObserver", "(", "Settings", ".", "System", ".", "getUriFor", "(", "Settings", ".", "System", ".", "POINTER_LOCATION", ")", ",", "false", ",", "this", ")", ";", "resolver", ".", "registerContentObserver", "(", "Settings", ".", "Secure", ".", "getUriFor", "(", "Settings", ".", "Secure", ".", "DEFAULT_INPUT_METHOD", ")", ",", "false", ",", "this", ")", ";", "resolver", ".", "registerContentObserver", "(", "Settings", ".", "System", ".", "getUriFor", "(", "\"\"", ")", ",", "false", ",", "this", ")", ";", "resolver", ".", "registerContentObserver", "(", "Settings", ".", "System", ".", "getUriFor", "(", "Settings", ".", "System", ".", "ACCELEROMETER_ROTATION_ANGLES", ")", ",", "false", ",", "this", ")", ";", "updateSettings", "(", ")", ";", "}", "@", "Override", "public", "void", "onChange", "(", "boolean", "selfChange", ")", "{", "updateSettings", "(", ")", ";", "updateRotation", "(", "false", ")", ";", "}", "}", "class", "MyOrientationListener", "extends", "WindowOrientationListener", "{", "MyOrientationListener", "(", "Context", "context", ")", "{", "super", "(", "context", ")", ";", "}", "@", "Override", "public", "void", "onProposedRotationChanged", "(", "int", "rotation", ")", "{", "if", "(", "localLOGV", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", "+", "rotation", ")", ";", "updateRotation", "(", "false", ")", ";", "}", "}", "MyOrientationListener", "mOrientationListener", ";", "boolean", "needSensorRunningLp", "(", ")", "{", "if", "(", "mCurrentAppOrientation", "==", "ActivityInfo", ".", "SCREEN_ORIENTATION_SENSOR", "||", "mCurrentAppOrientation", "==", "ActivityInfo", ".", "SCREEN_ORIENTATION_FULL_SENSOR", "||", "mCurrentAppOrientation", "==", "ActivityInfo", ".", "SCREEN_ORIENTATION_SENSOR_PORTRAIT", "||", "mCurrentAppOrientation", "==", "ActivityInfo", ".", "SCREEN_ORIENTATION_SENSOR_LANDSCAPE", ")", "{", "return", "true", ";", "}", "if", "(", "(", "mCarDockEnablesAccelerometer", "&&", "mDockMode", "==", "Intent", ".", "EXTRA_DOCK_STATE_CAR", ")", "||", "(", "mDeskDockEnablesAccelerometer", "&&", "(", "mDockMode", "==", "Intent", ".", "EXTRA_DOCK_STATE_DESK", "||", "mDockMode", "==", "Intent", ".", "EXTRA_DOCK_STATE_LE_DESK", "||", "mDockMode", "==", "Intent", ".", "EXTRA_DOCK_STATE_HE_DESK", ")", ")", ")", "{", "return", "true", ";", "}", "if", "(", "mAccelerometerDefault", "==", "0", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}", "void", "updateOrientationListenerLp", "(", ")", "{", "if", "(", "!", "mOrientationListener", ".", "canDetectOrientation", "(", ")", ")", "{", "return", ";", "}", "if", "(", "localLOGV", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", "+", "mScreenOnEarly", "+", "\"\"", "+", "mCurrentAppOrientation", "+", "\"\"", "+", "mOrientationSensorEnabled", ")", ";", "boolean", "disable", "=", "true", ";", "if", "(", "mScreenOnEarly", ")", "{", "if", "(", "needSensorRunningLp", "(", ")", ")", "{", "disable", "=", "false", ";", "if", "(", "!", "mOrientationSensorEnabled", ")", "{", "mOrientationListener", ".", "enable", "(", ")", ";", "if", "(", "localLOGV", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "mOrientationSensorEnabled", "=", "true", ";", "}", "}", "}", "if", "(", "disable", "&&", "mOrientationSensorEnabled", ")", "{", "mOrientationListener", ".", "disable", "(", ")", ";", "if", "(", "localLOGV", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "mOrientationSensorEnabled", "=", "false", ";", "}", "}", "private", "void", "interceptPowerKeyDown", "(", "boolean", "handled", ")", "{", "mPowerKeyHandled", "=", "handled", ";", "if", "(", "!", "handled", ")", "{", "mHandler", ".", "postDelayed", "(", "mPowerLongPress", ",", "ViewConfiguration", ".", "getGlobalActionKeyTimeout", "(", ")", ")", ";", "}", "}", "private", "boolean", "interceptPowerKeyUp", "(", "boolean", "canceled", ")", "{", "if", "(", "!", "mPowerKeyHandled", ")", "{", "mHandler", ".", "removeCallbacks", "(", "mPowerLongPress", ")", ";", "return", "!", "canceled", ";", "}", "return", "false", ";", "}", "private", "void", "cancelPendingPowerKeyAction", "(", ")", "{", "if", "(", "!", "mPowerKeyHandled", ")", "{", "mHandler", ".", "removeCallbacks", "(", "mPowerLongPress", ")", ";", "}", "if", "(", "mPowerKeyTriggered", ")", "{", "mPendingPowerKeyUpCanceled", "=", "true", ";", "}", "}", "Runnable", "mVolumeUpLongPress", "=", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "mIsLongPress", "=", "true", ";", "sendMediaButtonEvent", "(", "KeyEvent", ".", "KEYCODE_MEDIA_NEXT", ")", ";", "}", ";", "}", ";", "Runnable", "mVolumeDownLongPress", "=", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "mIsLongPress", "=", "true", ";", "sendMediaButtonEvent", "(", "KeyEvent", ".", "KEYCODE_MEDIA_PREVIOUS", ")", ";", "}", ";", "}", ";", "private", "void", "sendMediaButtonEvent", "(", "int", "code", ")", "{", "long", "eventtime", "=", "SystemClock", ".", "uptimeMillis", "(", ")", ";", "Intent", "keyIntent", "=", "new", "Intent", "(", "Intent", ".", "ACTION_MEDIA_BUTTON", ",", "null", ")", ";", "KeyEvent", "keyEvent", "=", "new", "KeyEvent", "(", "eventtime", ",", "eventtime", ",", "KeyEvent", ".", "ACTION_DOWN", ",", "code", ",", "0", ")", ";", "keyIntent", ".", "putExtra", "(", "Intent", ".", "EXTRA_KEY_EVENT", ",", "keyEvent", ")", ";", "mContext", ".", "sendOrderedBroadcast", "(", "keyIntent", ",", "null", ")", ";", "keyEvent", "=", "KeyEvent", ".", "changeAction", "(", "keyEvent", ",", "KeyEvent", ".", "ACTION_UP", ")", ";", "keyIntent", ".", "putExtra", "(", "Intent", ".", "EXTRA_KEY_EVENT", ",", "keyEvent", ")", ";", "mContext", ".", "sendOrderedBroadcast", "(", "keyIntent", ",", "null", ")", ";", "}", "void", "handleVolumeLongPress", "(", "int", "keycode", ")", "{", "mHandler", ".", "postDelayed", "(", "keycode", "==", "KeyEvent", ".", "KEYCODE_VOLUME_UP", "?", "mVolumeUpLongPress", ":", "mVolumeDownLongPress", ",", "ViewConfiguration", ".", "getLongPressTimeout", "(", ")", ")", ";", "}", "void", "handleVolumeLongPressAbort", "(", ")", "{", "mHandler", ".", "removeCallbacks", "(", "mVolumeUpLongPress", ")", ";", "mHandler", ".", "removeCallbacks", "(", "mVolumeDownLongPress", ")", ";", "}", "private", "void", "interceptScreenshotChord", "(", ")", "{", "if", "(", "mVolumeDownKeyTriggered", "&&", "mPowerKeyTriggered", "&&", "!", "mVolumeUpKeyTriggered", ")", "{", "final", "long", "now", "=", "SystemClock", ".", "uptimeMillis", "(", ")", ";", "if", "(", "now", "<=", "mVolumeDownKeyTime", "+", "ACTION_CHORD_DEBOUNCE_DELAY_MILLIS", "&&", "now", "<=", "mPowerKeyTime", "+", "ACTION_CHORD_DEBOUNCE_DELAY_MILLIS", ")", "{", "mVolumeDownKeyConsumedByChord", "=", "true", ";", "cancelPendingPowerKeyAction", "(", ")", ";", "mHandler", ".", "postDelayed", "(", "mScreenshotChordLongPress", ",", "ViewConfiguration", ".", "getGlobalActionKeyTimeout", "(", ")", ")", ";", "}", "}", "}", "private", "void", "cancelPendingScreenshotChordAction", "(", ")", "{", "mHandler", ".", "removeCallbacks", "(", "mScreenshotChordLongPress", ")", ";", "}", "private", "void", "interceptRingerChord", "(", ")", "{", "if", "(", "mVolumeDownKeyTriggered", "&&", "!", "mPowerKeyTriggered", "&&", "mVolumeUpKeyTriggered", ")", "{", "final", "long", "now", "=", "SystemClock", ".", "uptimeMillis", "(", ")", ";", "if", "(", "now", "<=", "mVolumeDownKeyTime", "+", "ACTION_CHORD_DEBOUNCE_DELAY_MILLIS", "&&", "now", "<=", "mVolumeUpKeyTime", "+", "ACTION_CHORD_DEBOUNCE_DELAY_MILLIS", ")", "{", "mVolumeDownKeyConsumedByChord", "=", "true", ";", "mVolumeUpKeyConsumedByChord", "=", "true", ";", "mHandler", ".", "postDelayed", "(", "mRingerChordLongPress", ",", "ViewConfiguration", ".", "getGlobalActionKeyTimeout", "(", ")", ")", ";", "}", "}", "}", "private", "void", "cancelPendingRingerChordAction", "(", ")", "{", "mHandler", ".", "removeCallbacks", "(", "mRingerChordLongPress", ")", ";", "}", "private", "final", "Runnable", "mPowerLongPress", "=", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "if", "(", "mLongPressOnPowerBehavior", "<", "0", ")", "{", "mLongPressOnPowerBehavior", "=", "mContext", ".", "getResources", "(", ")", ".", "getInteger", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "integer", ".", "config_longPressOnPowerBehavior", ")", ";", "}", "switch", "(", "mLongPressOnPowerBehavior", ")", "{", "case", "LONG_PRESS_POWER_NOTHING", ":", "break", ";", "case", "LONG_PRESS_POWER_GLOBAL_ACTIONS", ":", "mPowerKeyHandled", "=", "true", ";", "performHapticFeedbackLw", "(", "null", ",", "HapticFeedbackConstants", ".", "LONG_PRESS", ",", "false", ")", ";", "sendCloseSystemWindows", "(", "SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS", ")", ";", "showGlobalActionsDialog", "(", ")", ";", "break", ";", "case", "LONG_PRESS_POWER_SHUT_OFF", ":", "mPowerKeyHandled", "=", "true", ";", "performHapticFeedbackLw", "(", "null", ",", "HapticFeedbackConstants", ".", "LONG_PRESS", ",", "false", ")", ";", "sendCloseSystemWindows", "(", "SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS", ")", ";", "ShutdownThread", ".", "shutdown", "(", "mContext", ",", "true", ")", ";", "break", ";", "}", "}", "}", ";", "private", "final", "Runnable", "mScreenshotChordLongPress", "=", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "takeScreenshot", "(", ")", ";", "}", "}", ";", "private", "final", "Runnable", "mRingerChordLongPress", "=", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "final", "AudioManager", "am", "=", "(", "AudioManager", ")", "mContext", ".", "getSystemService", "(", "Context", ".", "AUDIO_SERVICE", ")", ";", "final", "int", "ringerMode", "=", "am", ".", "getRingerMode", "(", ")", ";", "final", "VolumePanel", "volumePanel", "=", "new", "VolumePanel", "(", "ThemeUtils", ".", "createUiContext", "(", "mContext", ")", ",", "(", "AudioService", ")", "getAudioService", "(", ")", ")", ";", "if", "(", "ringerMode", "==", "AudioManager", ".", "RINGER_MODE_NORMAL", ")", "{", "boolean", "vibrateSetting", "=", "am", ".", "getVibrateSetting", "(", "AudioManager", ".", "VIBRATE_TYPE_RINGER", ")", "==", "AudioManager", ".", "VIBRATE_SETTING_ON", ";", "am", ".", "setRingerMode", "(", "vibrateSetting", "?", "AudioManager", ".", "RINGER_MODE_VIBRATE", ":", "AudioManager", ".", "RINGER_MODE_SILENT", ")", ";", "}", "else", "{", "am", ".", "setRingerMode", "(", "AudioManager", ".", "RINGER_MODE_NORMAL", ")", ";", "}", "volumePanel", ".", "postVolumeChanged", "(", "AudioManager", ".", "STREAM_RING", ",", "AudioManager", ".", "FLAG_SHOW_UI", "|", "AudioManager", ".", "FLAG_VIBRATE", ")", ";", "}", "}", ";", "Runnable", "mBackLongPress", "=", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "try", "{", "performHapticFeedbackLw", "(", "null", ",", "HapticFeedbackConstants", ".", "LONG_PRESS", ",", "false", ")", ";", "IActivityManager", "mgr", "=", "ActivityManagerNative", ".", "getDefault", "(", ")", ";", "List", "<", "RunningAppProcessInfo", ">", "apps", "=", "mgr", ".", "getRunningAppProcesses", "(", ")", ";", "for", "(", "RunningAppProcessInfo", "appInfo", ":", "apps", ")", "{", "int", "uid", "=", "appInfo", ".", "uid", ";", "if", "(", "uid", ">=", "Process", ".", "FIRST_APPLICATION_UID", "&&", "uid", "<=", "Process", ".", "LAST_APPLICATION_UID", "&&", "appInfo", ".", "importance", "==", "RunningAppProcessInfo", ".", "IMPORTANCE_FOREGROUND", ")", "{", "Toast", ".", "makeText", "(", "mContext", ",", "R", ".", "string", ".", "app_killed_message", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "if", "(", "appInfo", ".", "pkgList", "!=", "null", "&&", "(", "apps", ".", "size", "(", ")", ">", "0", ")", ")", "{", "mgr", ".", "forceStopPackage", "(", "appInfo", ".", "pkgList", "[", "0", "]", ")", ";", "}", "else", "{", "Process", ".", "killProcess", "(", "appInfo", ".", "pid", ")", ";", "}", "break", ";", "}", "}", "}", "catch", "(", "RemoteException", "remoteException", ")", "{", "}", "}", "}", ";", "void", "showGlobalActionsDialog", "(", ")", "{", "if", "(", "mGlobalActions", "==", "null", ")", "{", "mGlobalActions", "=", "new", "GlobalActions", "(", "mContext", ")", ";", "}", "final", "boolean", "keyguardShowing", "=", "mKeyguardMediator", ".", "isShowingAndNotHidden", "(", ")", ";", "mGlobalActions", ".", "showDialog", "(", "keyguardShowing", ",", "isDeviceProvisioned", "(", ")", ")", ";", "if", "(", "keyguardShowing", ")", "{", "mKeyguardMediator", ".", "pokeWakelock", "(", ")", ";", "}", "}", "boolean", "isDeviceProvisioned", "(", ")", "{", "return", "Settings", ".", "Secure", ".", "getInt", "(", "mContext", ".", "getContentResolver", "(", ")", ",", "Settings", ".", "Secure", ".", "DEVICE_PROVISIONED", ",", "0", ")", "!=", "0", ";", "}", "private", "void", "handleLongPressOnHome", "(", ")", "{", "if", "(", "mLongPressOnHomeBehavior", "<", "0", ")", "{", "mLongPressOnHomeBehavior", "=", "mContext", ".", "getResources", "(", ")", ".", "getInteger", "(", "R", ".", "integer", ".", "config_longPressOnHomeBehavior", ")", ";", "if", "(", "mLongPressOnHomeBehavior", "<", "LONG_PRESS_HOME_NOTHING", "||", "mLongPressOnHomeBehavior", ">", "LONG_PRESS_HOME_RECENT_SYSTEM_UI", ")", "{", "mLongPressOnHomeBehavior", "=", "LONG_PRESS_HOME_NOTHING", ";", "}", "}", "if", "(", "mLongPressOnHomeBehavior", "!=", "LONG_PRESS_HOME_NOTHING", ")", "{", "performHapticFeedbackLw", "(", "null", ",", "HapticFeedbackConstants", ".", "LONG_PRESS", ",", "false", ")", ";", "sendCloseSystemWindows", "(", "SYSTEM_DIALOG_REASON_RECENT_APPS", ")", ";", "mHomePressed", "=", "false", ";", "}", "if", "(", "mLongPressOnHomeBehavior", "==", "LONG_PRESS_HOME_RECENT_DIALOG", ")", "{", "showOrHideRecentAppsDialog", "(", "RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS", ")", ";", "}", "else", "if", "(", "mLongPressOnHomeBehavior", "==", "LONG_PRESS_HOME_RECENT_SYSTEM_UI", ")", "{", "try", "{", "mStatusBarService", ".", "toggleRecentApps", "(", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "Slog", ".", "e", "(", "TAG", ",", "\"\"", ",", "e", ")", ";", "}", "}", "}", "private", "void", "handleLongPressOnMenu", "(", ")", "{", "if", "(", "mLongPressOnMenuBehavior", "<", "0", ")", "{", "if", "(", "(", "mContext", ".", "getResources", "(", ")", ".", "getInteger", "(", "R", ".", "integer", ".", "config_deviceHardwareKeys", ")", "&", "KEY_MASK_SEARCH", ")", "==", "0", ")", "{", "mLongPressOnMenuBehavior", "=", "LONG_PRESS_MENU_SEARCH", ";", "}", "else", "{", "mLongPressOnMenuBehavior", "=", "LONG_PRESS_MENU_NOTHING", ";", "}", "}", "if", "(", "mLongPressOnMenuBehavior", "==", "LONG_PRESS_MENU_SEARCH", ")", "{", "performHapticFeedbackLw", "(", "null", ",", "HapticFeedbackConstants", ".", "LONG_PRESS", ",", "false", ")", ";", "triggerVirtualKeypress", "(", "KeyEvent", ".", "KEYCODE_SEARCH", ")", ";", "}", "}", "private", "void", "triggerVirtualKeypress", "(", "final", "int", "keyCode", ")", "{", "new", "Thread", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "try", "{", "mWindowManager", ".", "injectKeyEvent", "(", "new", "KeyEvent", "(", "KeyEvent", ".", "ACTION_DOWN", ",", "keyCode", ")", ",", "true", ")", ";", "mWindowManager", ".", "injectKeyEvent", "(", "new", "KeyEvent", "(", "KeyEvent", ".", "ACTION_UP", ",", "keyCode", ")", ",", "true", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "}", ")", ".", "start", "(", ")", ";", "}", "void", "showOrHideRecentAppsDialog", "(", "final", "int", "behavior", ")", "{", "mHandler", ".", "post", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "if", "(", "mRecentAppsDialog", "==", "null", ")", "{", "mRecentAppsDialog", "=", "new", "RecentApplicationsDialog", "(", "mContext", ")", ";", "}", "if", "(", "mRecentAppsDialog", ".", "isShowing", "(", ")", ")", "{", "switch", "(", "behavior", ")", "{", "case", "RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS", ":", "mRecentAppsDialog", ".", "dismiss", "(", ")", ";", "break", ";", "case", "RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH", ":", "mRecentAppsDialog", ".", "dismissAndSwitch", "(", ")", ";", "break", ";", "case", "RECENT_APPS_BEHAVIOR_EXIT_TOUCH_MODE_AND_SHOW", ":", "default", ":", "break", ";", "}", "}", "else", "{", "switch", "(", "behavior", ")", "{", "case", "RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS", ":", "mRecentAppsDialog", ".", "show", "(", ")", ";", "break", ";", "case", "RECENT_APPS_BEHAVIOR_EXIT_TOUCH_MODE_AND_SHOW", ":", "try", "{", "mWindowManager", ".", "setInTouchMode", "(", "false", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "mRecentAppsDialog", ".", "show", "(", ")", ";", "break", ";", "case", "RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH", ":", "default", ":", "break", ";", "}", "}", "}", "}", ")", ";", "}", "public", "void", "init", "(", "Context", "context", ",", "IWindowManager", "windowManager", ",", "WindowManagerFuncs", "windowManagerFuncs", ",", "LocalPowerManager", "powerManager", ")", "{", "mContext", "=", "context", ";", "mWindowManager", "=", "windowManager", ";", "mWindowManagerFuncs", "=", "windowManagerFuncs", ";", "mPowerManager", "=", "powerManager", ";", "mKeyguardMediator", "=", "new", "KeyguardViewMediator", "(", "context", ",", "this", ",", "powerManager", ")", ";", "mHandler", "=", "new", "Handler", "(", ")", ";", "mOrientationListener", "=", "new", "MyOrientationListener", "(", "mContext", ")", ";", "try", "{", "mOrientationListener", ".", "setCurrentRotation", "(", "windowManager", ".", "getRotation", "(", ")", ")", ";", "}", "catch", "(", "RemoteException", "ex", ")", "{", "}", "SettingsObserver", "settingsObserver", "=", "new", "SettingsObserver", "(", "mHandler", ")", ";", "settingsObserver", ".", "observe", "(", ")", ";", "mShortcutManager", "=", "new", "ShortcutManager", "(", "context", ",", "mHandler", ")", ";", "mShortcutManager", ".", "observe", "(", ")", ";", "mHomeIntent", "=", "new", "Intent", "(", "Intent", ".", "ACTION_MAIN", ",", "null", ")", ";", "mHomeIntent", ".", "addCategory", "(", "Intent", ".", "CATEGORY_HOME", ")", ";", "mHomeIntent", ".", "addFlags", "(", "Intent", ".", "FLAG_ACTIVITY_NEW_TASK", "|", "Intent", ".", "FLAG_ACTIVITY_RESET_TASK_IF_NEEDED", ")", ";", "mCarDockIntent", "=", "new", "Intent", "(", "Intent", ".", "ACTION_MAIN", ",", "null", ")", ";", "mCarDockIntent", ".", "addCategory", "(", "Intent", ".", "CATEGORY_CAR_DOCK", ")", ";", "mCarDockIntent", ".", "addFlags", "(", "Intent", ".", "FLAG_ACTIVITY_NEW_TASK", "|", "Intent", ".", "FLAG_ACTIVITY_RESET_TASK_IF_NEEDED", ")", ";", "mDeskDockIntent", "=", "new", "Intent", "(", "Intent", ".", "ACTION_MAIN", ",", "null", ")", ";", "mDeskDockIntent", ".", "addCategory", "(", "Intent", ".", "CATEGORY_DESK_DOCK", ")", ";", "mDeskDockIntent", ".", "addFlags", "(", "Intent", ".", "FLAG_ACTIVITY_NEW_TASK", "|", "Intent", ".", "FLAG_ACTIVITY_RESET_TASK_IF_NEEDED", ")", ";", "PowerManager", "pm", "=", "(", "PowerManager", ")", "context", ".", "getSystemService", "(", "Context", ".", "POWER_SERVICE", ")", ";", "mBroadcastWakeLock", "=", "pm", ".", "newWakeLock", "(", "PowerManager", ".", "PARTIAL_WAKE_LOCK", ",", "\"\"", ")", ";", "mEnableShiftMenuBugReports", "=", "\"1\"", ".", "equals", "(", "SystemProperties", ".", "get", "(", "\"\"", ")", ")", ";", "mLidOpenRotation", "=", "readRotation", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "integer", ".", "config_lidOpenRotation", ")", ";", "mCarDockRotation", "=", "readRotation", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "integer", ".", "config_carDockRotation", ")", ";", "mDeskDockRotation", "=", "readRotation", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "integer", ".", "config_deskDockRotation", ")", ";", "mCarDockEnablesAccelerometer", "=", "mContext", ".", "getResources", "(", ")", ".", "getBoolean", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "bool", ".", "config_carDockEnablesAccelerometer", ")", ";", "mDeskDockEnablesAccelerometer", "=", "mContext", ".", "getResources", "(", ")", ".", "getBoolean", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "bool", ".", "config_deskDockEnablesAccelerometer", ")", ";", "mLidKeyboardAccessibility", "=", "mContext", ".", "getResources", "(", ")", ".", "getInteger", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "integer", ".", "config_lidKeyboardAccessibility", ")", ";", "mLidNavigationAccessibility", "=", "mContext", ".", "getResources", "(", ")", ".", "getInteger", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "integer", ".", "config_lidNavigationAccessibility", ")", ";", "IntentFilter", "filter", "=", "new", "IntentFilter", "(", ")", ";", "filter", ".", "addAction", "(", "UiModeManager", ".", "ACTION_ENTER_CAR_MODE", ")", ";", "filter", ".", "addAction", "(", "UiModeManager", ".", "ACTION_EXIT_CAR_MODE", ")", ";", "filter", ".", "addAction", "(", "UiModeManager", ".", "ACTION_ENTER_DESK_MODE", ")", ";", "filter", ".", "addAction", "(", "UiModeManager", ".", "ACTION_EXIT_DESK_MODE", ")", ";", "filter", ".", "addAction", "(", "Intent", ".", "ACTION_DOCK_EVENT", ")", ";", "Intent", "intent", "=", "context", ".", "registerReceiver", "(", "mDockReceiver", ",", "filter", ")", ";", "if", "(", "intent", "!=", "null", ")", "{", "mDockMode", "=", "intent", ".", "getIntExtra", "(", "Intent", ".", "EXTRA_DOCK_STATE", ",", "Intent", ".", "EXTRA_DOCK_STATE_UNDOCKED", ")", ";", "}", "IntentFilter", "filterHDMI", "=", "new", "IntentFilter", "(", ")", ";", "filterHDMI", ".", "addAction", "(", "Intent", ".", "ACTION_HDMISTATUS_CHANGED", ")", ";", "filterHDMI", ".", "addAction", "(", "Intent", ".", "ACTION_TVDACSTATUS_CHANGED", ")", ";", "Intent", "intentHDMI", "=", "context", ".", "registerReceiver", "(", "mHDMIReceiver", ",", "filterHDMI", ")", ";", "if", "(", "intentHDMI", "!=", "null", ")", "{", "if", "(", "intentHDMI", ".", "getIntExtra", "(", "DisplayManager", ".", "EXTRA_HDMISTATUS", ",", "0", ")", "==", "1", ")", "{", "setHdmiPlugged", "(", "true", ")", ";", "}", "else", "{", "setHdmiPlugged", "(", "false", ")", ";", "}", "}", "mVibrator", "=", "new", "Vibrator", "(", ")", ";", "mLongPressVibePattern", "=", "getLongIntArray", "(", "mContext", ".", "getResources", "(", ")", ",", "com", ".", "android", ".", "internal", ".", "R", ".", "array", ".", "config_longPressVibePattern", ")", ";", "mVirtualKeyVibePattern", "=", "getLongIntArray", "(", "mContext", ".", "getResources", "(", ")", ",", "com", ".", "android", ".", "internal", ".", "R", ".", "array", ".", "config_virtualKeyVibePattern", ")", ";", "mKeyboardTapVibePattern", "=", "getLongIntArray", "(", "mContext", ".", "getResources", "(", ")", ",", "com", ".", "android", ".", "internal", ".", "R", ".", "array", ".", "config_keyboardTapVibePattern", ")", ";", "mSafeModeDisabledVibePattern", "=", "getLongIntArray", "(", "mContext", ".", "getResources", "(", ")", ",", "com", ".", "android", ".", "internal", ".", "R", ".", "array", ".", "config_safeModeDisabledVibePattern", ")", ";", "mSafeModeEnabledVibePattern", "=", "getLongIntArray", "(", "mContext", ".", "getResources", "(", ")", ",", "com", ".", "android", ".", "internal", ".", "R", ".", "array", ".", "config_safeModeEnabledVibePattern", ")", ";", "initializeHdmiState", "(", ")", ";", "if", "(", "mPowerManager", ".", "isScreenOn", "(", ")", ")", "{", "screenTurningOn", "(", "null", ")", ";", "}", "else", "{", "screenTurnedOff", "(", "WindowManagerPolicy", ".", "OFF_BECAUSE_OF_USER", ")", ";", "}", "String", "deviceKeyHandlerLib", "=", "mContext", ".", "getResources", "(", ")", ".", "getString", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "string", ".", "config_deviceKeyHandlerLib", ")", ";", "String", "deviceKeyHandlerClass", "=", "mContext", ".", "getResources", "(", ")", ".", "getString", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "string", ".", "config_deviceKeyHandlerClass", ")", ";", "if", "(", "!", "deviceKeyHandlerLib", ".", "equals", "(", "\"\"", ")", "&&", "!", "deviceKeyHandlerClass", ".", "equals", "(", "\"\"", ")", ")", "{", "DexClassLoader", "loader", "=", "new", "DexClassLoader", "(", "deviceKeyHandlerLib", ",", "new", "ContextWrapper", "(", "mContext", ")", ".", "getCacheDir", "(", ")", ".", "getAbsolutePath", "(", ")", ",", "null", ",", "ClassLoader", ".", "getSystemClassLoader", "(", ")", ")", ";", "try", "{", "Class", "<", "?", ">", "klass", "=", "loader", ".", "loadClass", "(", "deviceKeyHandlerClass", ")", ";", "Constructor", "<", "?", ">", "constructor", "=", "klass", ".", "getConstructor", "(", "Context", ".", "class", ")", ";", "mDeviceKeyHandler", "=", "(", "DeviceKeyHandler", ")", "constructor", ".", "newInstance", "(", "mContext", ")", ";", "Slog", ".", "d", "(", "TAG", ",", "\"\"", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "Slog", ".", "d", "(", "TAG", ",", "\"\"", "+", "deviceKeyHandlerClass", "+", "\"", "from", "class", "\"", "+", "deviceKeyHandlerLib", ",", "e", ")", ";", "}", "}", "}", "public", "void", "setInitialDisplaySize", "(", "int", "width", ",", "int", "height", ")", "{", "int", "shortSize", ";", "if", "(", "width", ">", "height", ")", "{", "shortSize", "=", "height", ";", "mLandscapeRotation", "=", "Surface", ".", "ROTATION_0", ";", "mSeascapeRotation", "=", "Surface", ".", "ROTATION_180", ";", "if", "(", "mContext", ".", "getResources", "(", ")", ".", "getBoolean", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "bool", ".", "config_reverseDefaultRotation", ")", ")", "{", "mPortraitRotation", "=", "Surface", ".", "ROTATION_90", ";", "mUpsideDownRotation", "=", "Surface", ".", "ROTATION_270", ";", "}", "else", "{", "mPortraitRotation", "=", "Surface", ".", "ROTATION_270", ";", "mUpsideDownRotation", "=", "Surface", ".", "ROTATION_90", ";", "}", "}", "else", "{", "shortSize", "=", "width", ";", "mPortraitRotation", "=", "Surface", ".", "ROTATION_0", ";", "mUpsideDownRotation", "=", "Surface", ".", "ROTATION_180", ";", "if", "(", "mContext", ".", "getResources", "(", ")", ".", "getBoolean", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "bool", ".", "config_reverseDefaultRotation", ")", ")", "{", "mLandscapeRotation", "=", "Surface", ".", "ROTATION_270", ";", "mSeascapeRotation", "=", "Surface", ".", "ROTATION_90", ";", "}", "else", "{", "mLandscapeRotation", "=", "Surface", ".", "ROTATION_90", ";", "mSeascapeRotation", "=", "Surface", ".", "ROTATION_270", ";", "}", "}", "int", "shortSizeDp", "=", "shortSize", "*", "DisplayMetrics", ".", "DENSITY_DEFAULT", "/", "DisplayMetrics", ".", "DENSITY_DEVICE", ";", "mStatusBarCanHide", "=", "shortSizeDp", "<", "480", ";", "mStatusBarHeight", "=", "mContext", ".", "getResources", "(", ")", ".", "getDimensionPixelSize", "(", "mStatusBarCanHide", "?", "com", ".", "android", ".", "internal", ".", "R", ".", "dimen", ".", "status_bar_height", ":", "com", ".", "android", ".", "internal", ".", "R", ".", "dimen", ".", "system_bar_height", ")", ";", "mHasNavigationBar", "=", "mContext", ".", "getResources", "(", ")", ".", "getBoolean", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "bool", ".", "config_showNavigationBar", ")", ";", "String", "navBarOverride", "=", "SystemProperties", ".", "get", "(", "\"\"", ")", ";", "if", "(", "!", "\"\"", ".", "equals", "(", "navBarOverride", ")", ")", "{", "if", "(", "navBarOverride", ".", "equals", "(", "\"1\"", ")", ")", "mHasNavigationBar", "=", "false", ";", "else", "if", "(", "navBarOverride", ".", "equals", "(", "\"0\"", ")", ")", "mHasNavigationBar", "=", "true", ";", "}", "mNavigationBarHeight", "=", "mHasNavigationBar", "?", "mContext", ".", "getResources", "(", ")", ".", "getDimensionPixelSize", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "dimen", ".", "navigation_bar_height", ")", ":", "0", ";", "mNavigationBarWidth", "=", "mHasNavigationBar", "?", "mContext", ".", "getResources", "(", ")", ".", "getDimensionPixelSize", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "dimen", ".", "navigation_bar_width", ")", ":", "0", ";", "if", "(", "\"portrait\"", ".", "equals", "(", "SystemProperties", ".", "get", "(", "\"\"", ")", ")", ")", "{", "mHdmiRotation", "=", "mPortraitRotation", ";", "}", "else", "{", "mHdmiRotation", "=", "mLandscapeRotation", ";", "}", "}", "public", "void", "updateSettings", "(", ")", "{", "ContentResolver", "resolver", "=", "mContext", ".", "getContentResolver", "(", ")", ";", "boolean", "updateRotation", "=", "false", ";", "View", "addView", "=", "null", ";", "View", "removeView", "=", "null", ";", "synchronized", "(", "mLock", ")", "{", "mEndcallBehavior", "=", "Settings", ".", "System", ".", "getInt", "(", "resolver", ",", "Settings", ".", "System", ".", "END_BUTTON_BEHAVIOR", ",", "Settings", ".", "System", ".", "END_BUTTON_BEHAVIOR_DEFAULT", ")", ";", "mIncallPowerBehavior", "=", "Settings", ".", "Secure", ".", "getInt", "(", "resolver", ",", "Settings", ".", "Secure", ".", "INCALL_POWER_BUTTON_BEHAVIOR", ",", "Settings", ".", "Secure", ".", "INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT", ")", ";", "mVolumeWakeScreen", "=", "(", "Settings", ".", "System", ".", "getInt", "(", "resolver", ",", "Settings", ".", "System", ".", "VOLUME_WAKE_SCREEN", ",", "0", ")", "==", "1", ")", ";", "mVolBtnMusicControls", "=", "(", "Settings", ".", "System", ".", "getInt", "(", "resolver", ",", "Settings", ".", "System", ".", "VOLBTN_MUSIC_CONTROLS", ",", "1", ")", "==", "1", ")", ";", "int", "accelerometerDefault", "=", "Settings", ".", "System", ".", "getInt", "(", "resolver", ",", "Settings", ".", "System", ".", "ACCELEROMETER_ROTATION", ",", "DEFAULT_ACCELEROMETER_ROTATION", ")", ";", "mUserRotationMode", "=", "(", "accelerometerDefault", "==", "0", ")", "?", "WindowManagerPolicy", ".", "USER_ROTATION_LOCKED", ":", "WindowManagerPolicy", ".", "USER_ROTATION_FREE", ";", "mUserRotation", "=", "Settings", ".", "System", ".", "getInt", "(", "resolver", ",", "Settings", ".", "System", ".", "USER_ROTATION", ",", "Surface", ".", "ROTATION_0", ")", ";", "mUserRotationAngles", "=", "Settings", ".", "System", ".", "getInt", "(", "resolver", ",", "Settings", ".", "System", ".", "ACCELEROMETER_ROTATION_ANGLES", ",", "-", "1", ")", ";", "if", "(", "mAccelerometerDefault", "!=", "accelerometerDefault", ")", "{", "mAccelerometerDefault", "=", "accelerometerDefault", ";", "updateOrientationListenerLp", "(", ")", ";", "}", "mOrientationListener", ".", "setLogEnabled", "(", "Settings", ".", "System", ".", "getInt", "(", "resolver", ",", "Settings", ".", "System", ".", "WINDOW_ORIENTATION_LISTENER_LOG", ",", "0", ")", "!=", "0", ")", ";", "if", "(", "mSystemReady", ")", "{", "int", "pointerLocation", "=", "Settings", ".", "System", ".", "getInt", "(", "resolver", ",", "Settings", ".", "System", ".", "POINTER_LOCATION", ",", "0", ")", ";", "if", "(", "mPointerLocationMode", "!=", "pointerLocation", ")", "{", "mPointerLocationMode", "=", "pointerLocation", ";", "if", "(", "pointerLocation", "!=", "0", ")", "{", "if", "(", "mPointerLocationView", "==", "null", ")", "{", "mPointerLocationView", "=", "new", "PointerLocationView", "(", "mContext", ")", ";", "mPointerLocationView", ".", "setPrintCoords", "(", "false", ")", ";", "addView", "=", "mPointerLocationView", ";", "}", "}", "else", "{", "removeView", "=", "mPointerLocationView", ";", "mPointerLocationView", "=", "null", ";", "}", "}", "}", "mLockScreenTimeout", "=", "Settings", ".", "System", ".", "getInt", "(", "resolver", ",", "Settings", ".", "System", ".", "SCREEN_OFF_TIMEOUT", ",", "0", ")", ";", "String", "imId", "=", "Settings", ".", "Secure", ".", "getString", "(", "resolver", ",", "Settings", ".", "Secure", ".", "DEFAULT_INPUT_METHOD", ")", ";", "boolean", "hasSoftInput", "=", "imId", "!=", "null", "&&", "imId", ".", "length", "(", ")", ">", "0", ";", "if", "(", "mHasSoftInput", "!=", "hasSoftInput", ")", "{", "mHasSoftInput", "=", "hasSoftInput", ";", "updateRotation", "=", "true", ";", "}", "}", "if", "(", "updateRotation", ")", "{", "updateRotation", "(", "true", ")", ";", "}", "if", "(", "addView", "!=", "null", ")", "{", "WindowManager", ".", "LayoutParams", "lp", "=", "new", "WindowManager", ".", "LayoutParams", "(", "WindowManager", ".", "LayoutParams", ".", "MATCH_PARENT", ",", "WindowManager", ".", "LayoutParams", ".", "MATCH_PARENT", ")", ";", "lp", ".", "type", "=", "WindowManager", ".", "LayoutParams", ".", "TYPE_SECURE_SYSTEM_OVERLAY", ";", "lp", ".", "flags", "=", "WindowManager", ".", "LayoutParams", ".", "FLAG_FULLSCREEN", "|", "WindowManager", ".", "LayoutParams", ".", "FLAG_NOT_TOUCHABLE", "|", "WindowManager", ".", "LayoutParams", ".", "FLAG_NOT_FOCUSABLE", "|", "WindowManager", ".", "LayoutParams", ".", "FLAG_LAYOUT_IN_SCREEN", ";", "lp", ".", "format", "=", "PixelFormat", ".", "TRANSLUCENT", ";", "lp", ".", "setTitle", "(", "\"\"", ")", ";", "WindowManager", "wm", "=", "(", "WindowManager", ")", "mContext", ".", "getSystemService", "(", "Context", ".", "WINDOW_SERVICE", ")", ";", "lp", ".", "inputFeatures", "|=", "WindowManager", ".", "LayoutParams", ".", "INPUT_FEATURE_NO_INPUT_CHANNEL", ";", "wm", ".", "addView", "(", "addView", ",", "lp", ")", ";", "if", "(", "mPointerLocationInputChannel", "==", "null", ")", "{", "try", "{", "mPointerLocationInputChannel", "=", "mWindowManager", ".", "monitorInput", "(", "\"\"", ")", ";", "InputQueue", ".", "registerInputChannel", "(", "mPointerLocationInputChannel", ",", "mPointerLocationInputHandler", ",", "mHandler", ".", "getLooper", "(", ")", ".", "getQueue", "(", ")", ")", ";", "}", "catch", "(", "RemoteException", "ex", ")", "{", "Slog", ".", "e", "(", "TAG", ",", "\"\"", ",", "ex", ")", ";", "}", "}", "}", "if", "(", "removeView", "!=", "null", ")", "{", "if", "(", "mPointerLocationInputChannel", "!=", "null", ")", "{", "InputQueue", ".", "unregisterInputChannel", "(", "mPointerLocationInputChannel", ")", ";", "mPointerLocationInputChannel", ".", "dispose", "(", ")", ";", "mPointerLocationInputChannel", "=", "null", ";", "}", "WindowManager", "wm", "=", "(", "WindowManager", ")", "mContext", ".", "getSystemService", "(", "Context", ".", "WINDOW_SERVICE", ")", ";", "wm", ".", "removeView", "(", "removeView", ")", ";", "}", "}", "private", "int", "readRotation", "(", "int", "resID", ")", "{", "try", "{", "int", "rotation", "=", "mContext", ".", "getResources", "(", ")", ".", "getInteger", "(", "resID", ")", ";", "switch", "(", "rotation", ")", "{", "case", "0", ":", "return", "Surface", ".", "ROTATION_0", ";", "case", "90", ":", "return", "Surface", ".", "ROTATION_90", ";", "case", "180", ":", "return", "Surface", ".", "ROTATION_180", ";", "case", "270", ":", "return", "Surface", ".", "ROTATION_270", ";", "}", "}", "catch", "(", "Resources", ".", "NotFoundException", "e", ")", "{", "}", "return", "-", "1", ";", "}", "public", "int", "checkAddPermission", "(", "WindowManager", ".", "LayoutParams", "attrs", ")", "{", "int", "type", "=", "attrs", ".", "type", ";", "if", "(", "type", "<", "WindowManager", ".", "LayoutParams", ".", "FIRST_SYSTEM_WINDOW", "||", "type", ">", "WindowManager", ".", "LayoutParams", ".", "LAST_SYSTEM_WINDOW", ")", "{", "return", "WindowManagerImpl", ".", "ADD_OKAY", ";", "}", "String", "permission", "=", "null", ";", "switch", "(", "type", ")", "{", "case", "TYPE_TOAST", ":", "break", ";", "case", "TYPE_INPUT_METHOD", ":", "case", "TYPE_WALLPAPER", ":", "break", ";", "case", "TYPE_PHONE", ":", "case", "TYPE_PRIORITY_PHONE", ":", "case", "TYPE_SYSTEM_ALERT", ":", "case", "TYPE_SYSTEM_ERROR", ":", "case", "TYPE_SYSTEM_OVERLAY", ":", "permission", "=", "android", ".", "Manifest", ".", "permission", ".", "SYSTEM_ALERT_WINDOW", ";", "break", ";", "default", ":", "permission", "=", "android", ".", "Manifest", ".", "permission", ".", "INTERNAL_SYSTEM_WINDOW", ";", "}", "if", "(", "permission", "!=", "null", ")", "{", "if", "(", "mContext", ".", "checkCallingOrSelfPermission", "(", "permission", ")", "!=", "PackageManager", ".", "PERMISSION_GRANTED", ")", "{", "return", "WindowManagerImpl", ".", "ADD_PERMISSION_DENIED", ";", "}", "}", "return", "WindowManagerImpl", ".", "ADD_OKAY", ";", "}", "public", "void", "adjustWindowParamsLw", "(", "WindowManager", ".", "LayoutParams", "attrs", ")", "{", "switch", "(", "attrs", ".", "type", ")", "{", "case", "TYPE_SYSTEM_OVERLAY", ":", "case", "TYPE_SECURE_SYSTEM_OVERLAY", ":", "case", "TYPE_TOAST", ":", "attrs", ".", "flags", "|=", "WindowManager", ".", "LayoutParams", ".", "FLAG_NOT_FOCUSABLE", "|", "WindowManager", ".", "LayoutParams", ".", "FLAG_NOT_TOUCHABLE", ";", "attrs", ".", "flags", "&=", "~", "WindowManager", ".", "LayoutParams", ".", "FLAG_WATCH_OUTSIDE_TOUCH", ";", "break", ";", "}", "}", "void", "readLidState", "(", ")", "{", "try", "{", "int", "sw", "=", "mWindowManager", ".", "getSwitchState", "(", "SW_LID", ")", ";", "if", "(", "sw", ">", "0", ")", "{", "mLidOpen", "=", "LID_CLOSED", ";", "}", "else", "if", "(", "sw", "==", "0", ")", "{", "mLidOpen", "=", "LID_OPEN", ";", "}", "else", "{", "mLidOpen", "=", "LID_ABSENT", ";", "}", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "private", "int", "determineHiddenState", "(", "int", "mode", ",", "int", "hiddenValue", ",", "int", "visibleValue", ")", "{", "if", "(", "mLidOpen", "!=", "LID_ABSENT", ")", "{", "switch", "(", "mode", ")", "{", "case", "1", ":", "return", "mLidOpen", "==", "LID_OPEN", "?", "visibleValue", ":", "hiddenValue", ";", "case", "2", ":", "return", "mLidOpen", "==", "LID_OPEN", "?", "hiddenValue", ":", "visibleValue", ";", "}", "}", "return", "visibleValue", ";", "}", "public", "void", "adjustConfigurationLw", "(", "Configuration", "config", ")", "{", "readLidState", "(", ")", ";", "updateKeyboardVisibility", "(", ")", ";", "if", "(", "config", ".", "keyboard", "==", "Configuration", ".", "KEYBOARD_NOKEYS", ")", "{", "config", ".", "hardKeyboardHidden", "=", "Configuration", ".", "HARDKEYBOARDHIDDEN_YES", ";", "}", "else", "{", "config", ".", "hardKeyboardHidden", "=", "determineHiddenState", "(", "mLidKeyboardAccessibility", ",", "Configuration", ".", "HARDKEYBOARDHIDDEN_YES", ",", "Configuration", ".", "HARDKEYBOARDHIDDEN_NO", ")", ";", "}", "if", "(", "config", ".", "navigation", "==", "Configuration", ".", "NAVIGATION_NONAV", ")", "{", "config", ".", "navigationHidden", "=", "Configuration", ".", "NAVIGATIONHIDDEN_YES", ";", "}", "else", "{", "config", ".", "navigationHidden", "=", "determineHiddenState", "(", "mLidNavigationAccessibility", ",", "Configuration", ".", "NAVIGATIONHIDDEN_YES", ",", "Configuration", ".", "NAVIGATIONHIDDEN_NO", ")", ";", "}", "if", "(", "mHasSoftInput", "||", "config", ".", "hardKeyboardHidden", "==", "Configuration", ".", "HARDKEYBOARDHIDDEN_NO", ")", "{", "config", ".", "keyboardHidden", "=", "Configuration", ".", "KEYBOARDHIDDEN_NO", ";", "}", "else", "{", "config", ".", "keyboardHidden", "=", "Configuration", ".", "KEYBOARDHIDDEN_YES", ";", "}", "}", "public", "int", "windowTypeToLayerLw", "(", "int", "type", ")", "{", "if", "(", "type", ">=", "FIRST_APPLICATION_WINDOW", "&&", "type", "<=", "LAST_APPLICATION_WINDOW", ")", "{", "return", "APPLICATION_LAYER", ";", "}", "switch", "(", "type", ")", "{", "case", "TYPE_STATUS_BAR", ":", "return", "STATUS_BAR_LAYER", ";", "case", "TYPE_STATUS_BAR_PANEL", ":", "return", "STATUS_BAR_PANEL_LAYER", ";", "case", "TYPE_STATUS_BAR_SUB_PANEL", ":", "return", "STATUS_BAR_SUB_PANEL_LAYER", ";", "case", "TYPE_SYSTEM_DIALOG", ":", "return", "SYSTEM_DIALOG_LAYER", ";", "case", "TYPE_SEARCH_BAR", ":", "return", "SEARCH_BAR_LAYER", ";", "case", "TYPE_PHONE", ":", "return", "PHONE_LAYER", ";", "case", "TYPE_KEYGUARD", ":", "return", "KEYGUARD_LAYER", ";", "case", "TYPE_KEYGUARD_DIALOG", ":", "return", "KEYGUARD_DIALOG_LAYER", ";", "case", "TYPE_SYSTEM_ALERT", ":", "return", "SYSTEM_ALERT_LAYER", ";", "case", "TYPE_SYSTEM_ERROR", ":", "return", "SYSTEM_ERROR_LAYER", ";", "case", "TYPE_INPUT_METHOD", ":", "return", "INPUT_METHOD_LAYER", ";", "case", "TYPE_INPUT_METHOD_DIALOG", ":", "return", "INPUT_METHOD_DIALOG_LAYER", ";", "case", "TYPE_VOLUME_OVERLAY", ":", "return", "VOLUME_OVERLAY_LAYER", ";", "case", "TYPE_SYSTEM_OVERLAY", ":", "return", "SYSTEM_OVERLAY_LAYER", ";", "case", "TYPE_SECURE_SYSTEM_OVERLAY", ":", "return", "SECURE_SYSTEM_OVERLAY_LAYER", ";", "case", "TYPE_PRIORITY_PHONE", ":", "return", "PRIORITY_PHONE_LAYER", ";", "case", "TYPE_TOAST", ":", "return", "TOAST_LAYER", ";", "case", "TYPE_WALLPAPER", ":", "return", "WALLPAPER_LAYER", ";", "case", "TYPE_DRAG", ":", "return", "DRAG_LAYER", ";", "case", "TYPE_POINTER", ":", "return", "POINTER_LAYER", ";", "case", "TYPE_NAVIGATION_BAR", ":", "return", "NAVIGATION_BAR_LAYER", ";", "case", "TYPE_BOOT_PROGRESS", ":", "return", "BOOT_PROGRESS_LAYER", ";", "case", "TYPE_HIDDEN_NAV_CONSUMER", ":", "return", "HIDDEN_NAV_CONSUMER_LAYER", ";", "}", "Log", ".", "e", "(", "TAG", ",", "\"\"", "+", "type", ")", ";", "return", "APPLICATION_LAYER", ";", "}", "public", "int", "subWindowTypeToLayerLw", "(", "int", "type", ")", "{", "switch", "(", "type", ")", "{", "case", "TYPE_APPLICATION_PANEL", ":", "case", "TYPE_APPLICATION_ATTACHED_DIALOG", ":", "return", "APPLICATION_PANEL_SUBLAYER", ";", "case", "TYPE_APPLICATION_MEDIA", ":", "return", "APPLICATION_MEDIA_SUBLAYER", ";", "case", "TYPE_APPLICATION_MEDIA_OVERLAY", ":", "return", "APPLICATION_MEDIA_OVERLAY_SUBLAYER", ";", "case", "TYPE_APPLICATION_SUB_PANEL", ":", "return", "APPLICATION_SUB_PANEL_SUBLAYER", ";", "}", "Log", ".", "e", "(", "TAG", ",", "\"\"", "+", "type", ")", ";", "return", "0", ";", "}", "public", "int", "getMaxWallpaperLayer", "(", ")", "{", "return", "STATUS_BAR_LAYER", ";", "}", "public", "boolean", "canStatusBarHide", "(", ")", "{", "return", "mStatusBarCanHide", ";", "}", "public", "int", "getNonDecorDisplayWidth", "(", "int", "fullWidth", ",", "int", "fullHeight", ",", "int", "rotation", ")", "{", "if", "(", "fullWidth", ">", "fullHeight", ")", "{", "return", "fullWidth", "-", "mNavigationBarWidth", ";", "}", "return", "fullWidth", ";", "}", "public", "int", "getNonDecorDisplayHeight", "(", "int", "fullWidth", ",", "int", "fullHeight", ",", "int", "rotation", ")", "{", "return", "fullHeight", "-", "(", "mStatusBarCanHide", "?", "0", ":", "mStatusBarHeight", ")", "-", "(", "(", "fullWidth", ">", "fullHeight", ")", "?", "0", ":", "mNavigationBarHeight", ")", ";", "}", "public", "int", "getConfigDisplayWidth", "(", "int", "fullWidth", ",", "int", "fullHeight", ",", "int", "rotation", ")", "{", "return", "getNonDecorDisplayWidth", "(", "fullWidth", ",", "fullHeight", ",", "rotation", ")", ";", "}", "public", "int", "getConfigDisplayHeight", "(", "int", "fullWidth", ",", "int", "fullHeight", ",", "int", "rotation", ")", "{", "return", "getNonDecorDisplayHeight", "(", "fullWidth", ",", "fullHeight", ",", "rotation", ")", "-", "(", "mStatusBarCanHide", "?", "mStatusBarHeight", ":", "0", ")", ";", "}", "public", "boolean", "doesForceHide", "(", "WindowState", "win", ",", "WindowManager", ".", "LayoutParams", "attrs", ")", "{", "return", "attrs", ".", "type", "==", "WindowManager", ".", "LayoutParams", ".", "TYPE_KEYGUARD", ";", "}", "public", "boolean", "canBeForceHidden", "(", "WindowState", "win", ",", "WindowManager", ".", "LayoutParams", "attrs", ")", "{", "return", "attrs", ".", "type", "!=", "WindowManager", ".", "LayoutParams", ".", "TYPE_STATUS_BAR", "&&", "attrs", ".", "type", "!=", "WindowManager", ".", "LayoutParams", ".", "TYPE_WALLPAPER", ";", "}", "public", "View", "addStartingWindow", "(", "IBinder", "appToken", ",", "String", "packageName", ",", "int", "theme", ",", "CompatibilityInfo", "compatInfo", ",", "CharSequence", "nonLocalizedLabel", ",", "int", "labelRes", ",", "int", "icon", ",", "int", "windowFlags", ")", "{", "if", "(", "!", "SHOW_STARTING_ANIMATIONS", ")", "{", "return", "null", ";", "}", "if", "(", "packageName", "==", "null", ")", "{", "return", "null", ";", "}", "try", "{", "Context", "context", "=", "mContext", ";", "try", "{", "context", "=", "context", ".", "createPackageContext", "(", "packageName", ",", "0", ")", ";", "if", "(", "theme", "!=", "context", ".", "getThemeResId", "(", ")", ")", "{", "context", ".", "setTheme", "(", "theme", ")", ";", "}", "}", "catch", "(", "PackageManager", ".", "NameNotFoundException", "e", ")", "{", "}", "Window", "win", "=", "PolicyManager", ".", "makeNewWindow", "(", "context", ")", ";", "if", "(", "win", ".", "getWindowStyle", "(", ")", ".", "getBoolean", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "Window_windowDisablePreview", ",", "false", ")", ")", "{", "return", "null", ";", "}", "Resources", "r", "=", "context", ".", "getResources", "(", ")", ";", "win", ".", "setTitle", "(", "r", ".", "getText", "(", "labelRes", ",", "nonLocalizedLabel", ")", ")", ";", "win", ".", "setType", "(", "WindowManager", ".", "LayoutParams", ".", "TYPE_APPLICATION_STARTING", ")", ";", "win", ".", "setFlags", "(", "windowFlags", "|", "WindowManager", ".", "LayoutParams", ".", "FLAG_NOT_TOUCHABLE", "|", "WindowManager", ".", "LayoutParams", ".", "FLAG_NOT_FOCUSABLE", "|", "WindowManager", ".", "LayoutParams", ".", "FLAG_ALT_FOCUSABLE_IM", ",", "windowFlags", "|", "WindowManager", ".", "LayoutParams", ".", "FLAG_NOT_TOUCHABLE", "|", "WindowManager", ".", "LayoutParams", ".", "FLAG_NOT_FOCUSABLE", "|", "WindowManager", ".", "LayoutParams", ".", "FLAG_ALT_FOCUSABLE_IM", ")", ";", "if", "(", "!", "compatInfo", ".", "supportsScreen", "(", ")", ")", "{", "win", ".", "addFlags", "(", "WindowManager", ".", "LayoutParams", ".", "FLAG_COMPATIBLE_WINDOW", ")", ";", "}", "win", ".", "setLayout", "(", "WindowManager", ".", "LayoutParams", ".", "MATCH_PARENT", ",", "WindowManager", ".", "LayoutParams", ".", "MATCH_PARENT", ")", ";", "final", "WindowManager", ".", "LayoutParams", "params", "=", "win", ".", "getAttributes", "(", ")", ";", "params", ".", "token", "=", "appToken", ";", "params", ".", "packageName", "=", "packageName", ";", "params", ".", "windowAnimations", "=", "win", ".", "getWindowStyle", "(", ")", ".", "getResourceId", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "styleable", ".", "Window_windowAnimationStyle", ",", "0", ")", ";", "params", ".", "privateFlags", "|=", "WindowManager", ".", "LayoutParams", ".", "PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED", ";", "params", ".", "setTitle", "(", "\"Starting", "\"", "+", "packageName", ")", ";", "WindowManager", "wm", "=", "(", "WindowManager", ")", "context", ".", "getSystemService", "(", "Context", ".", "WINDOW_SERVICE", ")", ";", "View", "view", "=", "win", ".", "getDecorView", "(", ")", ";", "if", "(", "win", ".", "isFloating", "(", ")", ")", "{", "return", "null", ";", "}", "if", "(", "localLOGV", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", "+", "packageName", "+", "\"", "/", "\"", "+", "appToken", "+", "\":", "\"", "+", "(", "view", ".", "getParent", "(", ")", "!=", "null", "?", "view", ":", "null", ")", ")", ";", "wm", ".", "addView", "(", "view", ",", "params", ")", ";", "return", "view", ".", "getParent", "(", ")", "!=", "null", "?", "view", ":", "null", ";", "}", "catch", "(", "WindowManagerImpl", ".", "BadTokenException", "e", ")", "{", "Log", ".", "w", "(", "TAG", ",", "appToken", "+", "\"\"", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "Log", ".", "w", "(", "TAG", ",", "appToken", "+", "\"\"", ",", "e", ")", ";", "}", "return", "null", ";", "}", "public", "void", "removeStartingWindow", "(", "IBinder", "appToken", ",", "View", "window", ")", "{", "if", "(", "localLOGV", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", "+", "appToken", "+", "\":", "\"", "+", "window", ")", ";", "if", "(", "window", "!=", "null", ")", "{", "WindowManager", "wm", "=", "(", "WindowManager", ")", "mContext", ".", "getSystemService", "(", "Context", ".", "WINDOW_SERVICE", ")", ";", "wm", ".", "removeView", "(", "window", ")", ";", "}", "}", "public", "int", "prepareAddWindowLw", "(", "WindowState", "win", ",", "WindowManager", ".", "LayoutParams", "attrs", ")", "{", "switch", "(", "attrs", ".", "type", ")", "{", "case", "TYPE_STATUS_BAR", ":", "mContext", ".", "enforceCallingOrSelfPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "STATUS_BAR_SERVICE", ",", "\"\"", ")", ";", "if", "(", "mStatusBar", "!=", "null", ")", "{", "return", "WindowManagerImpl", ".", "ADD_MULTIPLE_SINGLETON", ";", "}", "mStatusBar", "=", "win", ";", "break", ";", "case", "TYPE_NAVIGATION_BAR", ":", "mContext", ".", "enforceCallingOrSelfPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "STATUS_BAR_SERVICE", ",", "\"\"", ")", ";", "mNavigationBar", "=", "win", ";", "if", "(", "DEBUG_LAYOUT", ")", "Log", ".", "i", "(", "TAG", ",", "\"\"", "+", "mNavigationBar", ")", ";", "break", ";", "case", "TYPE_STATUS_BAR_PANEL", ":", "mContext", ".", "enforceCallingOrSelfPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "STATUS_BAR_SERVICE", ",", "\"\"", ")", ";", "mStatusBarPanels", ".", "add", "(", "win", ")", ";", "break", ";", "case", "TYPE_STATUS_BAR_SUB_PANEL", ":", "mContext", ".", "enforceCallingOrSelfPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "STATUS_BAR_SERVICE", ",", "\"\"", ")", ";", "mStatusBarPanels", ".", "add", "(", "win", ")", ";", "break", ";", "case", "TYPE_KEYGUARD", ":", "if", "(", "mKeyguard", "!=", "null", ")", "{", "return", "WindowManagerImpl", ".", "ADD_MULTIPLE_SINGLETON", ";", "}", "mKeyguard", "=", "win", ";", "break", ";", "}", "return", "WindowManagerImpl", ".", "ADD_OKAY", ";", "}", "public", "void", "removeWindowLw", "(", "WindowState", "win", ")", "{", "if", "(", "mStatusBar", "==", "win", ")", "{", "mStatusBar", "=", "null", ";", "}", "else", "if", "(", "mKeyguard", "==", "win", ")", "{", "mKeyguard", "=", "null", ";", "}", "else", "if", "(", "mNavigationBar", "==", "win", ")", "{", "mNavigationBar", "=", "null", ";", "}", "else", "{", "mStatusBarPanels", ".", "remove", "(", "win", ")", ";", "}", "}", "static", "final", "boolean", "PRINT_ANIM", "=", "false", ";", "public", "int", "selectAnimationLw", "(", "WindowState", "win", ",", "int", "transit", ")", "{", "if", "(", "PRINT_ANIM", ")", "Log", ".", "i", "(", "TAG", ",", "\"\"", "+", "win", "+", "\":", "transit=\"", "+", "transit", ")", ";", "if", "(", "transit", "==", "TRANSIT_PREVIEW_DONE", ")", "{", "if", "(", "win", ".", "hasAppShownWindows", "(", ")", ")", "{", "if", "(", "PRINT_ANIM", ")", "Log", ".", "i", "(", "TAG", ",", "\"\"", ")", ";", "return", "com", ".", "android", ".", "internal", ".", "R", ".", "anim", ".", "app_starting_exit", ";", "}", "}", "return", "0", ";", "}", "public", "Animation", "createForceHideEnterAnimation", "(", ")", "{", "return", "AnimationUtils", ".", "loadAnimation", "(", "mContext", ",", "com", ".", "android", ".", "internal", ".", "R", ".", "anim", ".", "lock_screen_behind_enter", ")", ";", "}", "static", "ITelephony", "getTelephonyService", "(", ")", "{", "ITelephony", "telephonyService", "=", "ITelephony", ".", "Stub", ".", "asInterface", "(", "ServiceManager", ".", "checkService", "(", "Context", ".", "TELEPHONY_SERVICE", ")", ")", ";", "if", "(", "telephonyService", "==", "null", ")", "{", "Log", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "}", "return", "telephonyService", ";", "}", "static", "IAudioService", "getAudioService", "(", ")", "{", "IAudioService", "audioService", "=", "IAudioService", ".", "Stub", ".", "asInterface", "(", "ServiceManager", ".", "checkService", "(", "Context", ".", "AUDIO_SERVICE", ")", ")", ";", "if", "(", "audioService", "==", "null", ")", "{", "Log", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "}", "return", "audioService", ";", "}", "boolean", "keyguardOn", "(", ")", "{", "return", "keyguardIsShowingTq", "(", ")", "||", "inKeyguardRestrictedKeyInputMode", "(", ")", ";", "}", "private", "static", "final", "int", "[", "]", "WINDOW_TYPES_WHERE_HOME_DOESNT_WORK", "=", "{", "WindowManager", ".", "LayoutParams", ".", "TYPE_SYSTEM_ALERT", ",", "WindowManager", ".", "LayoutParams", ".", "TYPE_SYSTEM_ERROR", ",", "}", ";", "@", "Override", "public", "long", "interceptKeyBeforeDispatching", "(", "WindowState", "win", ",", "KeyEvent", "event", ",", "int", "policyFlags", ")", "{", "final", "boolean", "keyguardOn", "=", "keyguardOn", "(", ")", ";", "final", "int", "keyCode", "=", "event", ".", "getKeyCode", "(", ")", ";", "final", "int", "repeatCount", "=", "event", ".", "getRepeatCount", "(", ")", ";", "final", "int", "metaState", "=", "event", ".", "getMetaState", "(", ")", ";", "final", "int", "flags", "=", "event", ".", "getFlags", "(", ")", ";", "final", "boolean", "down", "=", "event", ".", "getAction", "(", ")", "==", "KeyEvent", ".", "ACTION_DOWN", ";", "final", "boolean", "canceled", "=", "event", ".", "isCanceled", "(", ")", ";", "if", "(", "false", ")", "{", "Log", ".", "d", "(", "TAG", ",", "\"\"", "+", "keyCode", "+", "\"", "down=\"", "+", "down", "+", "\"\"", "+", "repeatCount", "+", "\"", "keyguardOn=\"", "+", "keyguardOn", "+", "\"\"", "+", "mHomePressed", ")", ";", "}", "if", "(", "(", "flags", "&", "KeyEvent", ".", "FLAG_FALLBACK", ")", "==", "0", ")", "{", "if", "(", "mVolumeDownKeyTriggered", "&&", "!", "mPowerKeyTriggered", "&&", "!", "mVolumeUpKeyTriggered", ")", "{", "final", "long", "now", "=", "SystemClock", ".", "uptimeMillis", "(", ")", ";", "final", "long", "timeoutTime", "=", "mVolumeDownKeyTime", "+", "ACTION_CHORD_DEBOUNCE_DELAY_MILLIS", ";", "if", "(", "now", "<", "timeoutTime", ")", "{", "return", "timeoutTime", "-", "now", ";", "}", "}", "else", "if", "(", "mVolumeUpKeyTriggered", "&&", "!", "mVolumeDownKeyTriggered", ")", "{", "final", "long", "now", "=", "SystemClock", ".", "uptimeMillis", "(", ")", ";", "final", "long", "timeoutTime", "=", "mVolumeUpKeyTime", "+", "ACTION_CHORD_DEBOUNCE_DELAY_MILLIS", ";", "if", "(", "now", "<", "timeoutTime", ")", "{", "return", "timeoutTime", "-", "now", ";", "}", "}", "if", "(", "keyCode", "==", "KeyEvent", ".", "KEYCODE_VOLUME_DOWN", "&&", "mVolumeDownKeyConsumedByChord", ")", "{", "if", "(", "!", "down", ")", "{", "mVolumeDownKeyConsumedByChord", "=", "false", ";", "}", "return", "-", "1", ";", "}", "else", "if", "(", "keyCode", "==", "KeyEvent", ".", "KEYCODE_VOLUME_UP", "&&", "mVolumeUpKeyConsumedByChord", ")", "{", "if", "(", "!", "down", ")", "{", "mVolumeUpKeyConsumedByChord", "=", "false", ";", "}", "return", "-", "1", ";", "}", "}", "if", "(", "keyCode", "==", "KeyEvent", ".", "KEYCODE_BACK", "&&", "!", "down", ")", "{", "mHandler", ".", "removeCallbacks", "(", "mBackLongPress", ")", ";", "}", "if", "(", "keyCode", "==", "KeyEvent", ".", "KEYCODE_HOME", ")", "{", "if", "(", "mHomePressed", "&&", "!", "down", ")", "{", "mHomePressed", "=", "false", ";", "if", "(", "!", "canceled", ")", "{", "boolean", "incomingRinging", "=", "false", ";", "try", "{", "ITelephony", "telephonyService", "=", "getTelephonyService", "(", ")", ";", "if", "(", "telephonyService", "!=", "null", ")", "{", "incomingRinging", "=", "telephonyService", ".", "isRinging", "(", ")", ";", "}", "}", "catch", "(", "RemoteException", "ex", ")", "{", "Log", ".", "w", "(", "TAG", ",", "\"\"", ",", "ex", ")", ";", "}", "if", "(", "incomingRinging", ")", "{", "Log", ".", "i", "(", "TAG", ",", "\"\"", ")", ";", "}", "else", "{", "launchHomeFromHotKey", "(", ")", ";", "}", "}", "else", "{", "Log", ".", "i", "(", "TAG", ",", "\"\"", ")", ";", "}", "return", "-", "1", ";", "}", "WindowManager", ".", "LayoutParams", "attrs", "=", "win", "!=", "null", "?", "win", ".", "getAttrs", "(", ")", ":", "null", ";", "if", "(", "attrs", "!=", "null", ")", "{", "final", "int", "type", "=", "attrs", ".", "type", ";", "if", "(", "type", "==", "WindowManager", ".", "LayoutParams", ".", "TYPE_KEYGUARD", "||", "type", "==", "WindowManager", ".", "LayoutParams", ".", "TYPE_KEYGUARD_DIALOG", ")", "{", "return", "0", ";", "}", "final", "int", "typeCount", "=", "WINDOW_TYPES_WHERE_HOME_DOESNT_WORK", ".", "length", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "typeCount", ";", "i", "++", ")", "{", "if", "(", "type", "==", "WINDOW_TYPES_WHERE_HOME_DOESNT_WORK", "[", "i", "]", ")", "{", "return", "-", "1", ";", "}", "}", "}", "if", "(", "down", ")", "{", "if", "(", "repeatCount", "==", "0", ")", "{", "mHomePressed", "=", "true", ";", "}", "else", "if", "(", "(", "event", ".", "getFlags", "(", ")", "&", "KeyEvent", ".", "FLAG_LONG_PRESS", ")", "!=", "0", ")", "{", "if", "(", "!", "keyguardOn", ")", "{", "handleLongPressOnHome", "(", ")", ";", "}", "}", "}", "return", "-", "1", ";", "}", "else", "if", "(", "keyCode", "==", "KeyEvent", ".", "KEYCODE_MENU", ")", "{", "final", "int", "chordBug", "=", "KeyEvent", ".", "META_SHIFT_ON", ";", "if", "(", "down", ")", "{", "if", "(", "repeatCount", "==", "0", ")", "{", "if", "(", "mEnableShiftMenuBugReports", "&&", "(", "metaState", "&", "chordBug", ")", "==", "chordBug", ")", "{", "Intent", "intent", "=", "new", "Intent", "(", "Intent", ".", "ACTION_BUG_REPORT", ")", ";", "mContext", ".", "sendOrderedBroadcast", "(", "intent", ",", "null", ")", ";", "return", "-", "1", ";", "}", "else", "if", "(", "SHOW_PROCESSES_ON_ALT_MENU", "&&", "(", "metaState", "&", "KeyEvent", ".", "META_ALT_ON", ")", "==", "KeyEvent", ".", "META_ALT_ON", ")", "{", "Intent", "service", "=", "new", "Intent", "(", ")", ";", "service", ".", "setClassName", "(", "mContext", ",", "\"\"", ")", ";", "ContentResolver", "res", "=", "mContext", ".", "getContentResolver", "(", ")", ";", "boolean", "shown", "=", "Settings", ".", "System", ".", "getInt", "(", "res", ",", "Settings", ".", "System", ".", "SHOW_PROCESSES", ",", "0", ")", "!=", "0", ";", "if", "(", "!", "shown", ")", "{", "mContext", ".", "startService", "(", "service", ")", ";", "}", "else", "{", "mContext", ".", "stopService", "(", "service", ")", ";", "}", "Settings", ".", "System", ".", "putInt", "(", "res", ",", "Settings", ".", "System", ".", "SHOW_PROCESSES", ",", "shown", "?", "0", ":", "1", ")", ";", "return", "-", "1", ";", "}", "}", "else", "if", "(", "(", "event", ".", "getFlags", "(", ")", "&", "KeyEvent", ".", "FLAG_LONG_PRESS", ")", "!=", "0", ")", "{", "if", "(", "!", "keyguardOn", ")", "{", "handleLongPressOnMenu", "(", ")", ";", "if", "(", "mLongPressOnMenuBehavior", "!=", "LONG_PRESS_MENU_NOTHING", ")", "{", "return", "-", "1", ";", "}", "}", "}", "}", "}", "else", "if", "(", "keyCode", "==", "KeyEvent", ".", "KEYCODE_SEARCH", ")", "{", "if", "(", "down", ")", "{", "if", "(", "repeatCount", "==", "0", ")", "{", "mShortcutKeyPressed", "=", "keyCode", ";", "mConsumeShortcutKeyUp", "=", "false", ";", "}", "}", "else", "if", "(", "keyCode", "==", "mShortcutKeyPressed", ")", "{", "mShortcutKeyPressed", "=", "-", "1", ";", "if", "(", "mConsumeShortcutKeyUp", ")", "{", "mConsumeShortcutKeyUp", "=", "false", ";", "return", "-", "1", ";", "}", "}", "return", "0", ";", "}", "else", "if", "(", "keyCode", "==", "KeyEvent", ".", "KEYCODE_APP_SWITCH", ")", "{", "if", "(", "mAppSwitchPressed", "&&", "!", "down", ")", "{", "mAppSwitchPressed", "=", "false", ";", "if", "(", "!", "canceled", "&&", "!", "keyguardOn", ")", "{", "sendCloseSystemWindows", "(", "SYSTEM_DIALOG_REASON_RECENT_APPS", ")", ";", "try", "{", "mStatusBarService", ".", "toggleRecentApps", "(", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "return", "-", "1", ";", "}", "if", "(", "down", "&&", "repeatCount", "==", "0", ")", "{", "mAppSwitchPressed", "=", "true", ";", "}", "return", "-", "1", ";", "}", "else", "if", "(", "keyCode", "==", "KeyEvent", ".", "KEYCODE_BACK", ")", "{", "if", "(", "Settings", ".", "Secure", ".", "getInt", "(", "mContext", ".", "getContentResolver", "(", ")", ",", "Settings", ".", "Secure", ".", "KILL_APP_LONGPRESS_BACK", ",", "0", ")", "==", "1", ")", "{", "if", "(", "down", "&&", "repeatCount", "==", "0", ")", "{", "mHandler", ".", "postDelayed", "(", "mBackLongPress", ",", "ViewConfiguration", ".", "getGlobalActionKeyTimeout", "(", ")", ")", ";", "}", "}", "}", "if", "(", "mShortcutKeyPressed", "!=", "-", "1", ")", "{", "final", "KeyCharacterMap", "kcm", "=", "event", ".", "getKeyCharacterMap", "(", ")", ";", "if", "(", "kcm", ".", "isPrintingKey", "(", "keyCode", ")", ")", "{", "mConsumeShortcutKeyUp", "=", "true", ";", "if", "(", "down", "&&", "repeatCount", "==", "0", "&&", "!", "keyguardOn", ")", "{", "Intent", "shortcutIntent", "=", "mShortcutManager", ".", "getIntent", "(", "kcm", ",", "keyCode", ",", "metaState", ")", ";", "if", "(", "shortcutIntent", "!=", "null", ")", "{", "shortcutIntent", ".", "addFlags", "(", "Intent", ".", "FLAG_ACTIVITY_NEW_TASK", ")", ";", "try", "{", "mContext", ".", "startActivity", "(", "shortcutIntent", ")", ";", "}", "catch", "(", "ActivityNotFoundException", "ex", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "\"\"", "+", "KeyEvent", ".", "keyCodeToString", "(", "mShortcutKeyPressed", ")", "+", "\"+\"", "+", "KeyEvent", ".", "keyCodeToString", "(", "keyCode", ")", ",", "ex", ")", ";", "}", "}", "else", "{", "Slog", ".", "i", "(", "TAG", ",", "\"\"", "+", "KeyEvent", ".", "keyCodeToString", "(", "mShortcutKeyPressed", ")", "+", "\"+\"", "+", "KeyEvent", ".", "keyCodeToString", "(", "keyCode", ")", ")", ";", "}", "}", "return", "-", "1", ";", "}", "}", "if", "(", "down", "&&", "repeatCount", "==", "0", "&&", "(", "metaState", "&", "KeyEvent", ".", "META_META_ON", ")", "!=", "0", ")", "{", "final", "KeyCharacterMap", "kcm", "=", "event", ".", "getKeyCharacterMap", "(", ")", ";", "Intent", "shortcutIntent", "=", "mShortcutManager", ".", "getIntent", "(", "kcm", ",", "keyCode", ",", "metaState", "&", "~", "(", "KeyEvent", ".", "META_META_ON", "|", "KeyEvent", ".", "META_META_LEFT_ON", "|", "KeyEvent", ".", "META_META_RIGHT_ON", ")", ")", ";", "if", "(", "shortcutIntent", "!=", "null", ")", "{", "shortcutIntent", ".", "addFlags", "(", "Intent", ".", "FLAG_ACTIVITY_NEW_TASK", ")", ";", "try", "{", "mContext", ".", "startActivity", "(", "shortcutIntent", ")", ";", "}", "catch", "(", "ActivityNotFoundException", "ex", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "\"\"", "+", "\"META+\"", "+", "KeyEvent", ".", "keyCodeToString", "(", "keyCode", ")", ",", "ex", ")", ";", "}", "return", "-", "1", ";", "}", "}", "if", "(", "down", "&&", "repeatCount", "==", "0", ")", "{", "String", "category", "=", "sApplicationLaunchKeyCategories", ".", "get", "(", "keyCode", ")", ";", "if", "(", "category", "!=", "null", ")", "{", "Intent", "intent", "=", "Intent", ".", "makeMainSelectorActivity", "(", "Intent", ".", "ACTION_MAIN", ",", "category", ")", ";", "intent", ".", "setFlags", "(", "Intent", ".", "FLAG_ACTIVITY_NEW_TASK", ")", ";", "try", "{", "mContext", ".", "startActivity", "(", "intent", ")", ";", "}", "catch", "(", "ActivityNotFoundException", "ex", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "\"\"", "+", "\"keyCode=\"", "+", "keyCode", "+", "\",", "category=\"", "+", "category", ",", "ex", ")", ";", "}", "return", "-", "1", ";", "}", "}", "if", "(", "down", "&&", "repeatCount", "==", "0", "&&", "keyCode", "==", "KeyEvent", ".", "KEYCODE_TAB", ")", "{", "if", "(", "mRecentAppsDialogHeldModifiers", "==", "0", ")", "{", "final", "int", "shiftlessModifiers", "=", "event", ".", "getModifiers", "(", ")", "&", "~", "KeyEvent", ".", "META_SHIFT_MASK", ";", "if", "(", "KeyEvent", ".", "metaStateHasModifiers", "(", "shiftlessModifiers", ",", "KeyEvent", ".", "META_ALT_ON", ")", "||", "KeyEvent", ".", "metaStateHasModifiers", "(", "shiftlessModifiers", ",", "KeyEvent", ".", "META_META_ON", ")", ")", "{", "mRecentAppsDialogHeldModifiers", "=", "shiftlessModifiers", ";", "showOrHideRecentAppsDialog", "(", "RECENT_APPS_BEHAVIOR_EXIT_TOUCH_MODE_AND_SHOW", ")", ";", "return", "-", "1", ";", "}", "}", "}", "else", "if", "(", "!", "down", "&&", "mRecentAppsDialogHeldModifiers", "!=", "0", "&&", "(", "metaState", "&", "mRecentAppsDialogHeldModifiers", ")", "==", "0", ")", "{", "mRecentAppsDialogHeldModifiers", "=", "0", ";", "showOrHideRecentAppsDialog", "(", "RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH", ")", ";", "}", "if", "(", "mDeviceKeyHandler", "!=", "null", ")", "{", "try", "{", "return", "mDeviceKeyHandler", ".", "handleKeyEvent", "(", "event", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "Slog", ".", "d", "(", "TAG", ",", "\"\"", ",", "e", ")", ";", "}", "}", "return", "0", ";", "}", "@", "Override", "public", "KeyEvent", "dispatchUnhandledKey", "(", "WindowState", "win", ",", "KeyEvent", "event", ",", "int", "policyFlags", ")", "{", "if", "(", "DEBUG_FALLBACK", ")", "{", "Slog", ".", "d", "(", "TAG", ",", "\"\"", "+", "win", "+", "\",", "action=\"", "+", "event", ".", "getAction", "(", ")", "+", "\",", "flags=\"", "+", "event", ".", "getFlags", "(", ")", "+", "\",", "keyCode=\"", "+", "event", ".", "getKeyCode", "(", ")", "+", "\",", "scanCode=\"", "+", "event", ".", "getScanCode", "(", ")", "+", "\",", "metaState=\"", "+", "event", ".", "getMetaState", "(", ")", "+", "\"\"", "+", "event", ".", "getRepeatCount", "(", ")", "+", "\"\"", "+", "policyFlags", ")", ";", "}", "if", "(", "(", "event", ".", "getFlags", "(", ")", "&", "KeyEvent", ".", "FLAG_FALLBACK", ")", "==", "0", ")", "{", "final", "KeyCharacterMap", "kcm", "=", "event", ".", "getKeyCharacterMap", "(", ")", ";", "final", "int", "keyCode", "=", "event", ".", "getKeyCode", "(", ")", ";", "final", "int", "metaState", "=", "event", ".", "getMetaState", "(", ")", ";", "if", "(", "getFallbackAction", "(", "kcm", ",", "keyCode", ",", "metaState", ",", "mFallbackAction", ")", ")", "{", "if", "(", "DEBUG_FALLBACK", ")", "{", "Slog", ".", "d", "(", "TAG", ",", "\"\"", "+", "mFallbackAction", ".", "keyCode", "+", "\"", "metaState=\"", "+", "Integer", ".", "toHexString", "(", "mFallbackAction", ".", "metaState", ")", ")", ";", "}", "int", "flags", "=", "event", ".", "getFlags", "(", ")", "|", "KeyEvent", ".", "FLAG_FALLBACK", ";", "KeyEvent", "fallbackEvent", "=", "KeyEvent", ".", "obtain", "(", "event", ".", "getDownTime", "(", ")", ",", "event", ".", "getEventTime", "(", ")", ",", "event", ".", "getAction", "(", ")", ",", "mFallbackAction", ".", "keyCode", ",", "event", ".", "getRepeatCount", "(", ")", ",", "mFallbackAction", ".", "metaState", ",", "event", ".", "getDeviceId", "(", ")", ",", "event", ".", "getScanCode", "(", ")", ",", "flags", ",", "event", ".", "getSource", "(", ")", ",", "null", ")", ";", "int", "actions", "=", "interceptKeyBeforeQueueing", "(", "fallbackEvent", ",", "policyFlags", ",", "true", ")", ";", "if", "(", "(", "actions", "&", "ACTION_PASS_TO_USER", ")", "!=", "0", ")", "{", "long", "delayMillis", "=", "interceptKeyBeforeDispatching", "(", "win", ",", "fallbackEvent", ",", "policyFlags", ")", ";", "if", "(", "delayMillis", "==", "0", ")", "{", "if", "(", "DEBUG_FALLBACK", ")", "{", "Slog", ".", "d", "(", "TAG", ",", "\"\"", ")", ";", "}", "return", "fallbackEvent", ";", "}", "}", "fallbackEvent", ".", "recycle", "(", ")", ";", "}", "}", "if", "(", "DEBUG_FALLBACK", ")", "{", "Slog", ".", "d", "(", "TAG", ",", "\"No", "fallback.\"", ")", ";", "}", "return", "null", ";", "}", "private", "boolean", "getFallbackAction", "(", "KeyCharacterMap", "kcm", ",", "int", "keyCode", ",", "int", "metaState", ",", "FallbackAction", "outFallbackAction", ")", "{", "return", "kcm", ".", "getFallbackAction", "(", "keyCode", ",", "metaState", ",", "outFallbackAction", ")", ";", "}", "void", "launchHomeFromHotKey", "(", ")", "{", "if", "(", "mKeyguardMediator", ".", "isShowingAndNotHidden", "(", ")", ")", "{", "}", "else", "if", "(", "!", "mHideLockScreen", "&&", "mKeyguardMediator", ".", "isInputRestricted", "(", ")", ")", "{", "mKeyguardMediator", ".", "verifyUnlock", "(", "new", "OnKeyguardExitResult", "(", ")", "{", "public", "void", "onKeyguardExitResult", "(", "boolean", "success", ")", "{", "if", "(", "success", ")", "{", "try", "{", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "stopAppSwitches", "(", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "sendCloseSystemWindows", "(", "SYSTEM_DIALOG_REASON_HOME_KEY", ")", ";", "startDockOrHome", "(", ")", ";", "}", "}", "}", ")", ";", "}", "else", "{", "try", "{", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "stopAppSwitches", "(", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "sendCloseSystemWindows", "(", "SYSTEM_DIALOG_REASON_HOME_KEY", ")", ";", "startDockOrHome", "(", ")", ";", "}", "}", "final", "Runnable", "mAllowSystemUiDelay", "=", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "}", "}", ";", "final", "InputHandler", "mHideNavInputHandler", "=", "new", "BaseInputHandler", "(", ")", "{", "@", "Override", "public", "void", "handleMotion", "(", "MotionEvent", "event", ",", "InputQueue", ".", "FinishedCallback", "finishedCallback", ")", "{", "boolean", "handled", "=", "false", ";", "try", "{", "if", "(", "(", "event", ".", "getSource", "(", ")", "&", "InputDevice", ".", "SOURCE_CLASS_POINTER", ")", "!=", "0", ")", "{", "if", "(", "event", ".", "getAction", "(", ")", "==", "MotionEvent", ".", "ACTION_DOWN", ")", "{", "boolean", "changed", "=", "false", ";", "synchronized", "(", "mLock", ")", "{", "int", "newVal", "=", "mResettingSystemUiFlags", "|", "View", ".", "SYSTEM_UI_FLAG_HIDE_NAVIGATION", ";", "if", "(", "mResettingSystemUiFlags", "!=", "newVal", ")", "{", "mResettingSystemUiFlags", "=", "newVal", ";", "changed", "=", "true", ";", "}", "newVal", "=", "mForceClearedSystemUiFlags", "|", "View", ".", "SYSTEM_UI_FLAG_HIDE_NAVIGATION", ";", "if", "(", "mForceClearedSystemUiFlags", "!=", "newVal", ")", "{", "mForceClearedSystemUiFlags", "=", "newVal", ";", "changed", "=", "true", ";", "mHandler", ".", "postDelayed", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "synchronized", "(", "mLock", ")", "{", "mForceClearedSystemUiFlags", "&=", "~", "View", ".", "SYSTEM_UI_FLAG_HIDE_NAVIGATION", ";", "}", "mWindowManagerFuncs", ".", "reevaluateStatusBarVisibility", "(", ")", ";", "}", "}", ",", "1000", ")", ";", "}", "}", "if", "(", "changed", ")", "{", "mWindowManagerFuncs", ".", "reevaluateStatusBarVisibility", "(", ")", ";", "}", "}", "}", "}", "finally", "{", "finishedCallback", ".", "finished", "(", "handled", ")", ";", "}", "}", "}", ";", "@", "Override", "public", "int", "adjustSystemUiVisibilityLw", "(", "int", "visibility", ")", "{", "mResettingSystemUiFlags", "&=", "visibility", ";", "return", "visibility", "&", "~", "mResettingSystemUiFlags", "&", "~", "mForceClearedSystemUiFlags", ";", "}", "public", "void", "getContentInsetHintLw", "(", "WindowManager", ".", "LayoutParams", "attrs", ",", "Rect", "contentInset", ")", "{", "final", "int", "fl", "=", "attrs", ".", "flags", ";", "if", "(", "(", "fl", "&", "(", "FLAG_LAYOUT_IN_SCREEN", "|", "FLAG_FULLSCREEN", "|", "FLAG_LAYOUT_INSET_DECOR", ")", ")", "==", "(", "FLAG_LAYOUT_IN_SCREEN", "|", "FLAG_LAYOUT_INSET_DECOR", ")", ")", "{", "contentInset", ".", "set", "(", "mCurLeft", ",", "mCurTop", ",", "(", "mRestrictedScreenLeft", "+", "mRestrictedScreenWidth", ")", "-", "mCurRight", ",", "(", "mRestrictedScreenTop", "+", "mRestrictedScreenHeight", ")", "-", "mCurBottom", ")", ";", "}", "else", "{", "contentInset", ".", "setEmpty", "(", ")", ";", "}", "}", "public", "void", "beginLayoutLw", "(", "int", "displayWidth", ",", "int", "displayHeight", ",", "int", "displayRotation", ")", "{", "mUnrestrictedScreenLeft", "=", "mUnrestrictedScreenTop", "=", "0", ";", "mUnrestrictedScreenWidth", "=", "displayWidth", ";", "mUnrestrictedScreenHeight", "=", "displayHeight", ";", "mRestrictedScreenLeft", "=", "mRestrictedScreenTop", "=", "0", ";", "mRestrictedScreenWidth", "=", "displayWidth", ";", "mRestrictedScreenHeight", "=", "displayHeight", ";", "mDockLeft", "=", "mContentLeft", "=", "mCurLeft", "=", "0", ";", "mDockTop", "=", "mContentTop", "=", "mCurTop", "=", "0", ";", "mDockRight", "=", "mContentRight", "=", "mCurRight", "=", "displayWidth", ";", "mDockBottom", "=", "mContentBottom", "=", "mCurBottom", "=", "displayHeight", ";", "mDockLayer", "=", "0x10000000", ";", "final", "Rect", "pf", "=", "mTmpParentFrame", ";", "final", "Rect", "df", "=", "mTmpDisplayFrame", ";", "final", "Rect", "vf", "=", "mTmpVisibleFrame", ";", "pf", ".", "left", "=", "df", ".", "left", "=", "vf", ".", "left", "=", "mDockLeft", ";", "pf", ".", "top", "=", "df", ".", "top", "=", "vf", ".", "top", "=", "mDockTop", ";", "pf", ".", "right", "=", "df", ".", "right", "=", "vf", ".", "right", "=", "mDockRight", ";", "pf", ".", "bottom", "=", "df", ".", "bottom", "=", "vf", ".", "bottom", "=", "mDockBottom", ";", "final", "boolean", "navVisible", "=", "(", "mNavigationBar", "==", "null", "||", "mNavigationBar", ".", "isVisibleLw", "(", ")", ")", "&&", "(", "mLastSystemUiFlags", "&", "View", ".", "SYSTEM_UI_FLAG_HIDE_NAVIGATION", ")", "==", "0", ";", "if", "(", "navVisible", ")", "{", "if", "(", "mHideNavFakeWindow", "!=", "null", ")", "{", "mHideNavFakeWindow", ".", "dismiss", "(", ")", ";", "mHideNavFakeWindow", "=", "null", ";", "}", "}", "else", "if", "(", "mHideNavFakeWindow", "==", "null", ")", "{", "mHideNavFakeWindow", "=", "mWindowManagerFuncs", ".", "addFakeWindow", "(", "mHandler", ".", "getLooper", "(", ")", ",", "mHideNavInputHandler", ",", "\"hidden", "nav\"", ",", "WindowManager", ".", "LayoutParams", ".", "TYPE_HIDDEN_NAV_CONSUMER", ",", "0", ",", "false", ",", "false", ",", "true", ")", ";", "}", "if", "(", "mStatusBar", "!=", "null", ")", "{", "if", "(", "mNavigationBar", "!=", "null", ")", "{", "if", "(", "displayWidth", "<", "displayHeight", ")", "{", "mTmpNavigationFrame", ".", "set", "(", "0", ",", "displayHeight", "-", "mNavigationBarHeight", ",", "displayWidth", ",", "displayHeight", ")", ";", "if", "(", "navVisible", ")", "{", "mDockBottom", "=", "mTmpNavigationFrame", ".", "top", ";", "mRestrictedScreenHeight", "=", "mDockBottom", "-", "mDockTop", ";", "}", "else", "{", "mTmpNavigationFrame", ".", "offset", "(", "0", ",", "mNavigationBarHeight", ")", ";", "}", "}", "else", "{", "mTmpNavigationFrame", ".", "set", "(", "displayWidth", "-", "mNavigationBarWidth", ",", "0", ",", "displayWidth", ",", "displayHeight", ")", ";", "if", "(", "navVisible", ")", "{", "mDockRight", "=", "mTmpNavigationFrame", ".", "left", ";", "mRestrictedScreenWidth", "=", "mDockRight", "-", "mDockLeft", ";", "}", "else", "{", "mTmpNavigationFrame", ".", "offset", "(", "mNavigationBarWidth", ",", "0", ")", ";", "}", "}", "mContentTop", "=", "mCurTop", "=", "mDockTop", ";", "mContentBottom", "=", "mCurBottom", "=", "mDockBottom", ";", "mContentLeft", "=", "mCurLeft", "=", "mDockLeft", ";", "mContentRight", "=", "mCurRight", "=", "mDockRight", ";", "mNavigationBar", ".", "computeFrameLw", "(", "mTmpNavigationFrame", ",", "mTmpNavigationFrame", ",", "mTmpNavigationFrame", ",", "mTmpNavigationFrame", ")", ";", "if", "(", "DEBUG_LAYOUT", ")", "Log", ".", "i", "(", "TAG", ",", "\"\"", "+", "mTmpNavigationFrame", ")", ";", "}", "if", "(", "DEBUG_LAYOUT", ")", "Log", ".", "i", "(", "TAG", ",", "String", ".", "format", "(", "\"\"", ",", "mDockLeft", ",", "mDockTop", ",", "mDockRight", ",", "mDockBottom", ")", ")", ";", "pf", ".", "left", "=", "df", ".", "left", "=", "vf", ".", "left", "=", "mDockLeft", ";", "pf", ".", "top", "=", "df", ".", "top", "=", "vf", ".", "top", "=", "mDockTop", ";", "pf", ".", "right", "=", "df", ".", "right", "=", "vf", ".", "right", "=", "mDockRight", ";", "pf", ".", "bottom", "=", "df", ".", "bottom", "=", "vf", ".", "bottom", "=", "mDockBottom", ";", "mStatusBar", ".", "computeFrameLw", "(", "pf", ",", "df", ",", "vf", ",", "vf", ")", ";", "if", "(", "mStatusBar", ".", "isVisibleLw", "(", ")", ")", "{", "final", "Rect", "r", "=", "mStatusBar", ".", "getFrameLw", "(", ")", ";", "if", "(", "mStatusBarCanHide", ")", "{", "if", "(", "mDockTop", "==", "r", ".", "top", ")", "mDockTop", "=", "r", ".", "bottom", ";", "else", "if", "(", "mDockBottom", "==", "r", ".", "bottom", ")", "mDockBottom", "=", "r", ".", "top", ";", "mContentTop", "=", "mCurTop", "=", "mDockTop", ";", "mContentBottom", "=", "mCurBottom", "=", "mDockBottom", ";", "mContentLeft", "=", "mCurLeft", "=", "mDockLeft", ";", "mContentRight", "=", "mCurRight", "=", "mDockRight", ";", "if", "(", "DEBUG_LAYOUT", ")", "Log", ".", "v", "(", "TAG", ",", "\"Status", "bar:", "\"", "+", "String", ".", "format", "(", "\"\"", ",", "mDockLeft", ",", "mDockTop", ",", "mDockRight", ",", "mDockBottom", ",", "mContentLeft", ",", "mContentTop", ",", "mContentRight", ",", "mContentBottom", ",", "mCurLeft", ",", "mCurTop", ",", "mCurRight", ",", "mCurBottom", ")", ")", ";", "}", "else", "{", "if", "(", "mRestrictedScreenTop", "==", "r", ".", "top", ")", "{", "mRestrictedScreenTop", "=", "r", ".", "bottom", ";", "mRestrictedScreenHeight", "-=", "(", "r", ".", "bottom", "-", "r", ".", "top", ")", ";", "}", "else", "if", "(", "(", "mRestrictedScreenHeight", "-", "mRestrictedScreenTop", ")", "==", "r", ".", "bottom", ")", "{", "mRestrictedScreenHeight", "-=", "(", "r", ".", "bottom", "-", "r", ".", "top", ")", ";", "}", "mContentTop", "=", "mCurTop", "=", "mDockTop", "=", "mRestrictedScreenTop", ";", "mContentBottom", "=", "mCurBottom", "=", "mDockBottom", "=", "mRestrictedScreenTop", "+", "mRestrictedScreenHeight", ";", "if", "(", "DEBUG_LAYOUT", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", "+", "mRestrictedScreenLeft", "+", "\",\"", "+", "mRestrictedScreenTop", "+", "\",\"", "+", "(", "mRestrictedScreenLeft", "+", "mRestrictedScreenWidth", ")", "+", "\",\"", "+", "(", "mRestrictedScreenTop", "+", "mRestrictedScreenHeight", ")", "+", "\")\"", ")", ";", "}", "}", "}", "}", "void", "setAttachedWindowFrames", "(", "WindowState", "win", ",", "int", "fl", ",", "int", "adjust", ",", "WindowState", "attached", ",", "boolean", "insetDecors", ",", "Rect", "pf", ",", "Rect", "df", ",", "Rect", "cf", ",", "Rect", "vf", ")", "{", "if", "(", "win", ".", "getSurfaceLayer", "(", ")", ">", "mDockLayer", "&&", "attached", ".", "getSurfaceLayer", "(", ")", "<", "mDockLayer", ")", "{", "df", ".", "left", "=", "cf", ".", "left", "=", "vf", ".", "left", "=", "mDockLeft", ";", "df", ".", "top", "=", "cf", ".", "top", "=", "vf", ".", "top", "=", "mDockTop", ";", "df", ".", "right", "=", "cf", ".", "right", "=", "vf", ".", "right", "=", "mDockRight", ";", "df", ".", "bottom", "=", "cf", ".", "bottom", "=", "vf", ".", "bottom", "=", "mDockBottom", ";", "}", "else", "{", "if", "(", "adjust", "!=", "SOFT_INPUT_ADJUST_RESIZE", ")", "{", "cf", ".", "set", "(", "attached", ".", "getDisplayFrameLw", "(", ")", ")", ";", "}", "else", "{", "cf", ".", "set", "(", "attached", ".", "getContentFrameLw", "(", ")", ")", ";", "if", "(", "attached", ".", "getSurfaceLayer", "(", ")", "<", "mDockLayer", ")", "{", "if", "(", "cf", ".", "left", "<", "mContentLeft", ")", "cf", ".", "left", "=", "mContentLeft", ";", "if", "(", "cf", ".", "top", "<", "mContentTop", ")", "cf", ".", "top", "=", "mContentTop", ";", "if", "(", "cf", ".", "right", ">", "mContentRight", ")", "cf", ".", "right", "=", "mContentRight", ";", "if", "(", "cf", ".", "bottom", ">", "mContentBottom", ")", "cf", ".", "bottom", "=", "mContentBottom", ";", "}", "}", "df", ".", "set", "(", "insetDecors", "?", "attached", ".", "getDisplayFrameLw", "(", ")", ":", "cf", ")", ";", "vf", ".", "set", "(", "attached", ".", "getVisibleFrameLw", "(", ")", ")", ";", "}", "pf", ".", "set", "(", "(", "fl", "&", "FLAG_LAYOUT_IN_SCREEN", ")", "==", "0", "?", "attached", ".", "getFrameLw", "(", ")", ":", "df", ")", ";", "}", "public", "void", "layoutWindowLw", "(", "WindowState", "win", ",", "WindowManager", ".", "LayoutParams", "attrs", ",", "WindowState", "attached", ")", "{", "if", "(", "win", "==", "mStatusBar", "||", "win", "==", "mNavigationBar", ")", "{", "return", ";", "}", "final", "int", "fl", "=", "attrs", ".", "flags", ";", "final", "int", "sim", "=", "attrs", ".", "softInputMode", ";", "final", "Rect", "pf", "=", "mTmpParentFrame", ";", "final", "Rect", "df", "=", "mTmpDisplayFrame", ";", "final", "Rect", "cf", "=", "mTmpContentFrame", ";", "final", "Rect", "vf", "=", "mTmpVisibleFrame", ";", "final", "boolean", "hasNavBar", "=", "(", "mHasNavigationBar", "&&", "mNavigationBar", "!=", "null", "&&", "mNavigationBar", ".", "isVisibleLw", "(", ")", ")", ";", "if", "(", "attrs", ".", "type", "==", "TYPE_INPUT_METHOD", ")", "{", "pf", ".", "left", "=", "df", ".", "left", "=", "cf", ".", "left", "=", "vf", ".", "left", "=", "mDockLeft", ";", "pf", ".", "top", "=", "df", ".", "top", "=", "cf", ".", "top", "=", "vf", ".", "top", "=", "mDockTop", ";", "pf", ".", "right", "=", "df", ".", "right", "=", "cf", ".", "right", "=", "vf", ".", "right", "=", "mDockRight", ";", "pf", ".", "bottom", "=", "df", ".", "bottom", "=", "cf", ".", "bottom", "=", "vf", ".", "bottom", "=", "mDockBottom", ";", "attrs", ".", "gravity", "=", "Gravity", ".", "BOTTOM", ";", "mDockLayer", "=", "win", ".", "getSurfaceLayer", "(", ")", ";", "}", "else", "{", "final", "int", "adjust", "=", "sim", "&", "SOFT_INPUT_MASK_ADJUST", ";", "if", "(", "(", "fl", "&", "(", "FLAG_LAYOUT_IN_SCREEN", "|", "FLAG_FULLSCREEN", "|", "FLAG_LAYOUT_INSET_DECOR", ")", ")", "==", "(", "FLAG_LAYOUT_IN_SCREEN", "|", "FLAG_LAYOUT_INSET_DECOR", ")", ")", "{", "if", "(", "DEBUG_LAYOUT", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", "+", "attrs", ".", "getTitle", "(", ")", "+", "\"\"", ")", ";", "if", "(", "attached", "!=", "null", ")", "{", "setAttachedWindowFrames", "(", "win", ",", "fl", ",", "sim", ",", "attached", ",", "true", ",", "pf", ",", "df", ",", "cf", ",", "vf", ")", ";", "}", "else", "{", "if", "(", "attrs", ".", "type", "==", "TYPE_STATUS_BAR_PANEL", "||", "attrs", ".", "type", "==", "TYPE_STATUS_BAR_SUB_PANEL", ")", "{", "pf", ".", "left", "=", "df", ".", "left", "=", "hasNavBar", "?", "mDockLeft", ":", "mUnrestrictedScreenLeft", ";", "pf", ".", "top", "=", "df", ".", "top", "=", "mUnrestrictedScreenTop", ";", "pf", ".", "right", "=", "df", ".", "right", "=", "hasNavBar", "?", "mRestrictedScreenLeft", "+", "mRestrictedScreenWidth", ":", "mUnrestrictedScreenLeft", "+", "mUnrestrictedScreenWidth", ";", "pf", ".", "bottom", "=", "df", ".", "bottom", "=", "hasNavBar", "?", "mRestrictedScreenTop", "+", "mRestrictedScreenHeight", ":", "mUnrestrictedScreenTop", "+", "mUnrestrictedScreenHeight", ";", "if", "(", "DEBUG_LAYOUT", ")", "{", "Log", ".", "v", "(", "TAG", ",", "String", ".", "format", "(", "\"\"", ",", "pf", ".", "left", ",", "pf", ".", "top", ",", "pf", ".", "right", ",", "pf", ".", "bottom", ")", ")", ";", "}", "}", "else", "{", "pf", ".", "left", "=", "df", ".", "left", "=", "mRestrictedScreenLeft", ";", "pf", ".", "top", "=", "df", ".", "top", "=", "mRestrictedScreenTop", ";", "pf", ".", "right", "=", "df", ".", "right", "=", "mRestrictedScreenLeft", "+", "mRestrictedScreenWidth", ";", "pf", ".", "bottom", "=", "df", ".", "bottom", "=", "mRestrictedScreenTop", "+", "mRestrictedScreenHeight", ";", "}", "if", "(", "adjust", "!=", "SOFT_INPUT_ADJUST_RESIZE", ")", "{", "cf", ".", "left", "=", "mDockLeft", ";", "cf", ".", "top", "=", "mDockTop", ";", "cf", ".", "right", "=", "mDockRight", ";", "cf", ".", "bottom", "=", "mDockBottom", ";", "}", "else", "{", "cf", ".", "left", "=", "mContentLeft", ";", "cf", ".", "top", "=", "mContentTop", ";", "cf", ".", "right", "=", "mContentRight", ";", "cf", ".", "bottom", "=", "mContentBottom", ";", "}", "if", "(", "adjust", "!=", "SOFT_INPUT_ADJUST_NOTHING", ")", "{", "vf", ".", "left", "=", "mCurLeft", ";", "vf", ".", "top", "=", "mCurTop", ";", "vf", ".", "right", "=", "mCurRight", ";", "vf", ".", "bottom", "=", "mCurBottom", ";", "}", "else", "{", "vf", ".", "set", "(", "cf", ")", ";", "}", "}", "}", "else", "if", "(", "(", "fl", "&", "FLAG_LAYOUT_IN_SCREEN", ")", "!=", "0", ")", "{", "if", "(", "DEBUG_LAYOUT", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", "+", "attrs", ".", "getTitle", "(", ")", "+", "\"):", "IN_SCREEN\"", ")", ";", "if", "(", "attrs", ".", "type", "==", "TYPE_STATUS_BAR_PANEL", "||", "attrs", ".", "type", "==", "TYPE_STATUS_BAR_SUB_PANEL", ")", "{", "pf", ".", "left", "=", "df", ".", "left", "=", "cf", ".", "left", "=", "hasNavBar", "?", "mDockLeft", ":", "mUnrestrictedScreenLeft", ";", "pf", ".", "top", "=", "df", ".", "top", "=", "cf", ".", "top", "=", "mUnrestrictedScreenTop", ";", "pf", ".", "right", "=", "df", ".", "right", "=", "cf", ".", "right", "=", "hasNavBar", "?", "mRestrictedScreenLeft", "+", "mRestrictedScreenWidth", ":", "mUnrestrictedScreenLeft", "+", "mUnrestrictedScreenWidth", ";", "pf", ".", "bottom", "=", "df", ".", "bottom", "=", "cf", ".", "bottom", "=", "hasNavBar", "?", "mRestrictedScreenTop", "+", "mRestrictedScreenHeight", ":", "mUnrestrictedScreenTop", "+", "mUnrestrictedScreenHeight", ";", "if", "(", "DEBUG_LAYOUT", ")", "{", "Log", ".", "v", "(", "TAG", ",", "String", ".", "format", "(", "\"\"", ",", "pf", ".", "left", ",", "pf", ".", "top", ",", "pf", ".", "right", ",", "pf", ".", "bottom", ")", ")", ";", "}", "}", "else", "if", "(", "attrs", ".", "type", "==", "TYPE_NAVIGATION_BAR", ")", "{", "pf", ".", "left", "=", "df", ".", "left", "=", "mUnrestrictedScreenLeft", ";", "pf", ".", "top", "=", "df", ".", "top", "=", "mUnrestrictedScreenTop", ";", "pf", ".", "right", "=", "df", ".", "right", "=", "mUnrestrictedScreenLeft", "+", "mUnrestrictedScreenWidth", ";", "pf", ".", "bottom", "=", "df", ".", "bottom", "=", "mUnrestrictedScreenTop", "+", "mUnrestrictedScreenHeight", ";", "if", "(", "DEBUG_LAYOUT", ")", "{", "Log", ".", "v", "(", "TAG", ",", "String", ".", "format", "(", "\"\"", ",", "pf", ".", "left", ",", "pf", ".", "top", ",", "pf", ".", "right", ",", "pf", ".", "bottom", ")", ")", ";", "}", "}", "else", "if", "(", "(", "attrs", ".", "type", "==", "TYPE_SECURE_SYSTEM_OVERLAY", "||", "attrs", ".", "type", "==", "TYPE_BOOT_PROGRESS", ")", "&&", "(", "(", "fl", "&", "FLAG_FULLSCREEN", ")", "!=", "0", ")", ")", "{", "pf", ".", "left", "=", "df", ".", "left", "=", "mUnrestrictedScreenLeft", ";", "pf", ".", "top", "=", "df", ".", "top", "=", "mUnrestrictedScreenTop", ";", "pf", ".", "right", "=", "df", ".", "right", "=", "mUnrestrictedScreenLeft", "+", "mUnrestrictedScreenWidth", ";", "pf", ".", "bottom", "=", "df", ".", "bottom", "=", "mUnrestrictedScreenTop", "+", "mUnrestrictedScreenHeight", ";", "}", "else", "if", "(", "attrs", ".", "type", "==", "TYPE_BOOT_PROGRESS", ")", "{", "pf", ".", "left", "=", "df", ".", "left", "=", "cf", ".", "left", "=", "mUnrestrictedScreenLeft", ";", "pf", ".", "top", "=", "df", ".", "top", "=", "cf", ".", "top", "=", "mUnrestrictedScreenTop", ";", "pf", ".", "right", "=", "df", ".", "right", "=", "cf", ".", "right", "=", "mUnrestrictedScreenLeft", "+", "mUnrestrictedScreenWidth", ";", "pf", ".", "bottom", "=", "df", ".", "bottom", "=", "cf", ".", "bottom", "=", "mUnrestrictedScreenTop", "+", "mUnrestrictedScreenHeight", ";", "}", "else", "{", "pf", ".", "left", "=", "df", ".", "left", "=", "cf", ".", "left", "=", "mRestrictedScreenLeft", ";", "pf", ".", "top", "=", "df", ".", "top", "=", "cf", ".", "top", "=", "mRestrictedScreenTop", ";", "pf", ".", "right", "=", "df", ".", "right", "=", "cf", ".", "right", "=", "mRestrictedScreenLeft", "+", "mRestrictedScreenWidth", ";", "pf", ".", "bottom", "=", "df", ".", "bottom", "=", "cf", ".", "bottom", "=", "mRestrictedScreenTop", "+", "mRestrictedScreenHeight", ";", "}", "if", "(", "adjust", "!=", "SOFT_INPUT_ADJUST_NOTHING", ")", "{", "vf", ".", "left", "=", "mCurLeft", ";", "vf", ".", "top", "=", "mCurTop", ";", "vf", ".", "right", "=", "mCurRight", ";", "vf", ".", "bottom", "=", "mCurBottom", ";", "}", "else", "{", "vf", ".", "set", "(", "cf", ")", ";", "}", "}", "else", "if", "(", "attached", "!=", "null", ")", "{", "if", "(", "DEBUG_LAYOUT", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", "+", "attrs", ".", "getTitle", "(", ")", "+", "\"\"", "+", "attached", ")", ";", "setAttachedWindowFrames", "(", "win", ",", "fl", ",", "adjust", ",", "attached", ",", "false", ",", "pf", ",", "df", ",", "cf", ",", "vf", ")", ";", "}", "else", "{", "if", "(", "DEBUG_LAYOUT", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", "+", "attrs", ".", "getTitle", "(", ")", "+", "\"\"", ")", ";", "if", "(", "attrs", ".", "type", "==", "TYPE_STATUS_BAR_PANEL", ")", "{", "pf", ".", "left", "=", "df", ".", "left", "=", "cf", ".", "left", "=", "mRestrictedScreenLeft", ";", "pf", ".", "top", "=", "df", ".", "top", "=", "cf", ".", "top", "=", "mRestrictedScreenTop", ";", "pf", ".", "right", "=", "df", ".", "right", "=", "cf", ".", "right", "=", "mRestrictedScreenLeft", "+", "mRestrictedScreenWidth", ";", "pf", ".", "bottom", "=", "df", ".", "bottom", "=", "cf", ".", "bottom", "=", "mRestrictedScreenTop", "+", "mRestrictedScreenHeight", ";", "}", "else", "{", "pf", ".", "left", "=", "mContentLeft", ";", "pf", ".", "top", "=", "mContentTop", ";", "pf", ".", "right", "=", "mContentRight", ";", "pf", ".", "bottom", "=", "mContentBottom", ";", "if", "(", "adjust", "!=", "SOFT_INPUT_ADJUST_RESIZE", ")", "{", "df", ".", "left", "=", "cf", ".", "left", "=", "mDockLeft", ";", "df", ".", "top", "=", "cf", ".", "top", "=", "mDockTop", ";", "df", ".", "right", "=", "cf", ".", "right", "=", "mDockRight", ";", "df", ".", "bottom", "=", "cf", ".", "bottom", "=", "mDockBottom", ";", "}", "else", "{", "df", ".", "left", "=", "cf", ".", "left", "=", "mContentLeft", ";", "df", ".", "top", "=", "cf", ".", "top", "=", "mContentTop", ";", "df", ".", "right", "=", "cf", ".", "right", "=", "mContentRight", ";", "df", ".", "bottom", "=", "cf", ".", "bottom", "=", "mContentBottom", ";", "}", "if", "(", "adjust", "!=", "SOFT_INPUT_ADJUST_NOTHING", ")", "{", "vf", ".", "left", "=", "mCurLeft", ";", "vf", ".", "top", "=", "mCurTop", ";", "vf", ".", "right", "=", "mCurRight", ";", "vf", ".", "bottom", "=", "mCurBottom", ";", "}", "else", "{", "vf", ".", "set", "(", "cf", ")", ";", "}", "}", "}", "}", "if", "(", "(", "fl", "&", "FLAG_LAYOUT_NO_LIMITS", ")", "!=", "0", ")", "{", "df", ".", "left", "=", "df", ".", "top", "=", "cf", ".", "left", "=", "cf", ".", "top", "=", "vf", ".", "left", "=", "vf", ".", "top", "=", "-", "10000", ";", "df", ".", "right", "=", "df", ".", "bottom", "=", "cf", ".", "right", "=", "cf", ".", "bottom", "=", "vf", ".", "right", "=", "vf", ".", "bottom", "=", "10000", ";", "}", "if", "(", "DEBUG_LAYOUT", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", "+", "attrs", ".", "getTitle", "(", ")", "+", "\":", "sim=#\"", "+", "Integer", ".", "toHexString", "(", "sim", ")", "+", "\"", "attach=\"", "+", "attached", "+", "\"", "type=\"", "+", "attrs", ".", "type", "+", "String", ".", "format", "(", "\"\"", ",", "fl", ")", "+", "\"", "pf=\"", "+", "pf", ".", "toShortString", "(", ")", "+", "\"", "df=\"", "+", "df", ".", "toShortString", "(", ")", "+", "\"", "cf=\"", "+", "cf", ".", "toShortString", "(", ")", "+", "\"", "vf=\"", "+", "vf", ".", "toShortString", "(", ")", ")", ";", "win", ".", "computeFrameLw", "(", "pf", ",", "df", ",", "cf", ",", "vf", ")", ";", "if", "(", "attrs", ".", "type", "==", "TYPE_INPUT_METHOD", "&&", "!", "win", ".", "getGivenInsetsPendingLw", "(", ")", ")", "{", "int", "top", "=", "win", ".", "getContentFrameLw", "(", ")", ".", "top", ";", "top", "+=", "win", ".", "getGivenContentInsetsLw", "(", ")", ".", "top", ";", "if", "(", "mContentBottom", ">", "top", ")", "{", "mContentBottom", "=", "top", ";", "}", "top", "=", "win", ".", "getVisibleFrameLw", "(", ")", ".", "top", ";", "top", "+=", "win", ".", "getGivenVisibleInsetsLw", "(", ")", ".", "top", ";", "if", "(", "mCurBottom", ">", "top", ")", "{", "mCurBottom", "=", "top", ";", "}", "if", "(", "DEBUG_LAYOUT", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", "+", "mDockBottom", "+", "\"\"", "+", "mContentBottom", "+", "\"", "mCurBottom=\"", "+", "mCurBottom", ")", ";", "}", "}", "public", "int", "finishLayoutLw", "(", ")", "{", "return", "0", ";", "}", "public", "void", "beginAnimationLw", "(", "int", "displayWidth", ",", "int", "displayHeight", ")", "{", "mTopFullscreenOpaqueWindowState", "=", "null", ";", "mForceStatusBar", "=", "false", ";", "mHideLockScreen", "=", "false", ";", "mAllowLockscreenWhenOn", "=", "false", ";", "mDismissKeyguard", "=", "false", ";", "}", "public", "void", "animatingWindowLw", "(", "WindowState", "win", ",", "WindowManager", ".", "LayoutParams", "attrs", ")", "{", "if", "(", "DEBUG_LAYOUT", ")", "Slog", ".", "i", "(", "TAG", ",", "\"Win", "\"", "+", "win", "+", "\"\"", "+", "win", ".", "isVisibleOrBehindKeyguardLw", "(", ")", ")", ";", "if", "(", "mTopFullscreenOpaqueWindowState", "==", "null", "&&", "win", ".", "isVisibleOrBehindKeyguardLw", "(", ")", "&&", "!", "win", ".", "isGoneForLayoutLw", "(", ")", ")", "{", "if", "(", "(", "attrs", ".", "flags", "&", "FLAG_FORCE_NOT_FULLSCREEN", ")", "!=", "0", ")", "{", "mForceStatusBar", "=", "true", ";", "}", "if", "(", "attrs", ".", "type", ">=", "FIRST_APPLICATION_WINDOW", "&&", "attrs", ".", "type", "<=", "LAST_APPLICATION_WINDOW", "&&", "attrs", ".", "x", "==", "0", "&&", "attrs", ".", "y", "==", "0", "&&", "attrs", ".", "width", "==", "WindowManager", ".", "LayoutParams", ".", "MATCH_PARENT", "&&", "attrs", ".", "height", "==", "WindowManager", ".", "LayoutParams", ".", "MATCH_PARENT", ")", "{", "if", "(", "DEBUG_LAYOUT", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", "+", "win", ")", ";", "mTopFullscreenOpaqueWindowState", "=", "win", ";", "if", "(", "(", "attrs", ".", "flags", "&", "FLAG_SHOW_WHEN_LOCKED", ")", "!=", "0", ")", "{", "if", "(", "localLOGV", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", "+", "win", ")", ";", "mHideLockScreen", "=", "true", ";", "}", "if", "(", "(", "attrs", ".", "flags", "&", "FLAG_DISMISS_KEYGUARD", ")", "!=", "0", ")", "{", "if", "(", "localLOGV", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", "+", "win", ")", ";", "mDismissKeyguard", "=", "true", ";", "}", "if", "(", "(", "attrs", ".", "flags", "&", "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON", ")", "!=", "0", ")", "{", "mAllowLockscreenWhenOn", "=", "true", ";", "}", "}", "}", "}", "public", "int", "finishAnimationLw", "(", ")", "{", "int", "changes", "=", "0", ";", "boolean", "topIsFullscreen", "=", "false", ";", "final", "WindowManager", ".", "LayoutParams", "lp", "=", "(", "mTopFullscreenOpaqueWindowState", "!=", "null", ")", "?", "mTopFullscreenOpaqueWindowState", ".", "getAttrs", "(", ")", ":", "null", ";", "if", "(", "mStatusBar", "!=", "null", ")", "{", "if", "(", "DEBUG_LAYOUT", ")", "Log", ".", "i", "(", "TAG", ",", "\"force=\"", "+", "mForceStatusBar", "+", "\"", "top=\"", "+", "mTopFullscreenOpaqueWindowState", ")", ";", "if", "(", "mForceStatusBar", ")", "{", "if", "(", "DEBUG_LAYOUT", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "if", "(", "mStatusBar", ".", "showLw", "(", "true", ")", ")", "changes", "|=", "FINISH_LAYOUT_REDO_LAYOUT", ";", "}", "else", "if", "(", "mTopFullscreenOpaqueWindowState", "!=", "null", ")", "{", "if", "(", "localLOGV", ")", "{", "Log", ".", "d", "(", "TAG", ",", "\"frame:", "\"", "+", "mTopFullscreenOpaqueWindowState", ".", "getFrameLw", "(", ")", "+", "\"\"", "+", "mTopFullscreenOpaqueWindowState", ".", "getShownFrameLw", "(", ")", ")", ";", "Log", ".", "d", "(", "TAG", ",", "\"attr:", "\"", "+", "mTopFullscreenOpaqueWindowState", ".", "getAttrs", "(", ")", "+", "\"", "lp.flags=0x\"", "+", "Integer", ".", "toHexString", "(", "lp", ".", "flags", ")", ")", ";", "}", "topIsFullscreen", "=", "(", "lp", ".", "flags", "&", "WindowManager", ".", "LayoutParams", ".", "FLAG_FULLSCREEN", ")", "!=", "0", ";", "if", "(", "topIsFullscreen", ")", "{", "if", "(", "mStatusBarCanHide", "||", "(", "(", "(", "mFocusedWindow", "!=", "null", ")", "&&", "(", "mFocusedWindow", ".", "getSystemUiVisibility", "(", ")", "&", "View", ".", "SYSTEM_UI_FLAG_LOW_PROFILE", ")", "==", "1", ")", "&&", "(", "Settings", ".", "System", ".", "getInt", "(", "mContext", ".", "getContentResolver", "(", ")", ",", "Settings", ".", "System", ".", "COMBINED_BAR_AUTO_HIDE", ",", "0", ")", "==", "1", ")", ")", ")", "{", "if", "(", "DEBUG_LAYOUT", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "if", "(", "mStatusBar", ".", "hideLw", "(", "true", ")", ")", "{", "changes", "|=", "FINISH_LAYOUT_REDO_LAYOUT", ";", "mHandler", ".", "post", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "if", "(", "mStatusBarService", "!=", "null", ")", "{", "try", "{", "mStatusBarService", ".", "collapse", "(", ")", ";", "}", "catch", "(", "RemoteException", "ex", ")", "{", "}", "}", "}", "}", ")", ";", "}", "}", "else", "if", "(", "(", "(", "mFocusedWindow", "!=", "null", ")", "&&", "(", "mFocusedWindow", ".", "getSystemUiVisibility", "(", ")", "&", "View", ".", "SYSTEM_UI_FLAG_LOW_PROFILE", ")", "==", "0", ")", "&&", "(", "Settings", ".", "System", ".", "getInt", "(", "mContext", ".", "getContentResolver", "(", ")", ",", "Settings", ".", "System", ".", "COMBINED_BAR_AUTO_HIDE", ",", "0", ")", "==", "1", ")", ")", "{", "if", "(", "mStatusBar", ".", "showLw", "(", "true", ")", ")", "changes", "|=", "FINISH_LAYOUT_REDO_LAYOUT", ";", "}", "else", "if", "(", "DEBUG_LAYOUT", ")", "{", "Log", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "}", "}", "else", "{", "if", "(", "DEBUG_LAYOUT", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "if", "(", "mStatusBar", ".", "showLw", "(", "true", ")", ")", "changes", "|=", "FINISH_LAYOUT_REDO_LAYOUT", ";", "}", "}", "}", "mTopIsFullscreen", "=", "topIsFullscreen", ";", "if", "(", "mKeyguard", "!=", "null", ")", "{", "if", "(", "localLOGV", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", "+", "mHideLockScreen", ")", ";", "if", "(", "mDismissKeyguard", "&&", "!", "mKeyguardMediator", ".", "isSecure", "(", ")", ")", "{", "if", "(", "mKeyguard", ".", "hideLw", "(", "true", ")", ")", "{", "changes", "|=", "FINISH_LAYOUT_REDO_LAYOUT", "|", "FINISH_LAYOUT_REDO_CONFIG", "|", "FINISH_LAYOUT_REDO_WALLPAPER", ";", "}", "if", "(", "mKeyguardMediator", ".", "isShowing", "(", ")", ")", "{", "mHandler", ".", "post", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "mKeyguardMediator", ".", "keyguardDone", "(", "false", ",", "false", ")", ";", "}", "}", ")", ";", "}", "}", "else", "if", "(", "mHideLockScreen", ")", "{", "if", "(", "mKeyguard", ".", "hideLw", "(", "true", ")", ")", "{", "changes", "|=", "FINISH_LAYOUT_REDO_LAYOUT", "|", "FINISH_LAYOUT_REDO_CONFIG", "|", "FINISH_LAYOUT_REDO_WALLPAPER", ";", "}", "mKeyguardMediator", ".", "setHidden", "(", "true", ")", ";", "}", "else", "{", "if", "(", "mKeyguard", ".", "showLw", "(", "true", ")", ")", "{", "changes", "|=", "FINISH_LAYOUT_REDO_LAYOUT", "|", "FINISH_LAYOUT_REDO_CONFIG", "|", "FINISH_LAYOUT_REDO_WALLPAPER", ";", "}", "mKeyguardMediator", ".", "setHidden", "(", "false", ")", ";", "}", "}", "if", "(", "(", "updateSystemUiVisibilityLw", "(", ")", "&", "View", ".", "SYSTEM_UI_FLAG_HIDE_NAVIGATION", ")", "!=", "0", ")", "{", "changes", "|=", "FINISH_LAYOUT_REDO_LAYOUT", ";", "}", "updateLockScreenTimeout", "(", ")", ";", "return", "changes", ";", "}", "public", "boolean", "allowAppAnimationsLw", "(", ")", "{", "if", "(", "mKeyguard", "!=", "null", "&&", "mKeyguard", ".", "isVisibleLw", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "false", ")", "{", "if", "(", "mStatusBar", "!=", "null", "&&", "mStatusBar", ".", "isVisibleLw", "(", ")", ")", "{", "RectF", "rect", "=", "new", "RectF", "(", "mStatusBar", ".", "getShownFrameLw", "(", ")", ")", ";", "for", "(", "int", "i", "=", "mStatusBarPanels", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WindowState", "w", "=", "mStatusBarPanels", ".", "get", "(", "i", ")", ";", "if", "(", "w", ".", "isVisibleLw", "(", ")", ")", "{", "rect", ".", "union", "(", "w", ".", "getShownFrameLw", "(", ")", ")", ";", "}", "}", "final", "int", "insetw", "=", "mRestrictedScreenWidth", "/", "10", ";", "final", "int", "inseth", "=", "mRestrictedScreenHeight", "/", "10", ";", "if", "(", "rect", ".", "contains", "(", "insetw", ",", "inseth", ",", "mRestrictedScreenWidth", "-", "insetw", ",", "mRestrictedScreenHeight", "-", "inseth", ")", ")", "{", "return", "false", ";", "}", "}", "}", "return", "true", ";", "}", "public", "int", "focusChangedLw", "(", "WindowState", "lastFocus", ",", "WindowState", "newFocus", ")", "{", "mFocusedWindow", "=", "newFocus", ";", "if", "(", "(", "updateSystemUiVisibilityLw", "(", ")", "&", "View", ".", "SYSTEM_UI_FLAG_HIDE_NAVIGATION", ")", "!=", "0", ")", "{", "return", "FINISH_LAYOUT_REDO_LAYOUT", ";", "}", "return", "0", ";", "}", "public", "void", "notifyLidSwitchChanged", "(", "long", "whenNanos", ",", "boolean", "lidOpen", ")", "{", "mLidOpen", "=", "lidOpen", "?", "LID_OPEN", ":", "LID_CLOSED", ";", "updateKeyboardVisibility", "(", ")", ";", "boolean", "awakeNow", "=", "mKeyguardMediator", ".", "doLidChangeTq", "(", "lidOpen", ")", ";", "updateRotation", "(", "true", ")", ";", "if", "(", "awakeNow", ")", "{", "mKeyguardMediator", ".", "pokeWakelock", "(", ")", ";", "}", "else", "if", "(", "keyguardIsShowingTq", "(", ")", ")", "{", "if", "(", "lidOpen", ")", "{", "mKeyguardMediator", ".", "onWakeKeyWhenKeyguardShowingTq", "(", "KeyEvent", ".", "KEYCODE_POWER", ",", "mDockMode", "!=", "Intent", ".", "EXTRA_DOCK_STATE_UNDOCKED", ")", ";", "}", "}", "else", "{", "if", "(", "lidOpen", ")", "{", "mPowerManager", ".", "userActivity", "(", "SystemClock", ".", "uptimeMillis", "(", ")", ",", "false", ",", "LocalPowerManager", ".", "BUTTON_EVENT", ")", ";", "}", "else", "{", "mPowerManager", ".", "userActivity", "(", "SystemClock", ".", "uptimeMillis", "(", ")", ",", "false", ",", "LocalPowerManager", ".", "OTHER_EVENT", ")", ";", "}", "}", "}", "void", "setHdmiPlugged", "(", "boolean", "plugged", ")", "{", "if", "(", "mHdmiPlugged", "!=", "plugged", ")", "{", "mHdmiPlugged", "=", "plugged", ";", "updateRotation", "(", "true", ")", ";", "Intent", "intent", "=", "new", "Intent", "(", "ACTION_HDMI_PLUGGED", ")", ";", "intent", ".", "addFlags", "(", "Intent", ".", "FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT", ")", ";", "intent", ".", "putExtra", "(", "EXTRA_HDMI_PLUGGED_STATE", ",", "plugged", ")", ";", "mContext", ".", "sendStickyBroadcast", "(", "intent", ")", ";", "}", "}", "void", "initializeHdmiState", "(", ")", "{", "boolean", "plugged", "=", "false", ";", "if", "(", "new", "File", "(", "\"\"", ")", ".", "exists", "(", ")", ")", "{", "mHDMIObserver", ".", "startObserving", "(", "\"\"", ")", ";", "final", "String", "filename", "=", "\"\"", ";", "FileReader", "reader", "=", "null", ";", "try", "{", "reader", "=", "new", "FileReader", "(", "filename", ")", ";", "char", "[", "]", "buf", "=", "new", "char", "[", "15", "]", ";", "int", "n", "=", "reader", ".", "read", "(", "buf", ")", ";", "if", "(", "n", ">", "1", ")", "{", "plugged", "=", "0", "!=", "Integer", ".", "parseInt", "(", "new", "String", "(", "buf", ",", "0", ",", "n", "-", "1", ")", ")", ";", "}", "}", "catch", "(", "IOException", "ex", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "filename", "+", "\":", "\"", "+", "ex", ")", ";", "}", "catch", "(", "NumberFormatException", "ex", ")", "{", "Slog", ".", "w", "(", "TAG", ",", "\"\"", "+", "filename", "+", "\":", "\"", "+", "ex", ")", ";", "}", "finally", "{", "if", "(", "reader", "!=", "null", ")", "{", "try", "{", "reader", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "}", "}", "}", "}", "mHdmiPlugged", "=", "!", "plugged", ";", "setHdmiPlugged", "(", "!", "mHdmiPlugged", ")", ";", "}", "boolean", "isMusicActive", "(", ")", "{", "final", "AudioManager", "am", "=", "(", "AudioManager", ")", "mContext", ".", "getSystemService", "(", "Context", ".", "AUDIO_SERVICE", ")", ";", "if", "(", "am", "==", "null", ")", "{", "Log", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "return", "false", ";", "}", "return", "am", ".", "isMusicActive", "(", ")", ";", "}", "void", "handleVolumeKey", "(", "int", "stream", ",", "int", "keycode", ")", "{", "IAudioService", "audioService", "=", "getAudioService", "(", ")", ";", "if", "(", "audioService", "==", "null", ")", "{", "return", ";", "}", "try", "{", "if", "(", "keycode", "==", "KeyEvent", ".", "KEYCODE_VOLUME_MUTE", ")", "{", "final", "AudioManager", "am", "=", "(", "AudioManager", ")", "mContext", ".", "getSystemService", "(", "Context", ".", "AUDIO_SERVICE", ")", ";", "if", "(", "am", "==", "null", ")", "{", "Log", ".", "w", "(", "TAG", ",", "\"\"", ")", ";", "}", "else", "{", "am", ".", "toggleMute", "(", "stream", ")", ";", "}", "}", "else", "{", "mBroadcastWakeLock", ".", "acquire", "(", ")", ";", "audioService", ".", "adjustStreamVolume", "(", "stream", ",", "keycode", "==", "KeyEvent", ".", "KEYCODE_VOLUME_UP", "?", "AudioManager", ".", "ADJUST_RAISE", ":", "AudioManager", ".", "ADJUST_LOWER", ",", "0", ")", ";", "}", "}", "catch", "(", "RemoteException", "e", ")", "{", "Log", ".", "w", "(", "TAG", ",", "\"\"", "+", "e", ")", ";", "}", "finally", "{", "mBroadcastWakeLock", ".", "release", "(", ")", ";", "}", "}", "final", "Object", "mScreenshotLock", "=", "new", "Object", "(", ")", ";", "ServiceConnection", "mScreenshotConnection", "=", "null", ";", "final", "Runnable", "mScreenshotTimeout", "=", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "synchronized", "(", "mScreenshotLock", ")", "{", "if", "(", "mScreenshotConnection", "!=", "null", ")", "{", "mContext", ".", "unbindService", "(", "mScreenshotConnection", ")", ";", "mScreenshotConnection", "=", "null", ";", "}", "}", "}", "}", ";", "private", "void", "takeScreenshot", "(", ")", "{", "synchronized", "(", "mScreenshotLock", ")", "{", "if", "(", "mScreenshotConnection", "!=", "null", ")", "{", "return", ";", "}", "ComponentName", "cn", "=", "new", "ComponentName", "(", "\"\"", ",", "\"\"", ")", ";", "Intent", "intent", "=", "new", "Intent", "(", ")", ";", "intent", ".", "setComponent", "(", "cn", ")", ";", "ServiceConnection", "conn", "=", "new", "ServiceConnection", "(", ")", "{", "@", "Override", "public", "void", "onServiceConnected", "(", "ComponentName", "name", ",", "IBinder", "service", ")", "{", "synchronized", "(", "mScreenshotLock", ")", "{", "if", "(", "mScreenshotConnection", "!=", "this", ")", "{", "return", ";", "}", "Messenger", "messenger", "=", "new", "Messenger", "(", "service", ")", ";", "Message", "msg", "=", "Message", ".", "obtain", "(", "null", ",", "1", ")", ";", "final", "ServiceConnection", "myConn", "=", "this", ";", "Handler", "h", "=", "new", "Handler", "(", "mHandler", ".", "getLooper", "(", ")", ")", "{", "@", "Override", "public", "void", "handleMessage", "(", "Message", "msg", ")", "{", "synchronized", "(", "mScreenshotLock", ")", "{", "if", "(", "mScreenshotConnection", "==", "myConn", ")", "{", "mContext", ".", "unbindService", "(", "mScreenshotConnection", ")", ";", "mScreenshotConnection", "=", "null", ";", "mHandler", ".", "removeCallbacks", "(", "mScreenshotTimeout", ")", ";", "}", "}", "}", "}", ";", "msg", ".", "replyTo", "=", "new", "Messenger", "(", "h", ")", ";", "msg", ".", "arg1", "=", "msg", ".", "arg2", "=", "0", ";", "if", "(", "mStatusBar", "!=", "null", "&&", "mStatusBar", ".", "isVisibleLw", "(", ")", ")", "msg", ".", "arg1", "=", "1", ";", "if", "(", "mNavigationBar", "!=", "null", "&&", "mNavigationBar", ".", "isVisibleLw", "(", ")", ")", "msg", ".", "arg2", "=", "1", ";", "try", "{", "messenger", ".", "send", "(", "msg", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "}", "@", "Override", "public", "void", "onServiceDisconnected", "(", "ComponentName", "name", ")", "{", "}", "}", ";", "if", "(", "mContext", ".", "bindService", "(", "intent", ",", "conn", ",", "Context", ".", "BIND_AUTO_CREATE", ")", ")", "{", "mScreenshotConnection", "=", "conn", ";", "mHandler", ".", "postDelayed", "(", "mScreenshotTimeout", ",", "10000", ")", ";", "}", "}", "}", "@", "Override", "public", "int", "interceptKeyBeforeQueueing", "(", "KeyEvent", "event", ",", "int", "policyFlags", ",", "boolean", "isScreenOn", ")", "{", "final", "boolean", "down", "=", "event", ".", "getAction", "(", ")", "==", "KeyEvent", ".", "ACTION_DOWN", ";", "final", "boolean", "canceled", "=", "event", ".", "isCanceled", "(", ")", ";", "int", "keyCode", "=", "event", ".", "getKeyCode", "(", ")", ";", "final", "boolean", "isInjected", "=", "(", "policyFlags", "&", "WindowManagerPolicy", ".", "FLAG_INJECTED", ")", "!=", "0", ";", "final", "boolean", "keyguardActive", "=", "(", "isScreenOn", "?", "mKeyguardMediator", ".", "isShowingAndNotHidden", "(", ")", ":", "mKeyguardMediator", ".", "isShowing", "(", ")", ")", ";", "if", "(", "!", "mSystemBooted", ")", "{", "return", "0", ";", "}", "if", "(", "false", ")", "{", "Log", ".", "d", "(", "TAG", ",", "\"\"", "+", "keyCode", "+", "\"", "screenIsOn=\"", "+", "isScreenOn", "+", "\"\"", "+", "keyguardActive", ")", ";", "}", "if", "(", "down", "&&", "(", "policyFlags", "&", "WindowManagerPolicy", ".", "FLAG_VIRTUAL", ")", "!=", "0", "&&", "event", ".", "getRepeatCount", "(", ")", "==", "0", ")", "{", "performHapticFeedbackLw", "(", "null", ",", "HapticFeedbackConstants", ".", "VIRTUAL_KEY", ",", "false", ")", ";", "}", "int", "result", ";", "if", "(", "isScreenOn", "||", "isInjected", ")", "{", "result", "=", "ACTION_PASS_TO_USER", ";", "}", "else", "{", "result", "=", "0", ";", "final", "boolean", "isWakeKey", "=", "(", "policyFlags", "&", "(", "WindowManagerPolicy", ".", "FLAG_WAKE", "|", "WindowManagerPolicy", ".", "FLAG_WAKE_DROPPED", ")", ")", "!=", "0", ";", "if", "(", "down", "&&", "isWakeKey", ")", "{", "if", "(", "keyguardActive", ")", "{", "mKeyguardMediator", ".", "onWakeKeyWhenKeyguardShowingTq", "(", "keyCode", ",", "mDockMode", "!=", "Intent", ".", "EXTRA_DOCK_STATE_UNDOCKED", ")", ";", "}", "else", "if", "(", "(", "keyCode", "!=", "KeyEvent", ".", "KEYCODE_VOLUME_UP", ")", "&&", "(", "keyCode", "!=", "KeyEvent", ".", "KEYCODE_VOLUME_DOWN", ")", ")", "{", "result", "|=", "ACTION_POKE_USER_ACTIVITY", ";", "}", "}", "}", "switch", "(", "keyCode", ")", "{", "case", "KeyEvent", ".", "KEYCODE_ENDCALL", ":", "{", "result", "&=", "~", "ACTION_PASS_TO_USER", ";", "if", "(", "down", ")", "{", "ITelephony", "telephonyService", "=", "getTelephonyService", "(", ")", ";", "boolean", "hungUp", "=", "false", ";", "if", "(", "telephonyService", "!=", "null", ")", "{", "try", "{", "hungUp", "=", "telephonyService", ".", "endCall", "(", ")", ";", "}", "catch", "(", "RemoteException", "ex", ")", "{", "Log", ".", "w", "(", "TAG", ",", "\"\"", ",", "ex", ")", ";", "}", "}", "interceptPowerKeyDown", "(", "!", "isScreenOn", "||", "hungUp", ")", ";", "}", "else", "{", "if", "(", "interceptPowerKeyUp", "(", "canceled", ")", ")", "{", "if", "(", "(", "mEndcallBehavior", "&", "Settings", ".", "System", ".", "END_BUTTON_BEHAVIOR_HOME", ")", "!=", "0", ")", "{", "if", "(", "goHome", "(", ")", ")", "{", "break", ";", "}", "}", "if", "(", "(", "mEndcallBehavior", "&", "Settings", ".", "System", ".", "END_BUTTON_BEHAVIOR_SLEEP", ")", "!=", "0", ")", "{", "result", "=", "(", "result", "&", "~", "ACTION_POKE_USER_ACTIVITY", ")", "|", "ACTION_GO_TO_SLEEP", ";", "}", "}", "}", "break", ";", "}", "case", "KeyEvent", ".", "KEYCODE_VOLUME_DOWN", ":", "case", "KeyEvent", ".", "KEYCODE_VOLUME_UP", ":", "case", "KeyEvent", ".", "KEYCODE_VOLUME_MUTE", ":", "{", "if", "(", "keyCode", "==", "KeyEvent", ".", "KEYCODE_VOLUME_DOWN", ")", "{", "if", "(", "down", ")", "{", "if", "(", "isScreenOn", "&&", "!", "mVolumeDownKeyTriggered", "&&", "(", "event", ".", "getFlags", "(", ")", "&", "KeyEvent", ".", "FLAG_FALLBACK", ")", "==", "0", ")", "{", "mVolumeDownKeyTriggered", "=", "true", ";", "mVolumeDownKeyTime", "=", "event", ".", "getDownTime", "(", ")", ";", "mVolumeDownKeyConsumedByChord", "=", "false", ";", "cancelPendingPowerKeyAction", "(", ")", ";", "interceptScreenshotChord", "(", ")", ";", "interceptRingerChord", "(", ")", ";", "}", "}", "else", "{", "mVolumeDownKeyTriggered", "=", "false", ";", "cancelPendingScreenshotChordAction", "(", ")", ";", "cancelPendingRingerChordAction", "(", ")", ";", "}", "}", "else", "if", "(", "keyCode", "==", "KeyEvent", ".", "KEYCODE_VOLUME_UP", ")", "{", "if", "(", "down", ")", "{", "if", "(", "isScreenOn", "&&", "!", "mVolumeUpKeyTriggered", "&&", "(", "event", ".", "getFlags", "(", ")", "&", "KeyEvent", ".", "FLAG_FALLBACK", ")", "==", "0", ")", "{", "mVolumeUpKeyTriggered", "=", "true", ";", "mVolumeUpKeyTime", "=", "event", ".", "getDownTime", "(", ")", ";", "mVolumeUpKeyConsumedByChord", "=", "false", ";", "cancelPendingPowerKeyAction", "(", ")", ";", "cancelPendingScreenshotChordAction", "(", ")", ";", "interceptRingerChord", "(", ")", ";", "}", "}", "else", "{", "mVolumeUpKeyTriggered", "=", "false", ";", "cancelPendingScreenshotChordAction", "(", ")", ";", "cancelPendingRingerChordAction", "(", ")", ";", "}", "}", "if", "(", "down", ")", "{", "ITelephony", "telephonyService", "=", "getTelephonyService", "(", ")", ";", "if", "(", "telephonyService", "!=", "null", ")", "{", "try", "{", "if", "(", "telephonyService", ".", "isRinging", "(", ")", ")", "{", "Log", ".", "i", "(", "TAG", ",", "\"\"", "+", "\"\"", ")", ";", "telephonyService", ".", "silenceRinger", "(", ")", ";", "result", "&=", "~", "ACTION_PASS_TO_USER", ";", "break", ";", "}", "if", "(", "telephonyService", ".", "isOffhook", "(", ")", "&&", "(", "result", "&", "ACTION_PASS_TO_USER", ")", "==", "0", ")", "{", "handleVolumeKey", "(", "AudioManager", ".", "STREAM_VOICE_CALL", ",", "keyCode", ")", ";", "break", ";", "}", "}", "catch", "(", "RemoteException", "ex", ")", "{", "Log", ".", "w", "(", "TAG", ",", "\"\"", ",", "ex", ")", ";", "}", "}", "}", "if", "(", "isMusicActive", "(", ")", "&&", "(", "result", "&", "ACTION_PASS_TO_USER", ")", "==", "0", ")", "{", "if", "(", "mVolBtnMusicControls", "&&", "down", "&&", "(", "keyCode", "!=", "KeyEvent", ".", "KEYCODE_VOLUME_MUTE", ")", ")", "{", "mIsLongPress", "=", "false", ";", "handleVolumeLongPress", "(", "keyCode", ")", ";", "break", ";", "}", "else", "{", "if", "(", "mVolBtnMusicControls", "&&", "!", "down", ")", "{", "handleVolumeLongPressAbort", "(", ")", ";", "if", "(", "mIsLongPress", ")", "{", "break", ";", "}", "}", "if", "(", "!", "isScreenOn", "&&", "!", "mVolumeWakeScreen", ")", "{", "handleVolumeKey", "(", "AudioManager", ".", "STREAM_MUSIC", ",", "keyCode", ")", ";", "}", "}", "}", "if", "(", "isScreenOn", "||", "!", "mVolumeWakeScreen", ")", "{", "break", ";", "}", "else", "if", "(", "keyguardActive", ")", "{", "keyCode", "=", "KeyEvent", ".", "KEYCODE_POWER", ";", "mKeyguardMediator", ".", "onWakeKeyWhenKeyguardShowingTq", "(", "keyCode", ",", "mDockMode", "!=", "Intent", ".", "EXTRA_DOCK_STATE_UNDOCKED", ")", ";", "}", "else", "{", "result", "|=", "ACTION_POKE_USER_ACTIVITY", ";", "break", ";", "}", "}", "case", "KeyEvent", ".", "KEYCODE_POWER", ":", "{", "if", "(", "(", "mTopFullscreenOpaqueWindowState", ".", "getAttrs", "(", ")", ".", "flags", "&", "WindowManager", ".", "LayoutParams", ".", "PREVENT_POWER_KEY", ")", "!=", "0", ")", "{", "return", "result", ";", "}", "result", "&=", "~", "ACTION_PASS_TO_USER", ";", "if", "(", "down", ")", "{", "if", "(", "isScreenOn", "&&", "!", "mPowerKeyTriggered", "&&", "(", "event", ".", "getFlags", "(", ")", "&", "KeyEvent", ".", "FLAG_FALLBACK", ")", "==", "0", ")", "{", "mPowerKeyTriggered", "=", "true", ";", "mPowerKeyTime", "=", "event", ".", "getDownTime", "(", ")", ";", "cancelPendingRingerChordAction", "(", ")", ";", "interceptScreenshotChord", "(", ")", ";", "}", "ITelephony", "telephonyService", "=", "getTelephonyService", "(", ")", ";", "boolean", "hungUp", "=", "false", ";", "if", "(", "telephonyService", "!=", "null", ")", "{", "try", "{", "if", "(", "telephonyService", ".", "isRinging", "(", ")", ")", "{", "telephonyService", ".", "silenceRinger", "(", ")", ";", "}", "else", "if", "(", "(", "mIncallPowerBehavior", "&", "Settings", ".", "Secure", ".", "INCALL_POWER_BUTTON_BEHAVIOR_HANGUP", ")", "!=", "0", "&&", "telephonyService", ".", "isOffhook", "(", ")", ")", "{", "hungUp", "=", "telephonyService", ".", "endCall", "(", ")", ";", "}", "}", "catch", "(", "RemoteException", "ex", ")", "{", "Log", ".", "w", "(", "TAG", ",", "\"\"", ",", "ex", ")", ";", "}", "}", "interceptPowerKeyDown", "(", "!", "isScreenOn", "||", "hungUp", "||", "mVolumeDownKeyTriggered", "||", "mVolumeUpKeyTriggered", ")", ";", "}", "else", "{", "mPowerKeyTriggered", "=", "false", ";", "cancelPendingScreenshotChordAction", "(", ")", ";", "if", "(", "interceptPowerKeyUp", "(", "canceled", "||", "mPendingPowerKeyUpCanceled", ")", ")", "{", "result", "=", "(", "result", "&", "~", "ACTION_POKE_USER_ACTIVITY", ")", "|", "ACTION_GO_TO_SLEEP", ";", "}", "mPendingPowerKeyUpCanceled", "=", "false", ";", "}", "break", ";", "}", "case", "KeyEvent", ".", "KEYCODE_MEDIA_PLAY", ":", "case", "KeyEvent", ".", "KEYCODE_MEDIA_PAUSE", ":", "case", "KeyEvent", ".", "KEYCODE_MEDIA_PLAY_PAUSE", ":", "if", "(", "down", ")", "{", "ITelephony", "telephonyService", "=", "getTelephonyService", "(", ")", ";", "if", "(", "telephonyService", "!=", "null", ")", "{", "try", "{", "if", "(", "!", "telephonyService", ".", "isIdle", "(", ")", ")", "{", "break", ";", "}", "}", "catch", "(", "RemoteException", "ex", ")", "{", "Log", ".", "w", "(", "TAG", ",", "\"\"", ",", "ex", ")", ";", "}", "}", "}", "case", "KeyEvent", ".", "KEYCODE_HEADSETHOOK", ":", "case", "KeyEvent", ".", "KEYCODE_MUTE", ":", "case", "KeyEvent", ".", "KEYCODE_MEDIA_STOP", ":", "case", "KeyEvent", ".", "KEYCODE_MEDIA_NEXT", ":", "case", "KeyEvent", ".", "KEYCODE_MEDIA_PREVIOUS", ":", "case", "KeyEvent", ".", "KEYCODE_MEDIA_REWIND", ":", "case", "KeyEvent", ".", "KEYCODE_MEDIA_RECORD", ":", "case", "KeyEvent", ".", "KEYCODE_MEDIA_FAST_FORWARD", ":", "{", "if", "(", "(", "result", "&", "ACTION_PASS_TO_USER", ")", "==", "0", ")", "{", "mBroadcastWakeLock", ".", "acquire", "(", ")", ";", "mHandler", ".", "post", "(", "new", "PassHeadsetKey", "(", "new", "KeyEvent", "(", "event", ")", ")", ")", ";", "}", "break", ";", "}", "case", "KeyEvent", ".", "KEYCODE_CALL", ":", "{", "if", "(", "down", ")", "{", "ITelephony", "telephonyService", "=", "getTelephonyService", "(", ")", ";", "if", "(", "telephonyService", "!=", "null", ")", "{", "try", "{", "if", "(", "telephonyService", ".", "isRinging", "(", ")", ")", "{", "Log", ".", "i", "(", "TAG", ",", "\"\"", "+", "\"\"", ")", ";", "telephonyService", ".", "answerRingingCall", "(", ")", ";", "result", "&=", "~", "ACTION_PASS_TO_USER", ";", "}", "}", "catch", "(", "RemoteException", "ex", ")", "{", "Log", ".", "w", "(", "TAG", ",", "\"\"", ",", "ex", ")", ";", "}", "}", "}", "break", ";", "}", "}", "return", "result", ";", "}", "@", "Override", "public", "int", "interceptMotionBeforeQueueingWhenScreenOff", "(", "int", "policyFlags", ")", "{", "int", "result", "=", "0", ";", "final", "boolean", "isWakeMotion", "=", "(", "policyFlags", "&", "(", "WindowManagerPolicy", ".", "FLAG_WAKE", "|", "WindowManagerPolicy", ".", "FLAG_WAKE_DROPPED", ")", ")", "!=", "0", ";", "if", "(", "isWakeMotion", ")", "{", "if", "(", "mKeyguardMediator", ".", "isShowing", "(", ")", ")", "{", "mKeyguardMediator", ".", "onWakeMotionWhenKeyguardShowingTq", "(", ")", ";", "}", "else", "{", "result", "|=", "ACTION_POKE_USER_ACTIVITY", ";", "}", "}", "return", "result", ";", "}", "class", "PassHeadsetKey", "implements", "Runnable", "{", "KeyEvent", "mKeyEvent", ";", "PassHeadsetKey", "(", "KeyEvent", "keyEvent", ")", "{", "mKeyEvent", "=", "keyEvent", ";", "}", "public", "void", "run", "(", ")", "{", "if", "(", "ActivityManagerNative", ".", "isSystemReady", "(", ")", ")", "{", "Intent", "intent", "=", "new", "Intent", "(", "Intent", ".", "ACTION_MEDIA_BUTTON", ",", "null", ")", ";", "intent", ".", "putExtra", "(", "Intent", ".", "EXTRA_KEY_EVENT", ",", "mKeyEvent", ")", ";", "mContext", ".", "sendOrderedBroadcast", "(", "intent", ",", "null", ",", "mBroadcastDone", ",", "mHandler", ",", "Activity", ".", "RESULT_OK", ",", "null", ",", "null", ")", ";", "}", "}", "}", "BroadcastReceiver", "mBroadcastDone", "=", "new", "BroadcastReceiver", "(", ")", "{", "public", "void", "onReceive", "(", "Context", "context", ",", "Intent", "intent", ")", "{", "mBroadcastWakeLock", ".", "release", "(", ")", ";", "}", "}", ";", "BroadcastReceiver", "mDockReceiver", "=", "new", "BroadcastReceiver", "(", ")", "{", "public", "void", "onReceive", "(", "Context", "context", ",", "Intent", "intent", ")", "{", "if", "(", "Intent", ".", "ACTION_DOCK_EVENT", ".", "equals", "(", "intent", ".", "getAction", "(", ")", ")", ")", "{", "mDockMode", "=", "intent", ".", "getIntExtra", "(", "Intent", ".", "EXTRA_DOCK_STATE", ",", "Intent", ".", "EXTRA_DOCK_STATE_UNDOCKED", ")", ";", "}", "else", "{", "try", "{", "IUiModeManager", "uiModeService", "=", "IUiModeManager", ".", "Stub", ".", "asInterface", "(", "ServiceManager", ".", "getService", "(", "Context", ".", "UI_MODE_SERVICE", ")", ")", ";", "mUiMode", "=", "uiModeService", ".", "getCurrentModeType", "(", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "updateRotation", "(", "true", ")", ";", "updateOrientationListenerLp", "(", ")", ";", "}", "}", ";", "BroadcastReceiver", "mHDMIReceiver", "=", "new", "BroadcastReceiver", "(", ")", "{", "public", "void", "onReceive", "(", "Context", "context", ",", "Intent", "intent", ")", "{", "if", "(", "Intent", ".", "ACTION_HDMISTATUS_CHANGED", ".", "equals", "(", "intent", ".", "getAction", "(", ")", ")", ")", "{", "if", "(", "intent", ".", "getIntExtra", "(", "DisplayManager", ".", "EXTRA_HDMISTATUS", ",", "0", ")", "==", "1", ")", "{", "setHdmiPlugged", "(", "true", ")", ";", "}", "else", "{", "setHdmiPlugged", "(", "false", ")", ";", "}", "}", "}", "}", ";", "BroadcastReceiver", "mThemeChangeReceiver", "=", "new", "BroadcastReceiver", "(", ")", "{", "public", "void", "onReceive", "(", "Context", "context", ",", "Intent", "intent", ")", "{", "mUiContext", "=", "null", ";", "}", "}", ";", "public", "void", "screenTurnedOff", "(", "int", "why", ")", "{", "EventLog", ".", "writeEvent", "(", "70000", ",", "0", ")", ";", "synchronized", "(", "mLock", ")", "{", "mScreenOnEarly", "=", "false", ";", "mScreenOnFully", "=", "false", ";", "}", "mKeyguardMediator", ".", "onScreenTurnedOff", "(", "why", ")", ";", "synchronized", "(", "mLock", ")", "{", "updateOrientationListenerLp", "(", ")", ";", "updateLockScreenTimeout", "(", ")", ";", "}", "}", "public", "void", "screenTurningOn", "(", "final", "ScreenOnListener", "screenOnListener", ")", "{", "EventLog", ".", "writeEvent", "(", "70000", ",", "1", ")", ";", "if", "(", "false", ")", "{", "RuntimeException", "here", "=", "new", "RuntimeException", "(", "\"here\"", ")", ";", "here", ".", "fillInStackTrace", "(", ")", ";", "Slog", ".", "i", "(", "TAG", ",", "\"\"", ",", "here", ")", ";", "}", "if", "(", "screenOnListener", "!=", "null", ")", "{", "mKeyguardMediator", ".", "onScreenTurnedOn", "(", "new", "KeyguardViewManager", ".", "ShowListener", "(", ")", "{", "@", "Override", "public", "void", "onShown", "(", "IBinder", "windowToken", ")", "{", "if", "(", "windowToken", "!=", "null", ")", "{", "try", "{", "mWindowManager", ".", "waitForWindowDrawn", "(", "windowToken", ",", "new", "IRemoteCallback", ".", "Stub", "(", ")", "{", "@", "Override", "public", "void", "sendResult", "(", "Bundle", "data", ")", "{", "Slog", ".", "i", "(", "TAG", ",", "\"\"", ")", ";", "screenOnListener", ".", "onScreenOn", "(", ")", ";", "synchronized", "(", "mLock", ")", "{", "mScreenOnFully", "=", "true", ";", "}", "}", "}", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "else", "{", "Slog", ".", "i", "(", "TAG", ",", "\"\"", ")", ";", "screenOnListener", ".", "onScreenOn", "(", ")", ";", "synchronized", "(", "mLock", ")", "{", "mScreenOnFully", "=", "true", ";", "}", "}", "}", "}", ")", ";", "}", "else", "{", "synchronized", "(", "mLock", ")", "{", "mScreenOnFully", "=", "true", ";", "}", "}", "synchronized", "(", "mLock", ")", "{", "mScreenOnEarly", "=", "true", ";", "updateOrientationListenerLp", "(", ")", ";", "updateLockScreenTimeout", "(", ")", ";", "}", "}", "public", "boolean", "isScreenOnEarly", "(", ")", "{", "return", "mScreenOnEarly", ";", "}", "public", "boolean", "isScreenOnFully", "(", ")", "{", "return", "mScreenOnFully", ";", "}", "public", "void", "enableKeyguard", "(", "boolean", "enabled", ")", "{", "mKeyguardMediator", ".", "setKeyguardEnabled", "(", "enabled", ")", ";", "}", "public", "void", "exitKeyguardSecurely", "(", "OnKeyguardExitResult", "callback", ")", "{", "mKeyguardMediator", ".", "verifyUnlock", "(", "callback", ")", ";", "}", "private", "boolean", "keyguardIsShowingTq", "(", ")", "{", "return", "mKeyguardMediator", ".", "isShowingAndNotHidden", "(", ")", ";", "}", "public", "boolean", "isKeyguardLocked", "(", ")", "{", "return", "keyguardOn", "(", ")", ";", "}", "public", "boolean", "isKeyguardSecure", "(", ")", "{", "return", "mKeyguardMediator", ".", "isSecure", "(", ")", ";", "}", "public", "boolean", "inKeyguardRestrictedKeyInputMode", "(", ")", "{", "return", "mKeyguardMediator", ".", "isInputRestricted", "(", ")", ";", "}", "public", "void", "dismissKeyguardLw", "(", ")", "{", "if", "(", "!", "mKeyguardMediator", ".", "isSecure", "(", ")", ")", "{", "if", "(", "mKeyguardMediator", ".", "isShowing", "(", ")", ")", "{", "mHandler", ".", "post", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "mKeyguardMediator", ".", "keyguardDone", "(", "false", ",", "true", ")", ";", "}", "}", ")", ";", "}", "}", "}", "void", "sendCloseSystemWindows", "(", ")", "{", "sendCloseSystemWindows", "(", "mContext", ",", "null", ")", ";", "}", "void", "sendCloseSystemWindows", "(", "String", "reason", ")", "{", "sendCloseSystemWindows", "(", "mContext", ",", "reason", ")", ";", "}", "static", "void", "sendCloseSystemWindows", "(", "Context", "context", ",", "String", "reason", ")", "{", "if", "(", "ActivityManagerNative", ".", "isSystemReady", "(", ")", ")", "{", "try", "{", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "closeSystemDialogs", "(", "reason", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "}", "@", "Override", "public", "int", "rotationForOrientationLw", "(", "int", "orientation", ",", "int", "lastRotation", ")", "{", "if", "(", "false", ")", "{", "Slog", ".", "v", "(", "TAG", ",", "\"\"", "+", "orientation", "+", "\",", "last=\"", "+", "lastRotation", "+", "\");", "user=\"", "+", "mUserRotation", "+", "\"", "\"", "+", "(", "(", "mUserRotationMode", "==", "WindowManagerPolicy", ".", "USER_ROTATION_LOCKED", ")", "?", "\"\"", ":", "\"\"", ")", ")", ";", "}", "synchronized", "(", "mLock", ")", "{", "int", "sensorRotation", ";", "if", "(", "MediaPlayer", ".", "isPlayingVideo", "(", ")", ")", "{", "sensorRotation", "=", "Surface", ".", "ROTATION_0", ";", "}", "else", "{", "sensorRotation", "=", "mOrientationListener", ".", "getProposedRotation", "(", ")", ";", "}", "if", "(", "sensorRotation", "<", "0", ")", "{", "sensorRotation", "=", "lastRotation", ";", "}", "final", "int", "preferredRotation", ";", "if", "(", "mLidOpen", "==", "LID_OPEN", "&&", "mLidOpenRotation", ">=", "0", ")", "{", "preferredRotation", "=", "mLidOpenRotation", ";", "}", "else", "if", "(", "mDockMode", "==", "Intent", ".", "EXTRA_DOCK_STATE_CAR", "&&", "(", "mCarDockEnablesAccelerometer", "||", "mCarDockRotation", ">=", "0", ")", ")", "{", "preferredRotation", "=", "mCarDockEnablesAccelerometer", "?", "sensorRotation", ":", "mCarDockRotation", ";", "}", "else", "if", "(", "(", "mDockMode", "==", "Intent", ".", "EXTRA_DOCK_STATE_DESK", "||", "mDockMode", "==", "Intent", ".", "EXTRA_DOCK_STATE_LE_DESK", "||", "mDockMode", "==", "Intent", ".", "EXTRA_DOCK_STATE_HE_DESK", ")", "&&", "(", "mDeskDockEnablesAccelerometer", "||", "mDeskDockRotation", ">=", "0", ")", ")", "{", "preferredRotation", "=", "mDeskDockEnablesAccelerometer", "?", "sensorRotation", ":", "mDeskDockRotation", ";", "}", "else", "if", "(", "mHdmiPlugged", ")", "{", "preferredRotation", "=", "mHdmiRotation", ";", "}", "else", "if", "(", "(", "mAccelerometerDefault", "!=", "0", "&&", "(", "orientation", "==", "ActivityInfo", ".", "SCREEN_ORIENTATION_USER", "||", "orientation", "==", "ActivityInfo", ".", "SCREEN_ORIENTATION_UNSPECIFIED", ")", ")", "||", "orientation", "==", "ActivityInfo", ".", "SCREEN_ORIENTATION_SENSOR", "||", "orientation", "==", "ActivityInfo", ".", "SCREEN_ORIENTATION_FULL_SENSOR", "||", "orientation", "==", "ActivityInfo", ".", "SCREEN_ORIENTATION_SENSOR_LANDSCAPE", "||", "orientation", "==", "ActivityInfo", ".", "SCREEN_ORIENTATION_SENSOR_PORTRAIT", ")", "{", "if", "(", "mAllowAllRotations", "<", "0", ")", "{", "mAllowAllRotations", "=", "mContext", ".", "getResources", "(", ")", ".", "getBoolean", "(", "com", ".", "android", ".", "internal", ".", "R", ".", "bool", ".", "config_allowAllRotations", ")", "?", "1", ":", "0", ";", "}", "boolean", "allowed", "=", "true", ";", "if", "(", "mUserRotationAngles", "<", "0", ")", "{", "mUserRotationAngles", "=", "mAllowAllRotations", "==", "1", "?", "(", "1", "|", "2", "|", "4", "|", "8", ")", ":", "(", "1", "|", "2", "|", "8", ")", ";", "}", "switch", "(", "sensorRotation", ")", "{", "case", "Surface", ".", "ROTATION_0", ":", "allowed", "=", "(", "mUserRotationAngles", "&", "1", ")", "!=", "0", ";", "break", ";", "case", "Surface", ".", "ROTATION_90", ":", "allowed", "=", "(", "mUserRotationAngles", "&", "2", ")", "!=", "0", ";", "break", ";", "case", "Surface", ".", "ROTATION_180", ":", "allowed", "=", "(", "mUserRotationAngles", "&", "4", ")", "!=", "0", ";", "break", ";", "case", "Surface", ".", "ROTATION_270", ":", "allowed", "=", "(", "mUserRotationAngles", "&", "8", ")", "!=", "0", ";", "break", ";", "}", "if", "(", "allowed", ")", "{", "preferredRotation", "=", "sensorRotation", ";", "}", "else", "{", "preferredRotation", "=", "lastRotation", ";", "}", "}", "else", "if", "(", "mUserRotationMode", "==", "WindowManagerPolicy", ".", "USER_ROTATION_LOCKED", ")", "{", "preferredRotation", "=", "mUserRotation", ";", "}", "else", "{", "preferredRotation", "=", "-", "1", ";", "}", "switch", "(", "orientation", ")", "{", "case", "ActivityInfo", ".", "SCREEN_ORIENTATION_PORTRAIT", ":", "if", "(", "isAnyPortrait", "(", "preferredRotation", ")", ")", "{", "return", "preferredRotation", ";", "}", "return", "mPortraitRotation", ";", "case", "ActivityInfo", ".", "SCREEN_ORIENTATION_LANDSCAPE", ":", "if", "(", "isLandscapeOrSeascape", "(", "preferredRotation", ")", ")", "{", "return", "preferredRotation", ";", "}", "return", "mLandscapeRotation", ";", "case", "ActivityInfo", ".", "SCREEN_ORIENTATION_REVERSE_PORTRAIT", ":", "if", "(", "isAnyPortrait", "(", "preferredRotation", ")", ")", "{", "return", "preferredRotation", ";", "}", "return", "mUpsideDownRotation", ";", "case", "ActivityInfo", ".", "SCREEN_ORIENTATION_REVERSE_LANDSCAPE", ":", "if", "(", "isLandscapeOrSeascape", "(", "preferredRotation", ")", ")", "{", "return", "preferredRotation", ";", "}", "return", "mSeascapeRotation", ";", "case", "ActivityInfo", ".", "SCREEN_ORIENTATION_SENSOR_LANDSCAPE", ":", "if", "(", "isLandscapeOrSeascape", "(", "preferredRotation", ")", ")", "{", "return", "preferredRotation", ";", "}", "if", "(", "isLandscapeOrSeascape", "(", "lastRotation", ")", ")", "{", "return", "lastRotation", ";", "}", "return", "mLandscapeRotation", ";", "case", "ActivityInfo", ".", "SCREEN_ORIENTATION_SENSOR_PORTRAIT", ":", "if", "(", "isAnyPortrait", "(", "preferredRotation", ")", ")", "{", "return", "preferredRotation", ";", "}", "if", "(", "isAnyPortrait", "(", "lastRotation", ")", ")", "{", "return", "lastRotation", ";", "}", "return", "mPortraitRotation", ";", "default", ":", "if", "(", "preferredRotation", ">=", "0", ")", "{", "return", "preferredRotation", ";", "}", "return", "Surface", ".", "ROTATION_0", ";", "}", "}", "}", "@", "Override", "public", "boolean", "rotationHasCompatibleMetricsLw", "(", "int", "orientation", ",", "int", "rotation", ")", "{", "switch", "(", "orientation", ")", "{", "case", "ActivityInfo", ".", "SCREEN_ORIENTATION_PORTRAIT", ":", "case", "ActivityInfo", ".", "SCREEN_ORIENTATION_REVERSE_PORTRAIT", ":", "case", "ActivityInfo", ".", "SCREEN_ORIENTATION_SENSOR_PORTRAIT", ":", "return", "isAnyPortrait", "(", "rotation", ")", ";", "case", "ActivityInfo", ".", "SCREEN_ORIENTATION_LANDSCAPE", ":", "case", "ActivityInfo", ".", "SCREEN_ORIENTATION_REVERSE_LANDSCAPE", ":", "case", "ActivityInfo", ".", "SCREEN_ORIENTATION_SENSOR_LANDSCAPE", ":", "return", "isLandscapeOrSeascape", "(", "rotation", ")", ";", "default", ":", "return", "true", ";", "}", "}", "@", "Override", "public", "void", "setRotationLw", "(", "int", "rotation", ")", "{", "mOrientationListener", ".", "setCurrentRotation", "(", "rotation", ")", ";", "}", "private", "boolean", "isLandscapeOrSeascape", "(", "int", "rotation", ")", "{", "return", "rotation", "==", "mLandscapeRotation", "||", "rotation", "==", "mSeascapeRotation", ";", "}", "private", "boolean", "isAnyPortrait", "(", "int", "rotation", ")", "{", "return", "rotation", "==", "mPortraitRotation", "||", "rotation", "==", "mUpsideDownRotation", ";", "}", "public", "void", "setUserRotationMode", "(", "int", "mode", ",", "int", "rot", ")", "{", "ContentResolver", "res", "=", "mContext", ".", "getContentResolver", "(", ")", ";", "if", "(", "mode", "==", "WindowManagerPolicy", ".", "USER_ROTATION_LOCKED", ")", "{", "Settings", ".", "System", ".", "putInt", "(", "res", ",", "Settings", ".", "System", ".", "USER_ROTATION", ",", "rot", ")", ";", "Settings", ".", "System", ".", "putInt", "(", "res", ",", "Settings", ".", "System", ".", "ACCELEROMETER_ROTATION", ",", "0", ")", ";", "}", "else", "{", "Settings", ".", "System", ".", "putInt", "(", "res", ",", "Settings", ".", "System", ".", "ACCELEROMETER_ROTATION", ",", "1", ")", ";", "}", "}", "public", "boolean", "detectSafeMode", "(", ")", "{", "try", "{", "int", "menuState", "=", "mWindowManager", ".", "getKeycodeState", "(", "KeyEvent", ".", "KEYCODE_MENU", ")", ";", "int", "sState", "=", "mWindowManager", ".", "getKeycodeState", "(", "KeyEvent", ".", "KEYCODE_S", ")", ";", "int", "dpadState", "=", "mWindowManager", ".", "getDPadKeycodeState", "(", "KeyEvent", ".", "KEYCODE_DPAD_CENTER", ")", ";", "int", "trackballState", "=", "mWindowManager", ".", "getTrackballScancodeState", "(", "BTN_MOUSE", ")", ";", "int", "volumeDownState", "=", "mWindowManager", ".", "getKeycodeState", "(", "KeyEvent", ".", "KEYCODE_VOLUME_DOWN", ")", ";", "mSafeMode", "=", "menuState", ">", "0", "||", "sState", ">", "0", "||", "dpadState", ">", "0", "||", "trackballState", ">", "0", "||", "volumeDownState", ">", "0", ";", "performHapticFeedbackLw", "(", "null", ",", "mSafeMode", "?", "HapticFeedbackConstants", ".", "SAFE_MODE_ENABLED", ":", "HapticFeedbackConstants", ".", "SAFE_MODE_DISABLED", ",", "true", ")", ";", "if", "(", "mSafeMode", ")", "{", "Log", ".", "i", "(", "TAG", ",", "\"\"", "+", "menuState", "+", "\"", "s=\"", "+", "sState", "+", "\"", "dpad=\"", "+", "dpadState", "+", "\"", "trackball=\"", "+", "trackballState", "+", "\")\"", ")", ";", "}", "else", "{", "Log", ".", "i", "(", "TAG", ",", "\"\"", ")", ";", "}", "return", "mSafeMode", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "}", "static", "long", "[", "]", "getLongIntArray", "(", "Resources", "r", ",", "int", "resid", ")", "{", "int", "[", "]", "ar", "=", "r", ".", "getIntArray", "(", "resid", ")", ";", "if", "(", "ar", "==", "null", ")", "{", "return", "null", ";", "}", "long", "[", "]", "out", "=", "new", "long", "[", "ar", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "ar", ".", "length", ";", "i", "++", ")", "{", "out", "[", "i", "]", "=", "ar", "[", "i", "]", ";", "}", "return", "out", ";", "}", "public", "void", "systemReady", "(", ")", "{", "mKeyguardMediator", ".", "onSystemReady", "(", ")", ";", "android", ".", "os", ".", "SystemProperties", ".", "set", "(", "\"\"", ",", "\"1\"", ")", ";", "synchronized", "(", "mLock", ")", "{", "updateOrientationListenerLp", "(", ")", ";", "mSystemReady", "=", "true", ";", "mHandler", ".", "post", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "updateSettings", "(", ")", ";", "}", "}", ")", ";", "}", "}", "public", "void", "systemBooted", "(", ")", "{", "synchronized", "(", "mLock", ")", "{", "mSystemBooted", "=", "true", ";", "}", "}", "ProgressDialog", "mBootMsgDialog", "=", "null", ";", "public", "void", "showBootMessage", "(", "final", "CharSequence", "msg", ",", "final", "boolean", "always", ")", "{", "mHandler", ".", "post", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "if", "(", "mBootMsgDialog", "==", "null", ")", "{", "mBootMsgDialog", "=", "new", "ProgressDialog", "(", "mContext", ")", "{", "@", "Override", "public", "boolean", "dispatchKeyEvent", "(", "KeyEvent", "event", ")", "{", "return", "true", ";", "}", "@", "Override", "public", "boolean", "dispatchKeyShortcutEvent", "(", "KeyEvent", "event", ")", "{", "return", "true", ";", "}", "@", "Override", "public", "boolean", "dispatchTouchEvent", "(", "MotionEvent", "ev", ")", "{", "return", "true", ";", "}", "@", "Override", "public", "boolean", "dispatchTrackballEvent", "(", "MotionEvent", "ev", ")", "{", "return", "true", ";", "}", "@", "Override", "public", "boolean", "dispatchGenericMotionEvent", "(", "MotionEvent", "ev", ")", "{", "return", "true", ";", "}", "@", "Override", "public", "boolean", "dispatchPopulateAccessibilityEvent", "(", "AccessibilityEvent", "event", ")", "{", "return", "true", ";", "}", "}", ";", "mBootMsgDialog", ".", "setTitle", "(", "R", ".", "string", ".", "android_upgrading_title", ")", ";", "mBootMsgDialog", ".", "setProgressStyle", "(", "ProgressDialog", ".", "STYLE_SPINNER", ")", ";", "mBootMsgDialog", ".", "setIndeterminate", "(", "true", ")", ";", "mBootMsgDialog", ".", "getWindow", "(", ")", ".", "setType", "(", "WindowManager", ".", "LayoutParams", ".", "TYPE_BOOT_PROGRESS", ")", ";", "mBootMsgDialog", ".", "getWindow", "(", ")", ".", "addFlags", "(", "WindowManager", ".", "LayoutParams", ".", "FLAG_DIM_BEHIND", "|", "WindowManager", ".", "LayoutParams", ".", "FLAG_LAYOUT_IN_SCREEN", ")", ";", "mBootMsgDialog", ".", "getWindow", "(", ")", ".", "setDimAmount", "(", "1", ")", ";", "WindowManager", ".", "LayoutParams", "lp", "=", "mBootMsgDialog", ".", "getWindow", "(", ")", ".", "getAttributes", "(", ")", ";", "lp", ".", "screenOrientation", "=", "ActivityInfo", ".", "SCREEN_ORIENTATION_NOSENSOR", ";", "mBootMsgDialog", ".", "getWindow", "(", ")", ".", "setAttributes", "(", "lp", ")", ";", "mBootMsgDialog", ".", "setCancelable", "(", "false", ")", ";", "mBootMsgDialog", ".", "show", "(", ")", ";", "}", "mBootMsgDialog", ".", "setMessage", "(", "msg", ")", ";", "}", "}", ")", ";", "}", "public", "void", "hideBootMessages", "(", ")", "{", "mHandler", ".", "post", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "if", "(", "mBootMsgDialog", "!=", "null", ")", "{", "mBootMsgDialog", ".", "dismiss", "(", ")", ";", "mBootMsgDialog", "=", "null", ";", "}", "}", "}", ")", ";", "}", "public", "void", "userActivity", "(", ")", "{", "synchronized", "(", "mScreenLockTimeout", ")", "{", "if", "(", "mLockScreenTimerActive", ")", "{", "mHandler", ".", "removeCallbacks", "(", "mScreenLockTimeout", ")", ";", "mHandler", ".", "postDelayed", "(", "mScreenLockTimeout", ",", "mLockScreenTimeout", ")", ";", "}", "}", "}", "Runnable", "mScreenLockTimeout", "=", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "synchronized", "(", "this", ")", "{", "if", "(", "localLOGV", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "mKeyguardMediator", ".", "doKeyguardTimeout", "(", ")", ";", "mLockScreenTimerActive", "=", "false", ";", "}", "}", "}", ";", "public", "void", "lockNow", "(", ")", "{", "mContext", ".", "enforceCallingOrSelfPermission", "(", "android", ".", "Manifest", ".", "permission", ".", "DEVICE_POWER", ",", "null", ")", ";", "mHandler", ".", "removeCallbacks", "(", "mScreenLockTimeout", ")", ";", "mHandler", ".", "post", "(", "mScreenLockTimeout", ")", ";", "}", "private", "void", "updateLockScreenTimeout", "(", ")", "{", "synchronized", "(", "mScreenLockTimeout", ")", "{", "boolean", "enable", "=", "(", "mAllowLockscreenWhenOn", "&&", "mScreenOnEarly", "&&", "mKeyguardMediator", ".", "isSecure", "(", ")", ")", ";", "if", "(", "mLockScreenTimerActive", "!=", "enable", ")", "{", "if", "(", "enable", ")", "{", "if", "(", "localLOGV", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "mHandler", ".", "postDelayed", "(", "mScreenLockTimeout", ",", "mLockScreenTimeout", ")", ";", "}", "else", "{", "if", "(", "localLOGV", ")", "Log", ".", "v", "(", "TAG", ",", "\"\"", ")", ";", "mHandler", ".", "removeCallbacks", "(", "mScreenLockTimeout", ")", ";", "}", "mLockScreenTimerActive", "=", "enable", ";", "}", "}", "}", "public", "void", "enableScreenAfterBoot", "(", ")", "{", "readLidState", "(", ")", ";", "updateKeyboardVisibility", "(", ")", ";", "updateRotation", "(", "true", ")", ";", "}", "private", "void", "updateKeyboardVisibility", "(", ")", "{", "mPowerManager", ".", "setKeyboardVisibility", "(", "mLidOpen", "==", "LID_OPEN", ")", ";", "}", "void", "updateRotation", "(", "boolean", "alwaysSendConfiguration", ")", "{", "try", "{", "mWindowManager", ".", "updateRotation", "(", "alwaysSendConfiguration", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "}", "Intent", "createHomeDockIntent", "(", ")", "{", "Intent", "intent", "=", "null", ";", "if", "(", "mUiMode", "==", "Configuration", ".", "UI_MODE_TYPE_CAR", ")", "{", "if", "(", "ENABLE_CAR_DOCK_HOME_CAPTURE", ")", "{", "intent", "=", "mCarDockIntent", ";", "}", "}", "else", "if", "(", "mUiMode", "==", "Configuration", ".", "UI_MODE_TYPE_DESK", ")", "{", "if", "(", "ENABLE_DESK_DOCK_HOME_CAPTURE", ")", "{", "intent", "=", "mDeskDockIntent", ";", "}", "}", "if", "(", "intent", "==", "null", ")", "{", "return", "null", ";", "}", "ActivityInfo", "ai", "=", "intent", ".", "resolveActivityInfo", "(", "mContext", ".", "getPackageManager", "(", ")", ",", "PackageManager", ".", "GET_META_DATA", ")", ";", "if", "(", "ai", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "ai", ".", "metaData", "!=", "null", "&&", "ai", ".", "metaData", ".", "getBoolean", "(", "Intent", ".", "METADATA_DOCK_HOME", ")", ")", "{", "intent", "=", "new", "Intent", "(", "intent", ")", ";", "intent", ".", "setClassName", "(", "ai", ".", "packageName", ",", "ai", ".", "name", ")", ";", "return", "intent", ";", "}", "return", "null", ";", "}", "void", "startDockOrHome", "(", ")", "{", "Intent", "dock", "=", "createHomeDockIntent", "(", ")", ";", "if", "(", "dock", "!=", "null", ")", "{", "try", "{", "mContext", ".", "startActivity", "(", "dock", ")", ";", "return", ";", "}", "catch", "(", "ActivityNotFoundException", "e", ")", "{", "}", "}", "mContext", ".", "startActivity", "(", "mHomeIntent", ")", ";", "}", "boolean", "goHome", "(", ")", "{", "if", "(", "false", ")", "{", "try", "{", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "stopAppSwitches", "(", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "}", "sendCloseSystemWindows", "(", ")", ";", "startDockOrHome", "(", ")", ";", "}", "else", "{", "try", "{", "if", "(", "SystemProperties", ".", "getInt", "(", "\"\"", ",", "0", ")", "==", "1", ")", "{", "Log", ".", "d", "(", "TAG", ",", "\"\"", ")", ";", "}", "else", "{", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "stopAppSwitches", "(", ")", ";", "sendCloseSystemWindows", "(", ")", ";", "Intent", "dock", "=", "createHomeDockIntent", "(", ")", ";", "if", "(", "dock", "!=", "null", ")", "{", "int", "result", "=", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "startActivity", "(", "null", ",", "dock", ",", "dock", ".", "resolveTypeIfNeeded", "(", "mContext", ".", "getContentResolver", "(", ")", ")", ",", "null", ",", "0", ",", "null", ",", "null", ",", "0", ",", "true", ",", "false", ",", "null", ",", "null", ",", "false", ")", ";", "if", "(", "result", "==", "IActivityManager", ".", "START_RETURN_INTENT_TO_CALLER", ")", "{", "return", "false", ";", "}", "}", "}", "int", "result", "=", "ActivityManagerNative", ".", "getDefault", "(", ")", ".", "startActivity", "(", "null", ",", "mHomeIntent", ",", "mHomeIntent", ".", "resolveTypeIfNeeded", "(", "mContext", ".", "getContentResolver", "(", ")", ")", ",", "null", ",", "0", ",", "null", ",", "null", ",", "0", ",", "true", ",", "false", ",", "null", ",", "null", ",", "false", ")", ";", "if", "(", "result", "==", "IActivityManager", ".", "START_RETURN_INTENT_TO_CALLER", ")", "{", "return", "false", ";", "}", "}", "catch", "(", "RemoteException", "ex", ")", "{", "}", "}", "return", "true", ";", "}", "public", "void", "setCurrentOrientationLw", "(", "int", "newOrientation", ")", "{", "synchronized", "(", "mLock", ")", "{", "if", "(", "newOrientation", "!=", "mCurrentAppOrientation", ")", "{", "mCurrentAppOrientation", "=", "newOrientation", ";", "updateOrientationListenerLp", "(", ")", ";", "}", "}", "}", "public", "boolean", "performHapticFeedbackLw", "(", "WindowState", "win", ",", "int", "effectId", ",", "boolean", "always", ")", "{", "final", "boolean", "hapticsDisabled", "=", "Settings", ".", "System", ".", "getInt", "(", "mContext", ".", "getContentResolver", "(", ")", ",", "Settings", ".", "System", ".", "HAPTIC_FEEDBACK_ENABLED", ",", "0", ")", "==", "0", ";", "if", "(", "!", "always", "&&", "(", "hapticsDisabled", "||", "mKeyguardMediator", ".", "isShowingAndNotHidden", "(", ")", ")", ")", "{", "return", "false", ";", "}", "long", "[", "]", "pattern", "=", "null", ";", "switch", "(", "effectId", ")", "{", "case", "HapticFeedbackConstants", ".", "LONG_PRESS", ":", "pattern", "=", "mLongPressVibePattern", ";", "break", ";", "case", "HapticFeedbackConstants", ".", "VIRTUAL_KEY", ":", "pattern", "=", "mVirtualKeyVibePattern", ";", "break", ";", "case", "HapticFeedbackConstants", ".", "KEYBOARD_TAP", ":", "pattern", "=", "mKeyboardTapVibePattern", ";", "break", ";", "case", "HapticFeedbackConstants", ".", "SAFE_MODE_DISABLED", ":", "pattern", "=", "mSafeModeDisabledVibePattern", ";", "break", ";", "case", "HapticFeedbackConstants", ".", "SAFE_MODE_ENABLED", ":", "pattern", "=", "mSafeModeEnabledVibePattern", ";", "break", ";", "default", ":", "return", "false", ";", "}", "if", "(", "pattern", ".", "length", "==", "1", ")", "{", "mVibrator", ".", "vibrate", "(", "pattern", "[", "0", "]", ")", ";", "}", "else", "{", "mVibrator", ".", "vibrate", "(", "pattern", ",", "-", "1", ")", ";", "}", "return", "true", ";", "}", "public", "void", "screenOnStartedLw", "(", ")", "{", "}", "public", "void", "screenOnStoppedLw", "(", ")", "{", "if", "(", "mPowerManager", ".", "isScreenOn", "(", ")", ")", "{", "if", "(", "!", "mKeyguardMediator", ".", "isShowingAndNotHidden", "(", ")", ")", "{", "long", "curTime", "=", "SystemClock", ".", "uptimeMillis", "(", ")", ";", "mPowerManager", ".", "userActivity", "(", "curTime", ",", "false", ",", "LocalPowerManager", ".", "OTHER_EVENT", ")", ";", "}", "}", "}", "public", "boolean", "allowKeyRepeat", "(", ")", "{", "return", "mScreenOnEarly", ";", "}", "private", "int", "updateSystemUiVisibilityLw", "(", ")", "{", "if", "(", "mFocusedWindow", "==", "null", ")", "{", "return", "0", ";", "}", "final", "int", "visibility", "=", "mFocusedWindow", ".", "getSystemUiVisibility", "(", ")", "&", "~", "mResettingSystemUiFlags", "&", "~", "mForceClearedSystemUiFlags", ";", "int", "diff", "=", "visibility", "^", "mLastSystemUiFlags", ";", "final", "boolean", "needsMenu", "=", "mFocusedWindow", ".", "getNeedsMenuLw", "(", "mTopFullscreenOpaqueWindowState", ")", ";", "if", "(", "diff", "==", "0", "&&", "mLastFocusNeedsMenu", "==", "needsMenu", "&&", "mFocusedApp", "==", "mFocusedWindow", ".", "getAppToken", "(", ")", ")", "{", "return", "0", ";", "}", "mLastSystemUiFlags", "=", "visibility", ";", "mLastFocusNeedsMenu", "=", "needsMenu", ";", "mFocusedApp", "=", "mFocusedWindow", ".", "getAppToken", "(", ")", ";", "mHandler", ".", "post", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "if", "(", "mStatusBarService", "==", "null", ")", "{", "mStatusBarService", "=", "IStatusBarService", ".", "Stub", ".", "asInterface", "(", "ServiceManager", ".", "getService", "(", "\"statusbar\"", ")", ")", ";", "}", "if", "(", "mStatusBarService", "!=", "null", ")", "{", "try", "{", "mStatusBarService", ".", "setSystemUiVisibility", "(", "visibility", ")", ";", "mStatusBarService", ".", "topAppWindowChanged", "(", "needsMenu", ")", ";", "}", "catch", "(", "RemoteException", "e", ")", "{", "mStatusBarService", "=", "null", ";", "}", "}", "}", "}", ")", ";", "return", "diff", ";", "}", "public", "boolean", "hasNavigationBar", "(", ")", "{", "return", "mHasNavigationBar", ";", "}", "public", "void", "dump", "(", "String", "prefix", ",", "FileDescriptor", "fd", ",", "PrintWriter", "pw", ",", "String", "[", "]", "args", ")", "{", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"mSafeMode=\"", ")", ";", "pw", ".", "print", "(", "mSafeMode", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mSystemReady", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mSystemBooted", ")", ";", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"mLidOpen=\"", ")", ";", "pw", ".", "print", "(", "mLidOpen", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mLidOpenRotation", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mHdmiPlugged", ")", ";", "if", "(", "mLastSystemUiFlags", "!=", "0", "||", "mResettingSystemUiFlags", "!=", "0", "||", "mForceClearedSystemUiFlags", "!=", "0", ")", "{", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "Integer", ".", "toHexString", "(", "mLastSystemUiFlags", ")", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "Integer", ".", "toHexString", "(", "mResettingSystemUiFlags", ")", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "Integer", ".", "toHexString", "(", "mForceClearedSystemUiFlags", ")", ")", ";", "}", "if", "(", "mLastFocusNeedsMenu", ")", "{", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mLastFocusNeedsMenu", ")", ";", "}", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"mUiMode=\"", ")", ";", "pw", ".", "print", "(", "mUiMode", ")", ";", "pw", ".", "print", "(", "\"", "mDockMode=\"", ")", ";", "pw", ".", "print", "(", "mDockMode", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mCarDockRotation", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mDeskDockRotation", ")", ";", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mUserRotationMode", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mUserRotation", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mAllowAllRotations", ")", ";", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mAccelerometerDefault", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mCurrentAppOrientation", ")", ";", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mCarDockEnablesAccelerometer", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mDeskDockEnablesAccelerometer", ")", ";", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mLidKeyboardAccessibility", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mLidNavigationAccessibility", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mLongPressOnPowerBehavior", ")", ";", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mScreenOnEarly", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mScreenOnFully", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mOrientationSensorEnabled", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mHasSoftInput", ")", ";", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mUnrestrictedScreenLeft", ")", ";", "pw", ".", "print", "(", "\",\"", ")", ";", "pw", ".", "print", "(", "mUnrestrictedScreenTop", ")", ";", "pw", ".", "print", "(", "\")", "\"", ")", ";", "pw", ".", "print", "(", "mUnrestrictedScreenWidth", ")", ";", "pw", ".", "print", "(", "\"x\"", ")", ";", "pw", ".", "println", "(", "mUnrestrictedScreenHeight", ")", ";", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mRestrictedScreenLeft", ")", ";", "pw", ".", "print", "(", "\",\"", ")", ";", "pw", ".", "print", "(", "mRestrictedScreenTop", ")", ";", "pw", ".", "print", "(", "\")", "\"", ")", ";", "pw", ".", "print", "(", "mRestrictedScreenWidth", ")", ";", "pw", ".", "print", "(", "\"x\"", ")", ";", "pw", ".", "println", "(", "mRestrictedScreenHeight", ")", ";", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"mCur=(\"", ")", ";", "pw", ".", "print", "(", "mCurLeft", ")", ";", "pw", ".", "print", "(", "\",\"", ")", ";", "pw", ".", "print", "(", "mCurTop", ")", ";", "pw", ".", "print", "(", "\")-(\"", ")", ";", "pw", ".", "print", "(", "mCurRight", ")", ";", "pw", ".", "print", "(", "\",\"", ")", ";", "pw", ".", "print", "(", "mCurBottom", ")", ";", "pw", ".", "println", "(", "\")\"", ")", ";", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"mContent=(\"", ")", ";", "pw", ".", "print", "(", "mContentLeft", ")", ";", "pw", ".", "print", "(", "\",\"", ")", ";", "pw", ".", "print", "(", "mContentTop", ")", ";", "pw", ".", "print", "(", "\")-(\"", ")", ";", "pw", ".", "print", "(", "mContentRight", ")", ";", "pw", ".", "print", "(", "\",\"", ")", ";", "pw", ".", "print", "(", "mContentBottom", ")", ";", "pw", ".", "println", "(", "\")\"", ")", ";", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"mDock=(\"", ")", ";", "pw", ".", "print", "(", "mDockLeft", ")", ";", "pw", ".", "print", "(", "\",\"", ")", ";", "pw", ".", "print", "(", "mDockTop", ")", ";", "pw", ".", "print", "(", "\")-(\"", ")", ";", "pw", ".", "print", "(", "mDockRight", ")", ";", "pw", ".", "print", "(", "\",\"", ")", ";", "pw", ".", "print", "(", "mDockBottom", ")", ";", "pw", ".", "println", "(", "\")\"", ")", ";", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"mDockLayer=\"", ")", ";", "pw", ".", "println", "(", "mDockLayer", ")", ";", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mTopFullscreenOpaqueWindowState", ")", ";", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mTopIsFullscreen", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mForceStatusBar", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mHideLockScreen", ")", ";", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mDismissKeyguard", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mHomePressed", ")", ";", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mAllowLockscreenWhenOn", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mLockScreenTimeout", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mLockScreenTimerActive", ")", ";", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mEndcallBehavior", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mIncallPowerBehavior", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mLongPressOnHomeBehavior", ")", ";", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mLandscapeRotation", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mSeascapeRotation", ")", ";", "pw", ".", "print", "(", "prefix", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "print", "(", "mPortraitRotation", ")", ";", "pw", ".", "print", "(", "\"\"", ")", ";", "pw", ".", "println", "(", "mUpsideDownRotation", ")", ";", "}", "}", "</s>" ]
8,203
[ "<s>", "package", "com", ".", "android", ".", "settings", ".", "cyanogenmod", ";", "import", "android", ".", "content", ".", "ContentResolver", ";", "import", "android", ".", "content", ".", "res", ".", "Configuration", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "preference", ".", "CheckBoxPreference", ";", "import", "android", ".", "preference", ".", "Preference", ";", "import", "android", ".", "preference", ".", "PreferenceScreen", ";", "import", "android", ".", "provider", ".", "Settings", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "com", ".", "android", ".", "settings", ".", "R", ";", "import", "com", ".", "android", ".", "settings", ".", "SettingsPreferenceFragment", ";", "public", "class", "LockscreenInterface", "extends", "SettingsPreferenceFragment", "implements", "Preference", ".", "OnPreferenceChangeListener", "{", "private", "static", "final", "String", "TAG", "=", "\"\"", ";", "private", "final", "Configuration", "mCurConfig", "=", "new", "Configuration", "(", ")", ";", "private", "static", "final", "String", "PREF_LOCKSCREEN_WEATHER", "=", "\"\"", ";", "private", "static", "final", "String", "PREF_WEATHER_SHOW_LOCATION", "=", "\"\"", ";", "private", "static", "final", "String", "PREF_WEATHER_SHOW_TIMESTAMP", "=", "\"\"", ";", "private", "CheckBoxPreference", "mLockscreenWeather", ";", "private", "CheckBoxPreference", "mWeatherShowLocaton", ";", "private", "CheckBoxPreference", "mWeatherShowTimestamp", ";", "boolean", "value", ";", "@", "Override", "public", "void", "onCreate", "(", "Bundle", "savedInstanceState", ")", "{", "super", ".", "onCreate", "(", "savedInstanceState", ")", ";", "addPreferencesFromResource", "(", "R", ".", "xml", ".", "lockscreen_interface_settings", ")", ";", "PreferenceScreen", "prefSet", "=", "getPreferenceScreen", "(", ")", ";", "mLockscreenWeather", "=", "(", "CheckBoxPreference", ")", "prefSet", ".", "findPreference", "(", "PREF_LOCKSCREEN_WEATHER", ")", ";", "mWeatherShowLocaton", "=", "(", "CheckBoxPreference", ")", "prefSet", ".", "findPreference", "(", "PREF_WEATHER_SHOW_LOCATION", ")", ";", "mWeatherShowTimestamp", "=", "(", "CheckBoxPreference", ")", "prefSet", ".", "findPreference", "(", "PREF_WEATHER_SHOW_TIMESTAMP", ")", ";", "value", "=", "mLockscreenWeather", ".", "isChecked", "(", ")", ";", "if", "(", "!", "value", ")", "{", "prefSet", ".", "removePreference", "(", "mWeatherShowLocaton", ")", ";", "prefSet", ".", "removePreference", "(", "mWeatherShowTimestamp", ")", ";", "}", "}", "@", "Override", "public", "void", "onResume", "(", ")", "{", "super", ".", "onResume", "(", ")", ";", "updateState", "(", ")", ";", "}", "@", "Override", "public", "void", "onPause", "(", ")", "{", "super", ".", "onPause", "(", ")", ";", "}", "private", "void", "updateState", "(", ")", "{", "}", "@", "Override", "public", "boolean", "onPreferenceTreeClick", "(", "PreferenceScreen", "preferenceScreen", ",", "Preference", "preference", ")", "{", "super", ".", "onPreferenceTreeClick", "(", "preferenceScreen", ",", "preference", ")", ";", "PreferenceScreen", "prefSet", "=", "getPreferenceScreen", "(", ")", ";", "if", "(", "preference", "==", "mLockscreenWeather", ")", "{", "value", "=", "mLockscreenWeather", ".", "isChecked", "(", ")", ";", "Settings", ".", "System", ".", "putInt", "(", "getContentResolver", "(", ")", ",", "Settings", ".", "System", ".", "LOCKSCREEN_WEATHER", ",", "value", "?", "1", ":", "0", ")", ";", "if", "(", "value", ")", "{", "Log", ".", "d", "(", "TAG", ",", "\"\"", ")", ";", "prefSet", ".", "addPreference", "(", "mWeatherShowLocaton", ")", ";", "prefSet", ".", "addPreference", "(", "mWeatherShowTimestamp", ")", ";", "}", "else", "{", "Log", ".", "d", "(", "TAG", ",", "\"\"", ")", ";", "prefSet", ".", "removePreference", "(", "mWeatherShowLocaton", ")", ";", "prefSet", ".", "removePreference", "(", "mWeatherShowTimestamp", ")", ";", "}", "return", "true", ";", "}", "else", "if", "(", "preference", "==", "mWeatherShowLocaton", ")", "{", "value", "=", "mWeatherShowLocaton", ".", "isChecked", "(", ")", ";", "Settings", ".", "System", ".", "putInt", "(", "getContentResolver", "(", ")", ",", "Settings", ".", "System", ".", "WEATHER_SHOW_LOCATION", ",", "value", "?", "1", ":", "0", ")", ";", "return", "true", ";", "}", "else", "if", "(", "preference", "==", "mWeatherShowTimestamp", ")", "{", "value", "=", "mWeatherShowTimestamp", ".", "isChecked", "(", ")", ";", "Settings", ".", "System", ".", "putInt", "(", "getContentResolver", "(", ")", ",", "Settings", ".", "System", ".", "WEATHER_SHOW_TIMESTAMP", ",", "value", "?", "1", ":", "0", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}", "public", "boolean", "onPreferenceChange", "(", "Preference", "preference", ",", "Object", "objValue", ")", "{", "final", "String", "key", "=", "preference", ".", "getKey", "(", ")", ";", "return", "true", ";", "}", "}", "</s>" ]
8,204
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "org", ".", "metawatch", ".", "manager", ".", "Notification", ".", "VibratePattern", ";", "import", "android", ".", "content", ".", "BroadcastReceiver", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "os", ".", "Bundle", ";", "public", "class", "ApiIntentReceiver", "extends", "BroadcastReceiver", "{", "@", "Override", "public", "void", "onReceive", "(", "Context", "context", ",", "Intent", "intent", ")", "{", "String", "action", "=", "intent", ".", "getAction", "(", ")", ";", "if", "(", "action", ".", "equals", "(", "\"\"", ")", ")", "{", "if", "(", "intent", ".", "hasExtra", "(", "\"array\"", ")", ")", "{", "int", "[", "]", "array", "=", "intent", ".", "getIntArrayExtra", "(", "\"array\"", ")", ";", "Application", ".", "updateAppMode", "(", "context", ",", "array", ")", ";", "}", "else", "if", "(", "intent", ".", "hasExtra", "(", "\"buffer\"", ")", ")", "{", "byte", "[", "]", "buffer", "=", "intent", ".", "getByteArrayExtra", "(", "\"buffer\"", ")", ";", "Application", ".", "updateAppMode", "(", "context", ",", "buffer", ")", ";", "}", "return", ";", "}", "if", "(", "action", ".", "equals", "(", "\"\"", ")", ")", "{", "Application", ".", "startAppMode", "(", ")", ";", "return", ";", "}", "if", "(", "action", ".", "equals", "(", "\"\"", ")", ")", "{", "Application", ".", "startAppMode", "(", ")", ";", "return", ";", "}", "if", "(", "action", ".", "equals", "(", "\"\"", ")", ")", "{", "Bundle", "bundle", "=", "intent", ".", "getExtras", "(", ")", ";", "if", "(", "bundle", ".", "containsKey", "(", "\"buttons\"", ")", ")", "{", "Idle", ".", "overridenButtons", "=", "bundle", ".", "getByteArray", "(", "\"buttons\"", ")", ";", "}", "else", "{", "Idle", ".", "overridenButtons", "=", "null", ";", "}", "return", ";", "}", "if", "(", "action", ".", "equals", "(", "\"\"", ")", ")", "{", "if", "(", "intent", ".", "hasExtra", "(", "\"array\"", ")", ")", "{", "int", "[", "]", "array", "=", "intent", ".", "getIntArrayExtra", "(", "\"array\"", ")", ";", "VibratePattern", "vibrate", "=", "null", ";", "if", "(", "intent", ".", "hasExtra", "(", "\"vibrate_on\"", ")", "&&", "intent", ".", "hasExtra", "(", "\"vibrate_off\"", ")", "&&", "intent", ".", "hasExtra", "(", "\"\"", ")", ")", "{", "int", "vibrateOn", "=", "intent", ".", "getIntExtra", "(", "\"vibrate_on\"", ",", "500", ")", ";", "int", "vibrateOff", "=", "intent", ".", "getIntExtra", "(", "\"vibrate_off\"", ",", "500", ")", ";", "int", "vibrateCycles", "=", "intent", ".", "getIntExtra", "(", "\"\"", ",", "3", ")", ";", "vibrate", "=", "new", "VibratePattern", "(", "true", ",", "vibrateOn", ",", "vibrateOff", ",", "vibrateCycles", ")", ";", "}", "Notification", ".", "addArrayNotification", "(", "context", ",", "array", ",", "vibrate", ")", ";", "}", "else", "if", "(", "intent", ".", "hasExtra", "(", "\"buffer\"", ")", ")", "{", "byte", "[", "]", "buffer", "=", "intent", ".", "getByteArrayExtra", "(", "\"buffer\"", ")", ";", "VibratePattern", "vibrate", "=", "null", ";", "if", "(", "intent", ".", "hasExtra", "(", "\"vibrate_on\"", ")", "&&", "intent", ".", "hasExtra", "(", "\"vibrate_off\"", ")", "&&", "intent", ".", "hasExtra", "(", "\"\"", ")", ")", "{", "int", "vibrateOn", "=", "intent", ".", "getIntExtra", "(", "\"vibrate_on\"", ",", "500", ")", ";", "int", "vibrateOff", "=", "intent", ".", "getIntExtra", "(", "\"vibrate_off\"", ",", "500", ")", ";", "int", "vibrateCycles", "=", "intent", ".", "getIntExtra", "(", "\"\"", ",", "3", ")", ";", "vibrate", "=", "new", "VibratePattern", "(", "true", ",", "vibrateOn", ",", "vibrateOff", ",", "vibrateCycles", ")", ";", "}", "Notification", ".", "addBufferNotification", "(", "context", ",", "buffer", ",", "vibrate", ")", ";", "}", "return", ";", "}", "}", "}", "</s>" ]
8,205
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "org", ".", "metawatch", ".", "manager", ".", "MetaWatchService", ".", "Preferences", ";", "import", "android", ".", "app", ".", "Activity", ";", "import", "android", ".", "app", ".", "AlertDialog", ";", "import", "android", ".", "content", ".", "DialogInterface", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "view", ".", "Menu", ";", "import", "android", ".", "view", ".", "MenuInflater", ";", "import", "android", ".", "view", ".", "MenuItem", ";", "import", "android", ".", "webkit", ".", "WebView", ";", "public", "class", "MetaWatch", "extends", "Activity", "{", "public", "static", "final", "String", "TAG", "=", "\"MetaWatch\"", ";", "@", "Override", "public", "void", "onCreate", "(", "Bundle", "savedInstanceState", ")", "{", "super", ".", "onCreate", "(", "savedInstanceState", ")", ";", "setContentView", "(", "R", ".", "layout", ".", "main", ")", ";", "setTitle", "(", "getString", "(", "R", ".", "string", ".", "app_name", ")", ")", ";", "}", "@", "Override", "public", "boolean", "onCreateOptionsMenu", "(", "Menu", "menu", ")", "{", "MenuInflater", "inflater", "=", "getMenuInflater", "(", ")", ";", "inflater", ".", "inflate", "(", "R", ".", "menu", ".", "menu", ",", "menu", ")", ";", "return", "true", ";", "}", "@", "Override", "protected", "void", "onStart", "(", ")", "{", "super", ".", "onStart", "(", ")", ";", "MetaWatchService", ".", "loadPreferences", "(", "this", ")", ";", "if", "(", "Preferences", ".", "idleMusicControls", ")", "Protocol", ".", "enableMediaButtons", "(", ")", ";", "if", "(", "Preferences", ".", "idleReplay", ")", "Protocol", ".", "enableReplayButton", "(", ")", ";", "Protocol", ".", "configureMode", "(", ")", ";", "}", "@", "Override", "public", "boolean", "onOptionsItemSelected", "(", "MenuItem", "item", ")", "{", "switch", "(", "item", ".", "getItemId", "(", ")", ")", "{", "case", "R", ".", "id", ".", "start", ":", "startService", "(", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "stop", ":", "stopService", "(", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "test", ":", "startActivity", "(", "new", "Intent", "(", "this", ",", "Test", ".", "class", ")", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "settings", ":", "startActivity", "(", "new", "Intent", "(", "this", ",", "Settings", ".", "class", ")", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "about", ":", "showAbout", "(", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "exit", ":", "exit", "(", ")", ";", "return", "true", ";", "default", ":", "return", "super", ".", "onOptionsItemSelected", "(", "item", ")", ";", "}", "}", "void", "startService", "(", ")", "{", "startService", "(", "new", "Intent", "(", "this", ",", "MetaWatchService", ".", "class", ")", ")", ";", "}", "void", "stopService", "(", ")", "{", "stopService", "(", "new", "Intent", "(", "this", ",", "MetaWatchService", ".", "class", ")", ")", ";", "}", "void", "exit", "(", ")", "{", "System", ".", "exit", "(", "0", ")", ";", "}", "void", "showAbout", "(", ")", "{", "WebView", "webView", "=", "new", "WebView", "(", "this", ")", ";", "String", "html", "=", "\"\"", "+", "\"\"", "+", "\"<p>Version", "\"", "+", "Utils", ".", "getVersion", "(", "this", ")", "+", "\".</p>\"", "+", "\"\"", "+", "\"\"", ";", "webView", ".", "loadData", "(", "html", ",", "\"text/html\"", ",", "\"utf-8\"", ")", ";", "new", "AlertDialog", ".", "Builder", "(", "this", ")", ".", "setView", "(", "webView", ")", ".", "setCancelable", "(", "true", ")", ".", "setPositiveButton", "(", "\"OK\"", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "which", ")", "{", "dialog", ".", "dismiss", "(", ")", ";", "}", "}", ")", ".", "show", "(", ")", ";", "}", "}", "</s>" ]
8,206
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "graphics", ".", "Bitmap", ";", "public", "class", "Application", "{", "public", "static", "void", "startAppMode", "(", ")", "{", "MetaWatchService", ".", "WatchModes", ".", "APPLICATION", "=", "true", ";", "}", "public", "static", "void", "stopAppMode", "(", "Context", "context", ")", "{", "exitApp", "(", "context", ")", ";", "}", "public", "static", "void", "updateAppMode", "(", "Context", "context", ")", "{", "MetaWatchService", ".", "WatchModes", ".", "APPLICATION", "=", "true", ";", "if", "(", "MetaWatchService", ".", "WatchModes", ".", "APPLICATION", "==", "true", ")", "{", "if", "(", "MetaWatchService", ".", "watchState", "<", "MetaWatchService", ".", "WatchStates", ".", "APPLICATION", ")", "MetaWatchService", ".", "watchState", "=", "MetaWatchService", ".", "WatchStates", ".", "APPLICATION", ";", "if", "(", "MetaWatchService", ".", "watchState", "==", "MetaWatchService", ".", "WatchStates", ".", "APPLICATION", ")", "{", "Bitmap", "bitmap", "=", "Protocol", ".", "createTextBitmap", "(", "context", ",", "\"\"", ")", ";", "Protocol", ".", "sendLcdBitmap", "(", "bitmap", ",", "MetaWatchService", ".", "WatchBuffers", ".", "APPLICATION", ")", ";", "Protocol", ".", "updateDisplay", "(", "MetaWatchService", ".", "WatchBuffers", ".", "APPLICATION", ")", ";", "}", "}", "}", "public", "static", "void", "updateAppMode", "(", "Context", "context", ",", "Bitmap", "bitmap", ")", "{", "MetaWatchService", ".", "WatchModes", ".", "APPLICATION", "=", "true", ";", "if", "(", "MetaWatchService", ".", "WatchModes", ".", "APPLICATION", "==", "true", ")", "{", "if", "(", "MetaWatchService", ".", "watchState", "<", "MetaWatchService", ".", "WatchStates", ".", "APPLICATION", ")", "MetaWatchService", ".", "watchState", "=", "MetaWatchService", ".", "WatchStates", ".", "APPLICATION", ";", "if", "(", "MetaWatchService", ".", "watchState", "==", "MetaWatchService", ".", "WatchStates", ".", "APPLICATION", ")", "{", "Protocol", ".", "sendLcdBitmap", "(", "bitmap", ",", "MetaWatchService", ".", "WatchBuffers", ".", "APPLICATION", ")", ";", "Protocol", ".", "updateDisplay", "(", "MetaWatchService", ".", "WatchBuffers", ".", "APPLICATION", ")", ";", "}", "}", "}", "public", "static", "void", "updateAppMode", "(", "Context", "context", ",", "int", "[", "]", "array", ")", "{", "MetaWatchService", ".", "WatchModes", ".", "APPLICATION", "=", "true", ";", "if", "(", "MetaWatchService", ".", "WatchModes", ".", "APPLICATION", "==", "true", ")", "{", "if", "(", "MetaWatchService", ".", "watchState", "<", "MetaWatchService", ".", "WatchStates", ".", "APPLICATION", ")", "MetaWatchService", ".", "watchState", "=", "MetaWatchService", ".", "WatchStates", ".", "APPLICATION", ";", "if", "(", "MetaWatchService", ".", "watchState", "==", "MetaWatchService", ".", "WatchStates", ".", "APPLICATION", ")", "{", "Protocol", ".", "sendLcdArray", "(", "array", ",", "MetaWatchService", ".", "WatchBuffers", ".", "APPLICATION", ")", ";", "Protocol", ".", "updateDisplay", "(", "MetaWatchService", ".", "WatchBuffers", ".", "APPLICATION", ")", ";", "}", "}", "}", "public", "static", "void", "updateAppMode", "(", "Context", "context", ",", "byte", "[", "]", "buffer", ")", "{", "MetaWatchService", ".", "WatchModes", ".", "APPLICATION", "=", "true", ";", "if", "(", "MetaWatchService", ".", "WatchModes", ".", "APPLICATION", "==", "true", ")", "{", "if", "(", "MetaWatchService", ".", "watchState", "<", "MetaWatchService", ".", "WatchStates", ".", "APPLICATION", ")", "MetaWatchService", ".", "watchState", "=", "MetaWatchService", ".", "WatchStates", ".", "APPLICATION", ";", "if", "(", "MetaWatchService", ".", "watchState", "==", "MetaWatchService", ".", "WatchStates", ".", "APPLICATION", ")", "{", "Protocol", ".", "sendLcdBuffer", "(", "buffer", ",", "MetaWatchService", ".", "WatchBuffers", ".", "APPLICATION", ")", ";", "Protocol", ".", "updateDisplay", "(", "MetaWatchService", ".", "WatchBuffers", ".", "APPLICATION", ")", ";", "}", "}", "}", "public", "static", "void", "toApp", "(", ")", "{", "MetaWatchService", ".", "watchState", "=", "MetaWatchService", ".", "WatchStates", ".", "APPLICATION", ";", "Protocol", ".", "updateDisplay", "(", "MetaWatchService", ".", "WatchBuffers", ".", "APPLICATION", ")", ";", "}", "public", "static", "void", "exitApp", "(", "Context", "context", ")", "{", "MetaWatchService", ".", "WatchModes", ".", "APPLICATION", "=", "false", ";", "if", "(", "MetaWatchService", ".", "WatchModes", ".", "IDLE", "==", "true", ")", "{", "Idle", ".", "toIdle", "(", "context", ")", ";", "}", "}", "}", "</s>" ]
8,207
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "android", ".", "app", ".", "Activity", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "graphics", ".", "BitmapFactory", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "util", ".", "Log", ";", "public", "class", "ImageViewer", "extends", "Activity", "{", "@", "Override", "protected", "void", "onCreate", "(", "Bundle", "savedInstanceState", ")", "{", "super", ".", "onCreate", "(", "savedInstanceState", ")", ";", "Intent", "i", "=", "getIntent", "(", ")", ";", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"action:", "\"", "+", "i", ".", "getAction", "(", ")", ")", ";", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"data:", "\"", "+", "i", ".", "getData", "(", ")", ".", "getPath", "(", ")", ")", ";", "Application", ".", "updateAppMode", "(", "this", ",", "BitmapFactory", ".", "decodeFile", "(", "i", ".", "getData", "(", ")", ".", "getPath", "(", ")", ")", ")", ";", "finish", "(", ")", ";", "}", "}", "</s>" ]
8,208
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "org", ".", "metawatch", ".", "manager", ".", "MetaWatchService", ".", "Preferences", ";", "import", "org", ".", "metawatch", ".", "manager", ".", "MetaWatchService", ".", "WatchType", ";", "import", "org", ".", "metawatch", ".", "manager", ".", "Notification", ".", "VibratePattern", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "graphics", ".", "Bitmap", ";", "import", "android", ".", "graphics", ".", "Canvas", ";", "import", "android", ".", "graphics", ".", "Color", ";", "import", "android", ".", "graphics", ".", "Paint", ";", "import", "android", ".", "graphics", ".", "Typeface", ";", "public", "class", "NotificationBuilder", "{", "public", "static", "final", "class", "FontSize", "{", "public", "static", "final", "int", "SMALL", "=", "1", ";", "public", "static", "final", "int", "MEDIUM", "=", "2", ";", "public", "static", "final", "int", "LARGE", "=", "3", ";", "}", "public", "static", "void", "createSMS", "(", "Context", "context", ",", "String", "number", ",", "String", "text", ")", "{", "String", "name", "=", "Utils", ".", "getContactNameFromNumber", "(", "context", ",", "number", ")", ";", "if", "(", "MetaWatchService", ".", "watchType", "==", "WatchType", ".", "DIGITAL", ")", "{", "Bitmap", "bitmap", "=", "smartLines", "(", "context", ",", "\"message.bmp\"", ",", "new", "String", "[", "]", "{", "\"SMS", "from\"", ",", "name", "}", ")", ";", "Notification", ".", "addBitmapNotification", "(", "context", ",", "bitmap", ",", "new", "VibratePattern", "(", "true", ",", "500", ",", "500", ",", "3", ")", ",", "4000", ")", ";", "Notification", ".", "addTextNotification", "(", "context", ",", "text", ",", "new", "VibratePattern", "(", "false", ",", "0", ",", "0", ",", "0", ")", ",", "Notification", ".", "notificationTimeout", ")", ";", "}", "else", "{", "byte", "[", "]", "scroll", "=", "new", "byte", "[", "800", "]", ";", "int", "len", "=", "Protocol", ".", "createOled2linesLong", "(", "context", ",", "text", ",", "scroll", ")", ";", "Notification", ".", "addOledNotification", "(", "context", ",", "Protocol", ".", "createOled1line", "(", "context", ",", "\"message.bmp\"", ",", "\"SMS", "from\"", ")", ",", "Protocol", ".", "createOled2lines", "(", "context", ",", "name", ",", "text", ")", ",", "scroll", ",", "len", ",", "new", "VibratePattern", "(", "true", ",", "500", ",", "500", ",", "3", ")", ")", ";", "}", "}", "public", "static", "void", "createK9", "(", "Context", "context", ",", "String", "sender", ",", "String", "subject", ")", "{", "if", "(", "MetaWatchService", ".", "watchType", "==", "WatchType", ".", "DIGITAL", ")", "{", "Bitmap", "bitmap", "=", "smartLines", "(", "context", ",", "\"email.bmp\"", ",", "new", "String", "[", "]", "{", "\"K9", "mail", "from\"", ",", "sender", ",", "subject", "}", ")", ";", "Notification", ".", "addBitmapNotification", "(", "context", ",", "bitmap", ",", "new", "VibratePattern", "(", "true", ",", "500", ",", "500", ",", "3", ")", ",", "Notification", ".", "notificationTimeout", ")", ";", "}", "else", "{", "Notification", ".", "addOledNotification", "(", "context", ",", "Protocol", ".", "createOled1line", "(", "context", ",", "\"email.bmp\"", ",", "\"K9", "mail", "from\"", ")", ",", "Protocol", ".", "createOled2lines", "(", "context", ",", "sender", ",", "subject", ")", ",", "null", ",", "0", ",", "new", "VibratePattern", "(", "true", ",", "500", ",", "500", ",", "3", ")", ")", ";", "}", "}", "public", "static", "void", "createGmail", "(", "Context", "context", ",", "String", "sender", ",", "String", "email", ",", "String", "subject", ",", "String", "snippet", ")", "{", "if", "(", "MetaWatchService", ".", "watchType", "==", "WatchType", ".", "DIGITAL", ")", "{", "Bitmap", "bitmap", "=", "smartLines", "(", "context", ",", "\"email.bmp\"", ",", "new", "String", "[", "]", "{", "\"Gmail", "from\"", ",", "sender", ",", "email", ",", "subject", "}", ")", ";", "Notification", ".", "addBitmapNotification", "(", "context", ",", "bitmap", ",", "new", "VibratePattern", "(", "true", ",", "500", ",", "500", ",", "3", ")", ",", "Notification", ".", "notificationTimeout", ")", ";", "Notification", ".", "addTextNotification", "(", "context", ",", "snippet", ",", "new", "VibratePattern", "(", "false", ",", "0", ",", "0", ",", "0", ")", ",", "Notification", ".", "notificationTimeout", ")", ";", "}", "else", "{", "Notification", ".", "addOledNotification", "(", "context", ",", "Protocol", ".", "createOled2lines", "(", "context", ",", "\"Gmail", "from", "\"", "+", "sender", ",", "email", ")", ",", "Protocol", ".", "createOled2lines", "(", "context", ",", "subject", ",", "snippet", ")", ",", "null", ",", "0", ",", "new", "VibratePattern", "(", "true", ",", "500", ",", "500", ",", "3", ")", ")", ";", "}", "}", "public", "static", "void", "createGmailBlank", "(", "Context", "context", ",", "String", "recipient", ")", "{", "if", "(", "MetaWatchService", ".", "watchType", "==", "WatchType", ".", "DIGITAL", ")", "{", "Bitmap", "bitmap", "=", "smartLines", "(", "context", ",", "\"email.bmp\"", ",", "new", "String", "[", "]", "{", "\"Gmail", "for\"", ",", "recipient", "}", ")", ";", "Notification", ".", "addBitmapNotification", "(", "context", ",", "bitmap", ",", "new", "VibratePattern", "(", "true", ",", "500", ",", "500", ",", "3", ")", ",", "Notification", ".", "notificationTimeout", ")", ";", "}", "else", "{", "Notification", ".", "addOledNotification", "(", "context", ",", "Protocol", ".", "createOled1line", "(", "context", ",", "\"email.bmp\"", ",", "\"SMS", "for\"", ")", ",", "Protocol", ".", "createOled1line", "(", "context", ",", "null", ",", "recipient", ")", ",", "null", ",", "0", ",", "new", "VibratePattern", "(", "true", ",", "500", ",", "500", ",", "3", ")", ")", ";", "}", "}", "public", "static", "void", "createAlarm", "(", "Context", "context", ")", "{", "if", "(", "MetaWatchService", ".", "watchType", "==", "WatchType", ".", "DIGITAL", ")", "{", "Bitmap", "bitmap", "=", "smartLines", "(", "context", ",", "\"timer.bmp\"", ",", "new", "String", "[", "]", "{", "\"Alarm", "Clock\"", "}", ")", ";", "Notification", ".", "addBitmapNotification", "(", "context", ",", "bitmap", ",", "new", "VibratePattern", "(", "true", ",", "500", ",", "500", ",", "3", ")", ",", "Notification", ".", "notificationTimeout", ")", ";", "}", "else", "{", "Notification", ".", "addOledNotification", "(", "context", ",", "Protocol", ".", "createOled1line", "(", "context", ",", "\"timer.bmp\"", ",", "\"Alarm", "clock\"", ")", ",", "Protocol", ".", "createOled1line", "(", "context", ",", "null", ",", "\"Alarm\"", ")", ",", "null", ",", "0", ",", "new", "VibratePattern", "(", "true", ",", "500", ",", "500", ",", "3", ")", ")", ";", "}", "}", "public", "static", "void", "createMusic", "(", "Context", "context", ",", "String", "artist", ",", "String", "track", ")", "{", "if", "(", "MetaWatchService", ".", "watchType", "==", "WatchType", ".", "DIGITAL", ")", "{", "Bitmap", "bitmap", "=", "smartLines", "(", "context", ",", "\"play.bmp\"", ",", "new", "String", "[", "]", "{", "track", ",", "artist", "}", ")", ";", "Notification", ".", "addBitmapNotification", "(", "context", ",", "bitmap", ",", "new", "VibratePattern", "(", "true", ",", "150", ",", "0", ",", "1", ")", ",", "Notification", ".", "notificationTimeout", ")", ";", "}", "else", "{", "Notification", ".", "addOledNotification", "(", "context", ",", "Protocol", ".", "createOled1line", "(", "context", ",", "\"play.bmp\"", ",", "artist", ")", ",", "Protocol", ".", "createOled1line", "(", "context", ",", "null", ",", "track", ")", ",", "null", ",", "0", ",", "new", "VibratePattern", "(", "true", ",", "500", ",", "500", ",", "3", ")", ")", ";", "}", "}", "static", "Bitmap", "smartLines", "(", "Context", "context", ",", "String", "iconPath", ",", "String", "[", "]", "lines", ")", "{", "String", "font", "=", "null", ";", "int", "size", "=", "8", ";", "int", "realSize", "=", "7", ";", "switch", "(", "Preferences", ".", "fontSize", ")", "{", "case", "FontSize", ".", "SMALL", ":", "font", "=", "\"\"", ";", "realSize", "=", "5", ";", "break", ";", "case", "FontSize", ".", "MEDIUM", ":", "font", "=", "\"\"", ";", "realSize", "=", "7", ";", "break", ";", "case", "FontSize", ".", "LARGE", ":", "font", "=", "\"\"", ";", "realSize", "=", "11", ";", "size", "=", "16", ";", "break", ";", "}", "Bitmap", "bitmap", "=", "Bitmap", ".", "createBitmap", "(", "96", ",", "96", ",", "Bitmap", ".", "Config", ".", "RGB_565", ")", ";", "Canvas", "canvas", "=", "new", "Canvas", "(", "bitmap", ")", ";", "Paint", "paint", "=", "new", "Paint", "(", ")", ";", "paint", ".", "setColor", "(", "Color", ".", "BLACK", ")", ";", "paint", ".", "setTextSize", "(", "size", ")", ";", "Typeface", "typeface", "=", "Typeface", ".", "createFromAsset", "(", "context", ".", "getAssets", "(", ")", ",", "font", ")", ";", "paint", ".", "setTypeface", "(", "typeface", ")", ";", "canvas", ".", "drawColor", "(", "Color", ".", "WHITE", ")", ";", "Bitmap", "icon", "=", "Utils", ".", "loadBitmapFromAssets", "(", "context", ",", "iconPath", ")", ";", "int", "spaceForItem", "=", "96", "/", "(", "1", "+", "lines", ".", "length", ")", ";", "canvas", ".", "drawBitmap", "(", "icon", ",", "96", "/", "2", "-", "icon", ".", "getWidth", "(", ")", "/", "2", ",", "spaceForItem", "/", "2", "-", "icon", ".", "getHeight", "(", ")", "/", "2", ",", "paint", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "lines", ".", "length", ";", "i", "++", ")", "{", "int", "x", "=", "(", "int", ")", "(", "96", "/", "2", "-", "paint", ".", "measureText", "(", "lines", "[", "i", "]", ")", "/", "2", ")", ";", "if", "(", "x", "<", "0", ")", "x", "=", "0", ";", "int", "y", "=", "spaceForItem", "*", "(", "i", "+", "1", ")", "+", "spaceForItem", "/", "2", "+", "realSize", "/", "2", ";", "canvas", ".", "drawText", "(", "lines", "[", "i", "]", ",", "x", ",", "y", ",", "paint", ")", ";", "}", "return", "bitmap", ";", "}", "}", "</s>" ]
8,209
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "org", ".", "metawatch", ".", "manager", ".", "MetaWatchService", ".", "WatchType", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "graphics", ".", "Bitmap", ";", "import", "android", ".", "util", ".", "Log", ";", "public", "class", "Notification", "{", "static", "NotificationType", "lastNotification", "=", "null", ";", "public", "static", "ArrayList", "<", "NotificationType", ">", "notificationQueue", "=", "new", "ArrayList", "<", "Notification", ".", "NotificationType", ">", "(", ")", ";", "public", "static", "boolean", "isSending", "=", "false", ";", "public", "static", "final", "int", "notificationTimeout", "=", "5000", ";", "public", "static", "Object", "scrollRequest", "=", "new", "Object", "(", ")", ";", "public", "static", "class", "NotificationType", "{", "Bitmap", "bitmap", ";", "int", "[", "]", "array", ";", "byte", "[", "]", "buffer", ";", "byte", "[", "]", "oledTop", ";", "byte", "[", "]", "oledBottom", ";", "byte", "[", "]", "oledScroll", ";", "int", "scrollLength", ";", "int", "timeout", ";", "VibratePattern", "vibratePattern", ";", "}", "public", "static", "class", "VibratePattern", "{", "boolean", "vibrate", "=", "false", ";", "int", "on", ";", "int", "off", ";", "int", "cycles", ";", "public", "VibratePattern", "(", "boolean", "vibrate", ",", "int", "on", ",", "int", "off", ",", "int", "cycles", ")", "{", "this", ".", "vibrate", "=", "vibrate", ";", "this", ".", "on", "=", "on", ";", "this", ".", "off", "=", "off", ";", "this", ".", "cycles", "=", "cycles", ";", "}", "}", "public", "static", "void", "processNotificationQueue", "(", "final", "Context", "context", ")", "{", "if", "(", "isSending", ")", "return", ";", "else", "isSending", "=", "true", ";", "Thread", "thread", "=", "new", "Thread", "(", ")", "{", "public", "void", "run", "(", ")", "{", "if", "(", "notificationQueue", ".", "size", "(", ")", ">", "0", ")", "{", "MetaWatchService", ".", "watchState", "=", "MetaWatchService", ".", "WatchStates", ".", "NOTIFICATION", ";", "MetaWatchService", ".", "WatchModes", ".", "NOTIFICATION", "=", "true", ";", "}", "while", "(", "notificationQueue", ".", "size", "(", ")", ">", "0", ")", "{", "NotificationType", "notification", "=", "notificationQueue", ".", "get", "(", "0", ")", ";", "if", "(", "MetaWatchService", ".", "watchType", "==", "WatchType", ".", "DIGITAL", ")", "{", "if", "(", "notification", ".", "bitmap", "!=", "null", ")", "Protocol", ".", "sendLcdBitmap", "(", "notification", ".", "bitmap", ",", "MetaWatchService", ".", "WatchBuffers", ".", "NOTIFICATION", ")", ";", "else", "if", "(", "notification", ".", "array", "!=", "null", ")", "Protocol", ".", "sendLcdArray", "(", "notification", ".", "array", ",", "MetaWatchService", ".", "WatchBuffers", ".", "NOTIFICATION", ")", ";", "else", "if", "(", "notification", ".", "buffer", "!=", "null", ")", "Protocol", ".", "sendLcdBuffer", "(", "notification", ".", "buffer", ",", "MetaWatchService", ".", "WatchBuffers", ".", "NOTIFICATION", ")", ";", "Protocol", ".", "updateDisplay", "(", "2", ")", ";", "if", "(", "notification", ".", "vibratePattern", ".", "vibrate", ")", "Protocol", ".", "vibrate", "(", "notification", ".", "vibratePattern", ".", "on", ",", "notification", ".", "vibratePattern", ".", "off", ",", "notification", ".", "vibratePattern", ".", "cycles", ")", ";", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"\"", ")", ";", "}", "else", "{", "Protocol", ".", "sendOledDisplay", "(", "notification", ".", "oledTop", ",", "true", ",", "false", ")", ";", "Protocol", ".", "sendOledDisplay", "(", "notification", ".", "oledBottom", ",", "false", ",", "false", ")", ";", "if", "(", "notification", ".", "vibratePattern", ".", "vibrate", ")", "Protocol", ".", "vibrate", "(", "notification", ".", "vibratePattern", ".", "on", ",", "notification", ".", "vibratePattern", ".", "off", ",", "notification", ".", "vibratePattern", ".", "cycles", ")", ";", "if", "(", "notification", ".", "oledScroll", "!=", "null", ")", "{", "if", "(", "notification", ".", "scrollLength", "<", "1", ")", "return", ";", "if", "(", "notification", ".", "scrollLength", ">=", "240", ")", "{", "Protocol", ".", "sendOledBufferPart", "(", "notification", ".", "oledScroll", ",", "0", ",", "240", ",", "true", ",", "false", ")", ";", "for", "(", "int", "i", "=", "240", ";", "i", "<", "notification", ".", "scrollLength", ";", "i", "+=", "80", ")", "{", "try", "{", "synchronized", "(", "Notification", ".", "scrollRequest", ")", "{", "Notification", ".", "scrollRequest", ".", "wait", "(", "60000", ")", ";", "}", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "if", "(", "i", "+", "80", ">=", "notification", ".", "scrollLength", ")", "Protocol", ".", "sendOledBufferPart", "(", "notification", ".", "oledScroll", ",", "i", ",", "80", ",", "false", ",", "true", ")", ";", "else", "Protocol", ".", "sendOledBufferPart", "(", "notification", ".", "oledScroll", ",", "i", ",", "80", ",", "false", ",", "false", ")", ";", "}", "try", "{", "synchronized", "(", "Notification", ".", "scrollRequest", ")", "{", "Notification", ".", "scrollRequest", ".", "wait", "(", "60000", ")", ";", "}", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "}", "else", "{", "int", "len", "=", "notification", ".", "scrollLength", "/", "20", "+", "1", ";", "Protocol", ".", "sendOledBufferPart", "(", "notification", ".", "oledScroll", ",", "0", ",", "len", "*", "20", ",", "true", ",", "true", ")", ";", "}", "}", "}", "MetaWatchService", ".", "nap", "(", "notification", ".", "timeout", ")", ";", "if", "(", "MetaWatchService", ".", "WatchModes", ".", "CALL", "==", "true", ")", "{", "isSending", "=", "false", ";", "return", ";", "}", "notificationQueue", ".", "remove", "(", "0", ")", ";", "}", "isSending", "=", "false", ";", "exitNotification", "(", "context", ")", ";", "}", "}", ";", "thread", ".", "start", "(", ")", ";", "}", "public", "static", "void", "addTextNotification", "(", "Context", "context", ",", "String", "text", ",", "VibratePattern", "vibratePattern", ",", "int", "timeout", ")", "{", "NotificationType", "notification", "=", "new", "NotificationType", "(", ")", ";", "notification", ".", "bitmap", "=", "Protocol", ".", "createTextBitmap", "(", "context", ",", "text", ")", ";", "notification", ".", "timeout", "=", "timeout", ";", "if", "(", "vibratePattern", "==", "null", ")", "notification", ".", "vibratePattern", "=", "new", "VibratePattern", "(", "false", ",", "0", ",", "0", ",", "0", ")", ";", "else", "notification", ".", "vibratePattern", "=", "vibratePattern", ";", "notificationQueue", ".", "add", "(", "notification", ")", ";", "lastNotification", "=", "notification", ";", "processNotificationQueue", "(", "context", ")", ";", "}", "public", "static", "void", "addBitmapNotification", "(", "Context", "context", ",", "Bitmap", "bitmap", ",", "VibratePattern", "vibratePattern", ",", "int", "timeout", ")", "{", "NotificationType", "notification", "=", "new", "NotificationType", "(", ")", ";", "notification", ".", "bitmap", "=", "bitmap", ";", "notification", ".", "timeout", "=", "timeout", ";", "if", "(", "vibratePattern", "==", "null", ")", "notification", ".", "vibratePattern", "=", "new", "VibratePattern", "(", "false", ",", "0", ",", "0", ",", "0", ")", ";", "else", "notification", ".", "vibratePattern", "=", "vibratePattern", ";", "notificationQueue", ".", "add", "(", "notification", ")", ";", "lastNotification", "=", "notification", ";", "processNotificationQueue", "(", "context", ")", ";", "}", "public", "static", "void", "addArrayNotification", "(", "Context", "context", ",", "int", "[", "]", "array", ",", "VibratePattern", "vibratePattern", ")", "{", "NotificationType", "notification", "=", "new", "NotificationType", "(", ")", ";", "notification", ".", "array", "=", "array", ";", "notification", ".", "timeout", "=", "notificationTimeout", ";", "if", "(", "vibratePattern", "==", "null", ")", "notification", ".", "vibratePattern", "=", "new", "VibratePattern", "(", "false", ",", "0", ",", "0", ",", "0", ")", ";", "else", "notification", ".", "vibratePattern", "=", "vibratePattern", ";", "notificationQueue", ".", "add", "(", "notification", ")", ";", "lastNotification", "=", "notification", ";", "processNotificationQueue", "(", "context", ")", ";", "}", "public", "static", "void", "addBufferNotification", "(", "Context", "context", ",", "byte", "[", "]", "buffer", ",", "VibratePattern", "vibratePattern", ")", "{", "NotificationType", "notification", "=", "new", "NotificationType", "(", ")", ";", "notification", ".", "buffer", "=", "buffer", ";", "notification", ".", "timeout", "=", "notificationTimeout", ";", "if", "(", "vibratePattern", "==", "null", ")", "notification", ".", "vibratePattern", "=", "new", "VibratePattern", "(", "false", ",", "0", ",", "0", ",", "0", ")", ";", "else", "notification", ".", "vibratePattern", "=", "vibratePattern", ";", "notificationQueue", ".", "add", "(", "notification", ")", ";", "lastNotification", "=", "notification", ";", "processNotificationQueue", "(", "context", ")", ";", "}", "public", "static", "void", "addOledNotification", "(", "Context", "context", ",", "byte", "[", "]", "top", ",", "byte", "[", "]", "bottom", ",", "byte", "[", "]", "scroll", ",", "int", "scrollLength", ",", "VibratePattern", "vibratePattern", ")", "{", "NotificationType", "notification", "=", "new", "NotificationType", "(", ")", ";", "notification", ".", "oledTop", "=", "top", ";", "notification", ".", "oledBottom", "=", "bottom", ";", "notification", ".", "oledScroll", "=", "scroll", ";", "notification", ".", "scrollLength", "=", "scrollLength", ";", "notification", ".", "timeout", "=", "notificationTimeout", ";", "if", "(", "vibratePattern", "==", "null", ")", "notification", ".", "vibratePattern", "=", "new", "VibratePattern", "(", "false", ",", "0", ",", "0", ",", "0", ")", ";", "else", "notification", ".", "vibratePattern", "=", "vibratePattern", ";", "notificationQueue", ".", "add", "(", "notification", ")", ";", "lastNotification", "=", "notification", ";", "processNotificationQueue", "(", "context", ")", ";", "}", "public", "static", "void", "toNotification", "(", "Context", "context", ")", "{", "MetaWatchService", ".", "watchState", "=", "MetaWatchService", ".", "WatchStates", ".", "NOTIFICATION", ";", "MetaWatchService", ".", "WatchModes", ".", "NOTIFICATION", "=", "true", ";", "processNotificationQueue", "(", "context", ")", ";", "}", "public", "static", "void", "exitNotification", "(", "Context", "context", ")", "{", "MetaWatchService", ".", "WatchModes", ".", "NOTIFICATION", "=", "false", ";", "if", "(", "MetaWatchService", ".", "WatchModes", ".", "CALL", "==", "true", ")", "return", ";", "else", "if", "(", "MetaWatchService", ".", "WatchModes", ".", "APPLICATION", "==", "true", ")", "Application", ".", "toApp", "(", ")", ";", "else", "if", "(", "MetaWatchService", ".", "WatchModes", ".", "IDLE", "==", "true", ")", "Idle", ".", "toIdle", "(", "context", ")", ";", "}", "public", "static", "void", "replay", "(", "Context", "context", ")", "{", "if", "(", "lastNotification", "!=", "null", ")", "{", "lastNotification", ".", "vibratePattern", ".", "vibrate", "=", "false", ";", "notificationQueue", ".", "add", "(", "lastNotification", ")", ";", "toNotification", "(", "context", ")", ";", "}", "}", "}", "</s>" ]
8,210
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "org", ".", "metawatch", ".", "manager", ".", "Monitors", ".", "WeatherData", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "graphics", ".", "Bitmap", ";", "import", "android", ".", "graphics", ".", "Canvas", ";", "import", "android", ".", "graphics", ".", "Color", ";", "import", "android", ".", "graphics", ".", "Paint", ";", "import", "android", ".", "graphics", ".", "Typeface", ";", "import", "android", ".", "text", ".", "StaticLayout", ";", "import", "android", ".", "text", ".", "TextPaint", ";", "public", "class", "Idle", "{", "public", "static", "byte", "[", "]", "overridenButtons", "=", "null", ";", "static", "Bitmap", "createLcdIdle", "(", "Context", "context", ")", "{", "Bitmap", "bitmap", "=", "Bitmap", ".", "createBitmap", "(", "96", ",", "96", ",", "Bitmap", ".", "Config", ".", "RGB_565", ")", ";", "Canvas", "canvas", "=", "new", "Canvas", "(", "bitmap", ")", ";", "Paint", "paintSmall", "=", "new", "Paint", "(", ")", ";", "paintSmall", ".", "setColor", "(", "Color", ".", "BLACK", ")", ";", "paintSmall", ".", "setTextSize", "(", "8", ")", ";", "Typeface", "typefaceSmall", "=", "Typeface", ".", "createFromAsset", "(", "context", ".", "getAssets", "(", ")", ",", "\"\"", ")", ";", "paintSmall", ".", "setTypeface", "(", "typefaceSmall", ")", ";", "Paint", "paintLarge", "=", "new", "Paint", "(", ")", ";", "paintLarge", ".", "setColor", "(", "Color", ".", "BLACK", ")", ";", "paintLarge", ".", "setTextSize", "(", "16", ")", ";", "Typeface", "typefaceLarge", "=", "Typeface", ".", "createFromAsset", "(", "context", ".", "getAssets", "(", ")", ",", "\"\"", ")", ";", "paintLarge", ".", "setTypeface", "(", "typefaceLarge", ")", ";", "canvas", ".", "drawColor", "(", "Color", ".", "WHITE", ")", ";", "canvas", "=", "drawLine", "(", "canvas", ",", "32", ")", ";", "if", "(", "WeatherData", ".", "received", ")", "{", "canvas", ".", "save", "(", ")", ";", "TextPaint", "paint", "=", "new", "TextPaint", "(", "paintSmall", ")", ";", "StaticLayout", "layout", "=", "new", "StaticLayout", "(", "WeatherData", ".", "condition", ",", "paint", ",", "36", ",", "android", ".", "text", ".", "Layout", ".", "Alignment", ".", "ALIGN_NORMAL", ",", "1.3f", ",", "0", ",", "false", ")", ";", "canvas", ".", "translate", "(", "3", ",", "40", ")", ";", "layout", ".", "draw", "(", "canvas", ")", ";", "canvas", ".", "restore", "(", ")", ";", "Bitmap", "image", "=", "Utils", ".", "loadBitmapFromAssets", "(", "context", ",", "WeatherData", ".", "icon", ")", ";", "canvas", ".", "drawBitmap", "(", "image", ",", "37", ",", "35", ",", "null", ")", ";", "canvas", ".", "drawText", "(", "WeatherData", ".", "temp", ",", "64", ",", "46", ",", "paintLarge", ")", ";", "canvas", ".", "drawText", "(", "WeatherData", ".", "tempHigh", ",", "64", ",", "54", ",", "paintSmall", ")", ";", "canvas", ".", "drawText", "(", "WeatherData", ".", "tempLow", ",", "64", ",", "62", ",", "paintSmall", ")", ";", "canvas", ".", "drawText", "(", "WeatherData", ".", "city", ",", "3", ",", "62", ",", "paintSmall", ")", ";", "}", "else", "{", "canvas", ".", "drawText", "(", "\"no", "data\"", ",", "34", ",", "50", ",", "paintSmall", ")", ";", "}", "canvas", "=", "drawLine", "(", "canvas", ",", "64", ")", ";", "int", "rows", "=", "3", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "rows", ";", "i", "++", ")", "{", "int", "slotSpace", "=", "96", "/", "rows", ";", "int", "slotX", "=", "slotSpace", "/", "2", "-", "12", ";", "int", "iconX", "=", "slotSpace", "*", "i", "+", "slotX", ";", "switch", "(", "i", ")", "{", "case", "0", ":", "canvas", ".", "drawBitmap", "(", "Utils", ".", "loadBitmapFromAssets", "(", "context", ",", "\"\"", ")", ",", "iconX", ",", "67", ",", "null", ")", ";", "break", ";", "case", "1", ":", "canvas", ".", "drawBitmap", "(", "Utils", ".", "loadBitmapFromAssets", "(", "context", ",", "\"idle_sms.bmp\"", ")", ",", "iconX", ",", "67", ",", "null", ")", ";", "break", ";", "case", "2", ":", "canvas", ".", "drawBitmap", "(", "Utils", ".", "loadBitmapFromAssets", "(", "context", ",", "\"\"", ")", ",", "iconX", ",", "67", ",", "null", ")", ";", "break", ";", "}", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "rows", ";", "i", "++", ")", "{", "String", "count", "=", "\"\"", ";", "switch", "(", "i", ")", "{", "case", "0", ":", "count", "=", "Integer", ".", "toString", "(", "Utils", ".", "getMissedCallsCount", "(", "context", ")", ")", ";", "break", ";", "case", "1", ":", "count", "=", "Integer", ".", "toString", "(", "Utils", ".", "getUnreadSmsCount", "(", "context", ")", ")", ";", "break", ";", "case", "2", ":", "if", "(", "Utils", ".", "isGmailAccessSupported", "(", "context", ")", ")", "count", "=", "Integer", ".", "toString", "(", "Utils", ".", "getUnreadGmailCount", "(", "context", ",", "Utils", ".", "getGoogleAccountName", "(", "context", ")", ",", "\"^i\"", ")", ")", ";", "else", "count", "=", "Integer", ".", "toString", "(", "Monitors", ".", "getGmailUnreadCount", "(", ")", ")", ";", "break", ";", "}", "int", "slotSpace", "=", "96", "/", "rows", ";", "int", "slotX", "=", "(", "int", ")", "(", "slotSpace", "/", "2", "-", "paintSmall", ".", "measureText", "(", "count", ")", "/", "2", ")", ";", "int", "countX", "=", "slotSpace", "*", "i", "+", "slotX", ";", "canvas", ".", "drawText", "(", "count", ",", "countX", ",", "92", ",", "paintSmall", ")", ";", "}", "return", "bitmap", ";", "}", "public", "static", "Canvas", "drawLine", "(", "Canvas", "canvas", ",", "int", "y", ")", "{", "Paint", "paint", "=", "new", "Paint", "(", ")", ";", "paint", ".", "setColor", "(", "Color", ".", "BLACK", ")", ";", "int", "left", "=", "3", ";", "for", "(", "int", "i", "=", "0", "+", "left", ";", "i", "<", "96", "-", "left", ";", "i", "+=", "3", ")", "canvas", ".", "drawLine", "(", "i", ",", "y", ",", "i", "+", "2", ",", "y", ",", "paint", ")", ";", "return", "canvas", ";", "}", "public", "static", "void", "sendLcdIdle", "(", "Context", "context", ")", "{", "Bitmap", "bitmap", "=", "createLcdIdle", "(", "context", ")", ";", "Protocol", ".", "sendLcdBitmap", "(", "bitmap", ",", "MetaWatchService", ".", "WatchBuffers", ".", "IDLE", ")", ";", "Protocol", ".", "updateDisplay", "(", "0", ")", ";", "}", "public", "static", "boolean", "toIdle", "(", "Context", "context", ")", "{", "MetaWatchService", ".", "WatchModes", ".", "IDLE", "=", "true", ";", "MetaWatchService", ".", "watchState", "=", "MetaWatchService", ".", "WatchStates", ".", "IDLE", ";", "sendLcdIdle", "(", "context", ")", ";", "return", "true", ";", "}", "public", "static", "void", "updateLcdIdle", "(", "Context", "context", ")", "{", "if", "(", "MetaWatchService", ".", "watchState", "==", "MetaWatchService", ".", "WatchStates", ".", "IDLE", ")", "sendLcdIdle", "(", "context", ")", ";", "}", "public", "static", "boolean", "isIdleButtonOverriden", "(", "byte", "button", ")", "{", "if", "(", "overridenButtons", "!=", "null", ")", "for", "(", "int", "i", "=", "0", ";", "i", "<", "overridenButtons", ".", "length", ";", "i", "++", ")", "if", "(", "overridenButtons", "[", "i", "]", "==", "button", ")", "return", "true", ";", "return", "false", ";", "}", "}", "</s>" ]
8,211
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "metawatch", ".", "manager", ".", "MetaWatchService", ".", "Preferences", ";", "import", "android", ".", "accounts", ".", "Account", ";", "import", "android", ".", "accounts", ".", "AccountManager", ";", "import", "android", ".", "content", ".", "ContentResolver", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "database", ".", "ContentObserver", ";", "import", "android", ".", "database", ".", "Cursor", ";", "import", "android", ".", "net", ".", "Uri", ";", "import", "android", ".", "util", ".", "Log", ";", "public", "class", "GmailMonitor", "{", "Context", "context", ";", "MyContentObserver", "contentObserver", "=", "new", "MyContentObserver", "(", ")", ";", "ContentResolver", "contentResolver", ";", "public", "static", "String", "account", "=", "\"\"", ";", "public", "static", "int", "lastUnreadGmailCount", "=", "0", ";", "public", "GmailMonitor", "(", "Context", "ctx", ")", "{", "super", "(", ")", ";", "context", "=", "ctx", ";", "}", "public", "void", "startMonitor", "(", ")", "{", "try", "{", "AccountManager", "mgr", "=", "AccountManager", ".", "get", "(", "context", ")", ";", "Account", "[", "]", "accts", "=", "mgr", ".", "getAccounts", "(", ")", ";", "final", "int", "count", "=", "accts", ".", "length", ";", "Account", "acct", "=", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "count", ";", "i", "++", ")", "{", "acct", "=", "accts", "[", "i", "]", ";", "if", "(", "acct", ".", "type", ".", "equals", "(", "\"com.google\"", ")", ")", "{", "account", "=", "acct", ".", "name", ";", "break", ";", "}", "}", "Uri", "uri", "=", "Uri", ".", "parse", "(", "\"\"", "+", "account", ")", ";", "contentResolver", "=", "context", ".", "getContentResolver", "(", ")", ";", "contentResolver", ".", "registerContentObserver", "(", "uri", ",", "true", ",", "contentObserver", ")", ";", "}", "catch", "(", "Exception", "x", ")", "{", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "x", ".", "toString", "(", ")", ")", ";", "}", "}", "private", "class", "MyContentObserver", "extends", "ContentObserver", "{", "public", "MyContentObserver", "(", ")", "{", "super", "(", "null", ")", ";", "}", "@", "Override", "public", "void", "onChange", "(", "boolean", "selfChange", ")", "{", "super", ".", "onChange", "(", "selfChange", ")", ";", "Log", ".", "d", "(", "\"ow\"", ",", "\"\"", ")", ";", "if", "(", "Preferences", ".", "notifyGmail", ")", "{", "int", "currentGmailUnreadCount", "=", "getUnreadGmailCount", "(", "account", ",", "\"^u\"", ")", ";", "if", "(", "currentGmailUnreadCount", ">", "lastUnreadGmailCount", ")", "{", "Log", ".", "d", "(", "\"ow\"", ",", "Integer", ".", "toString", "(", "currentGmailUnreadCount", ")", "+", "\"", ">", "\"", "+", "Integer", ".", "toString", "(", "lastUnreadGmailCount", ")", ")", ";", "sendUnreadGmail", "(", "account", ")", ";", "}", "lastUnreadGmailCount", "=", "currentGmailUnreadCount", ";", "}", "}", "}", "public", "int", "getUnreadGmailCount", "(", "String", "account", ",", "String", "label", ")", "{", "try", "{", "int", "nameColumn", "=", "0", ";", "Cursor", "c", "=", "context", ".", "getContentResolver", "(", ")", ".", "query", "(", "Uri", ".", "parse", "(", "\"\"", "+", "account", ")", ",", "null", ",", "null", ",", "null", ",", "null", ")", ";", "c", ".", "moveToFirst", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "c", ".", "getColumnCount", "(", ")", ";", "i", "++", ")", "if", "(", "c", ".", "getColumnName", "(", "i", ")", ".", "equals", "(", "\"\"", ")", ")", "{", "nameColumn", "=", "i", ";", "break", ";", "}", "while", "(", "true", ")", "{", "if", "(", "c", ".", "getString", "(", "nameColumn", ")", ".", "equals", "(", "label", ")", ")", "for", "(", "int", "i", "=", "0", ";", "i", "<", "c", ".", "getColumnCount", "(", ")", ";", "i", "++", ")", "{", "if", "(", "c", ".", "getColumnName", "(", "i", ")", ".", "equals", "(", "\"\"", ")", ")", "{", "return", "Integer", ".", "parseInt", "(", "c", ".", "getString", "(", "i", ")", ")", ";", "}", "}", "c", ".", "moveToNext", "(", ")", ";", "if", "(", "c", ".", "isLast", "(", ")", ")", "{", "break", ";", "}", "}", "}", "catch", "(", "Exception", "x", ")", "{", "}", "return", "0", ";", "}", "void", "sendUnreadGmail", "(", "String", "account", ")", "{", "try", "{", "int", "nameColumn", "=", "0", ";", "String", "id", "=", "\"\"", ";", "String", "convId", "=", "\"\"", ";", "double", "maxDate", "=", "0", ";", "Cursor", "c", "=", "context", ".", "getContentResolver", "(", ")", ".", "query", "(", "Uri", ".", "parse", "(", "\"\"", "+", "account", ")", ",", "null", ",", "null", ",", "null", ",", "null", ")", ";", "c", ".", "moveToFirst", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "c", ".", "getColumnCount", "(", ")", ";", "i", "++", ")", "if", "(", "c", ".", "getColumnName", "(", "i", ")", ".", "equals", "(", "\"\"", ")", ")", "nameColumn", "=", "i", ";", "while", "(", "true", ")", "{", "if", "(", "c", ".", "getString", "(", "nameColumn", ")", ".", "equals", "(", "\"^u\"", ")", ")", "for", "(", "int", "i", "=", "0", ";", "i", "<", "c", ".", "getColumnCount", "(", ")", ";", "i", "++", ")", "{", "if", "(", "c", ".", "getColumnName", "(", "i", ")", ".", "equals", "(", "\"_id\"", ")", ")", "{", "id", "=", "c", ".", "getString", "(", "i", ")", ";", "}", "}", "if", "(", "c", ".", "isLast", "(", ")", ")", "break", ";", "c", ".", "moveToNext", "(", ")", ";", "}", "Cursor", "c2", "=", "context", ".", "getContentResolver", "(", ")", ".", "query", "(", "Uri", ".", "parse", "(", "\"\"", "+", "account", ")", ",", "null", ",", "null", ",", "null", ",", "null", ")", ";", "c2", ".", "moveToLast", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "c2", ".", "getColumnCount", "(", ")", ";", "i", "++", ")", "if", "(", "c2", ".", "getColumnName", "(", "i", ")", ".", "equals", "(", "\"labelIds\"", ")", ")", "nameColumn", "=", "i", ";", "while", "(", "true", ")", "{", "if", "(", "c2", ".", "getString", "(", "nameColumn", ")", ".", "indexOf", "(", "id", ")", ">=", "0", ")", "for", "(", "int", "i", "=", "0", ";", "i", "<", "c2", ".", "getColumnCount", "(", ")", ";", "i", "++", ")", "{", "if", "(", "c2", ".", "getColumnName", "(", "i", ")", ".", "equals", "(", "\"\"", ")", ")", "convId", "=", "c2", ".", "getString", "(", "i", ")", ";", "}", "if", "(", "c2", ".", "isFirst", "(", ")", ")", "break", ";", "c2", ".", "moveToPrevious", "(", ")", ";", "}", "maxDate", "=", "0", ";", "int", "colConvId", "=", "0", ";", "int", "colSub", "=", "0", ";", "int", "colFrom", "=", "0", ";", "int", "colRcv", "=", "0", ";", "String", "subject", "=", "\"\"", ";", "String", "sender", "=", "\"\"", ";", "String", "snippet", "=", "\"\"", ";", "Cursor", "c3", "=", "context", ".", "getContentResolver", "(", ")", ".", "query", "(", "Uri", ".", "parse", "(", "\"\"", "+", "account", "+", "\"/\"", "+", "convId", "+", "\"/messages\"", ")", ",", "null", ",", "null", ",", "null", ",", "null", ")", ";", "c3", ".", "moveToFirst", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "c3", ".", "getColumnCount", "(", ")", ";", "i", "++", ")", "{", "if", "(", "c3", ".", "getColumnName", "(", "i", ")", ".", "equals", "(", "\"conversation\"", ")", ")", "colConvId", "=", "i", ";", "if", "(", "c3", ".", "getColumnName", "(", "i", ")", ".", "equals", "(", "\"subject\"", ")", ")", "colSub", "=", "i", ";", "if", "(", "c3", ".", "getColumnName", "(", "i", ")", ".", "equals", "(", "\"fromAddress\"", ")", ")", "colFrom", "=", "i", ";", "if", "(", "c3", ".", "getColumnName", "(", "i", ")", ".", "equals", "(", "\"\"", ")", ")", "colRcv", "=", "i", ";", "}", "while", "(", "true", ")", "{", "if", "(", "c3", ".", "getString", "(", "colConvId", ")", ".", "indexOf", "(", "convId", ")", ">=", "0", ")", "{", "double", "thisDate", "=", "Double", ".", "parseDouble", "(", "c3", ".", "getString", "(", "colRcv", ")", ")", ";", "if", "(", "thisDate", ">", "maxDate", ")", "{", "subject", "=", "c3", ".", "getString", "(", "colSub", ")", ";", "sender", "=", "c3", ".", "getString", "(", "colFrom", ")", ";", "snippet", "=", "c3", ".", "getString", "(", "c3", ".", "getColumnIndex", "(", "\"snippet\"", ")", ")", ";", "maxDate", "=", "thisDate", ";", "}", "}", "if", "(", "c3", ".", "isLast", "(", ")", ")", "break", ";", "c3", ".", "moveToNext", "(", ")", ";", "}", "Pattern", "pattern", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "Matcher", "matcher", "=", "pattern", ".", "matcher", "(", "sender", ")", ";", "matcher", ".", "find", "(", ")", ";", "String", "senderName", "=", "matcher", ".", "group", "(", "1", ")", ".", "replace", "(", "\"\\\"\"", ",", "\"\"", ")", ";", "String", "senderMail", "=", "matcher", ".", "group", "(", "2", ")", ".", "replace", "(", "\"<\"", ",", "\"\"", ")", ".", "replace", "(", "\">\"", ",", "\"\"", ")", ";", "NotificationBuilder", ".", "createGmail", "(", "context", ",", "senderName", ",", "senderMail", ",", "subject", ",", "snippet", ")", ";", "}", "catch", "(", "Exception", "x", ")", "{", "}", "}", "}", "</s>" ]
8,212
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "public", "enum", "Message", "{", "InvalidMessage", "(", "0x00", ")", ",", "GetDeviceType", "(", "0x01", ")", ",", "GetDeviceTypeResponse", "(", "0x02", ")", ",", "GetInfoString", "(", "0x03", ")", ",", "GetInfoStringResponse", "(", "0x04", ")", ",", "DiagnosticLoopback", "(", "0x05", ")", ",", "EnterShippingModeMsg", "(", "0x06", ")", ",", "SoftwareResetMsg", "(", "0x07", ")", ",", "ConnectionTimeoutMsg", "(", "0x08", ")", ",", "TurnRadioOnMsg", "(", "0x09", ")", ",", "TurnRadioOffMsg", "(", "0x0a", ")", ",", "SppReserved", "(", "0x0b", ")", ",", "PariringControlMsg", "(", "0x0c", ")", ",", "EnterSniffModeMsg", "(", "0x0d", ")", ",", "xxReEnterSniffModeMsg", "(", "0x0e", ")", ",", "LinkAlarmMsg", "(", "0x0f", ")", ",", "OledWriteBufferMsg", "(", "0x10", ")", ",", "OledConfigureModeMsg", "(", "0x11", ")", ",", "OledChangeModeMsg", "(", "0x12", ")", ",", "OledWriteScrollBufferMsg", "(", "0x13", ")", ",", "OledScrollMsg", "(", "0x14", ")", ",", "OledShowIdleBufferMsg", "(", "0x15", ")", ",", "OledCrownMenuMsg", "(", "0x16", ")", ",", "OledCrownMenuButtonMsg", "(", "0x17", ")", ",", "AdvanceWatchHandsMsg", "(", "0x20", ")", ",", "SetVibrateMode", "(", "0x23", ")", ",", "SetRealTimeClock", "(", "0x26", ")", ",", "GetRealTimeClock", "(", "0x27", ")", ",", "GetRealTimeClockResponse", "(", "0x28", ")", ",", "NvalOperationMsg", "(", "0x30", ")", ",", "NvalOperationResponseMsg", "(", "0x31", ")", ",", "StatusChangeEvent", "(", "0x33", ")", ",", "ButtonEventMsg", "(", "0x34", ")", ",", "GeneralPurposePhoneMsg", "(", "0x35", ")", ",", "GeneralPurposeWatchMsg", "(", "0x36", ")", ",", "WriteBuffer", "(", "0x40", ")", ",", "ConfigureMode", "(", "0x41", ")", ",", "ConfigureIdleBufferSize", "(", "0x42", ")", ",", "UpdateDisplay", "(", "0x43", ")", ",", "LoadTemplate", "(", "0x44", ")", ",", "UpdateMyDisplaySram", "(", "0x45", ")", ",", "EnableButtonMsg", "(", "0x46", ")", ",", "DisableButtonMsg", "(", "0x47", ")", ",", "ReadButtonConfigMsg", "(", "0x48", ")", ",", "ReadButtonConfigResponse", "(", "0x49", ")", ",", "UpdateMyDisplayLcd", "(", "0x4a", ")", ",", "BatteryChargeControl", "(", "0x52", ")", ",", "BatteryConfigMsg", "(", "0x53", ")", ",", "LowBatteryWarningMsgHost", "(", "0x54", ")", ",", "LowBatteryBtOffMsgHost", "(", "0x55", ")", ",", "ReadBatteryVoltageMsg", "(", "0x56", ")", ",", "ReadBatteryVoltageResponse", "(", "0x57", ")", ",", "ReadLightSensorMsg", "(", "0x58", ")", ",", "ReadLightSensorResponse", "(", "0x59", ")", ",", "LowBatteryWarningMsg", "(", "0x5a", ")", ",", "LowBatteryBtOffMsg", "(", "0x5b", ")", ",", "IdleUpdate", "(", "0xa0", ")", ",", "xxxInitialIdleUpdate", "(", "0xa1", ")", ",", "WatchDrawnScreenTimeout", "(", "0xa2", ")", ",", "ClearLcdSpecial", "(", "0xa3", ")", ",", "WriteLcd", "(", "0xa4", ")", ",", "ClearLcd", "(", "0xa5", ")", ",", "ChangeModeMsg", "(", "0xa6", ")", ",", "ModeTimeoutMsg", "(", "0xa7", ")", ",", "WatchStatusMsg", "(", "0xa8", ")", ",", "MenuModeMsg", "(", "0xa9", ")", ",", "BarCode", "(", "0xaa", ")", ",", "ListPairedDevicesMsg", "(", "0xab", ")", ",", "ConnectionStateChangeMsg", "(", "0xac", ")", ",", "ModifyTimeMsg", "(", "0xad", ")", ",", "MenuButtonMsg", "(", "0xae", ")", ",", "ToggleSecondsMsg", "(", "0xaf", ")", ",", "SplashTimeoutMsg", "(", "0xb0", ")", ",", "LedChange", "(", "0xc0", ")", ",", "QueryMemoryMsg", "(", "0xd0", ")", ",", "AccelerometerSteps", "(", "0xea", ")", ",", "AccelerometerRawData", "(", "0xeb", ")", ";", "public", "byte", "msg", ";", "static", "public", "final", "byte", "start", "=", "0x01", ";", "Message", "(", "int", "msg", ")", "{", "this", ".", "msg", "=", "(", "byte", ")", "msg", ";", "}", "}", ";", "</s>" ]
8,213
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "java", ".", "lang", ".", "reflect", ".", "InvocationTargetException", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Method", ";", "import", "java", ".", "util", ".", "UUID", ";", "import", "android", ".", "app", ".", "NotificationManager", ";", "import", "android", ".", "app", ".", "PendingIntent", ";", "import", "android", ".", "app", ".", "Service", ";", "import", "android", ".", "bluetooth", ".", "BluetoothAdapter", ";", "import", "android", ".", "bluetooth", ".", "BluetoothDevice", ";", "import", "android", ".", "bluetooth", ".", "BluetoothSocket", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "content", ".", "SharedPreferences", ";", "import", "android", ".", "content", ".", "SharedPreferences", ".", "Editor", ";", "import", "android", ".", "media", ".", "AudioManager", ";", "import", "android", ".", "os", ".", "Handler", ";", "import", "android", ".", "os", ".", "IBinder", ";", "import", "android", ".", "os", ".", "Looper", ";", "import", "android", ".", "os", ".", "Message", ";", "import", "android", ".", "os", ".", "PowerManager", ";", "import", "android", ".", "preference", ".", "PreferenceManager", ";", "import", "android", ".", "telephony", ".", "TelephonyManager", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "widget", ".", "RemoteViews", ";", "import", "android", ".", "widget", ".", "Toast", ";", "public", "class", "MetaWatchService", "extends", "Service", "{", "Context", "context", ";", "public", "static", "BluetoothAdapter", "bluetoothAdapter", ";", "BluetoothSocket", "bluetoothSocket", ";", "static", "InputStream", "inputStream", ";", "static", "OutputStream", "outputStream", ";", "TelephonyManager", "telephonyManager", ";", "AudioManager", "audioManager", ";", "NotificationManager", "notificationManager", ";", "RemoteViews", "remoteViews", ";", "android", ".", "app", ".", "Notification", "notification", ";", "public", "static", "PowerManager", "powerManger", ";", "public", "static", "PowerManager", ".", "WakeLock", "wakeLock", ";", "static", "int", "connectionState", ";", "public", "static", "int", "watchType", ";", "public", "static", "int", "watchState", ";", "public", "static", "TestSmsLoop", "testSmsLoop", ";", "final", "class", "ConnectionState", "{", "static", "final", "int", "DISCONNECTED", "=", "0", ";", "static", "final", "int", "CONNECTING", "=", "1", ";", "static", "final", "int", "CONNECTED", "=", "2", ";", "static", "final", "int", "DISCONNECTING", "=", "3", ";", "}", "final", "class", "WatchBuffers", "{", "static", "final", "int", "IDLE", "=", "0", ";", "static", "final", "int", "APPLICATION", "=", "1", ";", "static", "final", "int", "NOTIFICATION", "=", "2", ";", "}", "final", "class", "WatchStates", "{", "static", "final", "int", "OFF", "=", "0", ";", "static", "final", "int", "IDLE", "=", "1", ";", "static", "final", "int", "APPLICATION", "=", "2", ";", "static", "final", "int", "NOTIFICATION", "=", "3", ";", "static", "final", "int", "CALL", "=", "3", ";", "}", "static", "class", "WatchModes", "{", "public", "static", "boolean", "IDLE", "=", "false", ";", "public", "static", "boolean", "APPLICATION", "=", "false", ";", "public", "static", "boolean", "NOTIFICATION", "=", "false", ";", "public", "static", "boolean", "CALL", "=", "false", ";", "}", "static", "class", "Preferences", "{", "public", "static", "boolean", "startOnBoot", "=", "false", ";", "public", "static", "boolean", "notifyCall", "=", "true", ";", "public", "static", "boolean", "notifySMS", "=", "true", ";", "public", "static", "boolean", "notifyGmail", "=", "true", ";", "public", "static", "boolean", "notifyK9", "=", "true", ";", "public", "static", "boolean", "notifyAlarm", "=", "true", ";", "public", "static", "boolean", "notifyMusic", "=", "true", ";", "public", "static", "String", "watchMacAddress", "=", "\"\"", ";", "public", "static", "int", "packetWait", "=", "10", ";", "public", "static", "boolean", "skipSDP", "=", "false", ";", "public", "static", "boolean", "invertLCD", "=", "false", ";", "public", "static", "String", "weatherCity", "=", "\"Dallas,US\"", ";", "public", "static", "boolean", "weatherCelsius", "=", "false", ";", "public", "static", "int", "fontSize", "=", "2", ";", "public", "static", "int", "smsLoopInterval", "=", "15", ";", "public", "static", "boolean", "idleMusicControls", "=", "false", ";", "public", "static", "boolean", "idleReplay", "=", "false", ";", "}", "final", "class", "WatchType", "{", "static", "final", "int", "ANALOG", "=", "1", ";", "static", "final", "int", "DIGITAL", "=", "2", ";", "}", "@", "Override", "public", "IBinder", "onBind", "(", "Intent", "intent", ")", "{", "return", "null", ";", "}", "public", "static", "void", "loadPreferences", "(", "Context", "context", ")", "{", "SharedPreferences", "sharedPreferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "context", ")", ";", "Preferences", ".", "startOnBoot", "=", "sharedPreferences", ".", "getBoolean", "(", "\"StartOnBoot\"", ",", "Preferences", ".", "startOnBoot", ")", ";", "Preferences", ".", "notifyCall", "=", "sharedPreferences", ".", "getBoolean", "(", "\"NotifyCall\"", ",", "Preferences", ".", "notifyCall", ")", ";", "Preferences", ".", "notifySMS", "=", "sharedPreferences", ".", "getBoolean", "(", "\"NotifySMS\"", ",", "Preferences", ".", "notifySMS", ")", ";", "Preferences", ".", "notifyGmail", "=", "sharedPreferences", ".", "getBoolean", "(", "\"NotifyGmail\"", ",", "Preferences", ".", "notifyGmail", ")", ";", "Preferences", ".", "notifyK9", "=", "sharedPreferences", ".", "getBoolean", "(", "\"NotifyK9\"", ",", "Preferences", ".", "notifyK9", ")", ";", "Preferences", ".", "notifyAlarm", "=", "sharedPreferences", ".", "getBoolean", "(", "\"NotifyAlarm\"", ",", "Preferences", ".", "notifyAlarm", ")", ";", "Preferences", ".", "notifyMusic", "=", "sharedPreferences", ".", "getBoolean", "(", "\"NotifyMusic\"", ",", "Preferences", ".", "notifyMusic", ")", ";", "Preferences", ".", "watchMacAddress", "=", "sharedPreferences", ".", "getString", "(", "\"MAC\"", ",", "Preferences", ".", "watchMacAddress", ")", ";", "Preferences", ".", "skipSDP", "=", "sharedPreferences", ".", "getBoolean", "(", "\"SkipSDP\"", ",", "Preferences", ".", "skipSDP", ")", ";", "Preferences", ".", "invertLCD", "=", "sharedPreferences", ".", "getBoolean", "(", "\"InvertLCD\"", ",", "Preferences", ".", "invertLCD", ")", ";", "Preferences", ".", "weatherCity", "=", "sharedPreferences", ".", "getString", "(", "\"WeatherCity\"", ",", "Preferences", ".", "weatherCity", ")", ";", "Preferences", ".", "weatherCelsius", "=", "sharedPreferences", ".", "getBoolean", "(", "\"\"", ",", "Preferences", ".", "weatherCelsius", ")", ";", "Preferences", ".", "idleMusicControls", "=", "sharedPreferences", ".", "getBoolean", "(", "\"\"", ",", "Preferences", ".", "idleMusicControls", ")", ";", "Preferences", ".", "idleReplay", "=", "sharedPreferences", ".", "getBoolean", "(", "\"IdleReplay\"", ",", "Preferences", ".", "idleReplay", ")", ";", "try", "{", "Preferences", ".", "fontSize", "=", "Integer", ".", "valueOf", "(", "sharedPreferences", ".", "getString", "(", "\"FontSize\"", ",", "Integer", ".", "toString", "(", "Preferences", ".", "fontSize", ")", ")", ")", ";", "Preferences", ".", "packetWait", "=", "Integer", ".", "valueOf", "(", "sharedPreferences", ".", "getString", "(", "\"PacketWait\"", ",", "Integer", ".", "toString", "(", "Preferences", ".", "packetWait", ")", ")", ")", ";", "Preferences", ".", "smsLoopInterval", "=", "Integer", ".", "valueOf", "(", "sharedPreferences", ".", "getString", "(", "\"\"", ",", "Integer", ".", "toString", "(", "Preferences", ".", "smsLoopInterval", ")", ")", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "}", "}", "public", "static", "void", "saveMac", "(", "Context", "context", ",", "String", "mac", ")", "{", "SharedPreferences", "sharedPreferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "context", ")", ";", "Editor", "editor", "=", "sharedPreferences", ".", "edit", "(", ")", ";", "editor", ".", "putString", "(", "\"MAC\"", ",", "mac", ")", ";", "editor", ".", "commit", "(", ")", ";", "}", "public", "void", "createNotification", "(", ")", "{", "notification", "=", "new", "android", ".", "app", ".", "Notification", "(", "R", ".", "drawable", ".", "disconnected_large", ",", "null", ",", "System", ".", "currentTimeMillis", "(", ")", ")", ";", "notification", ".", "flags", "|=", "android", ".", "app", ".", "Notification", ".", "FLAG_ONGOING_EVENT", ";", "remoteViews", "=", "new", "RemoteViews", "(", "getPackageName", "(", ")", ",", "R", ".", "layout", ".", "notification", ")", ";", "remoteViews", ".", "setImageViewResource", "(", "R", ".", "id", ".", "image", ",", "R", ".", "drawable", ".", "disconnected", ")", ";", "remoteViews", ".", "setTextViewText", "(", "R", ".", "id", ".", "text", ",", "\"\"", ")", ";", "notification", ".", "contentView", "=", "remoteViews", ";", "Intent", "notificationIntent", "=", "new", "Intent", "(", "this", ",", "MetaWatch", ".", "class", ")", ";", "PendingIntent", "contentIntent", "=", "PendingIntent", ".", "getActivity", "(", "this", ",", "0", ",", "notificationIntent", ",", "0", ")", ";", "notification", ".", "contentIntent", "=", "contentIntent", ";", "startForeground", "(", "1", ",", "notification", ")", ";", "}", "public", "void", "updateNotification", "(", "boolean", "connected", ")", "{", "if", "(", "connected", ")", "{", "notification", ".", "icon", "=", "R", ".", "drawable", ".", "connected", ";", "remoteViews", ".", "setImageViewResource", "(", "R", ".", "id", ".", "image", ",", "R", ".", "drawable", ".", "connected_large", ")", ";", "}", "else", "{", "notification", ".", "icon", "=", "R", ".", "drawable", ".", "disconnected", ";", "remoteViews", ".", "setImageViewResource", "(", "R", ".", "id", ".", "image", ",", "R", ".", "drawable", ".", "disconnected_large", ")", ";", "}", "startForeground", "(", "1", ",", "notification", ")", ";", "}", "public", "void", "removeNotification", "(", ")", "{", "stopForeground", "(", "true", ")", ";", "}", "@", "Override", "public", "void", "onCreate", "(", ")", "{", "super", ".", "onCreate", "(", ")", ";", "context", "=", "this", ";", "createNotification", "(", ")", ";", "connectionState", "=", "ConnectionState", ".", "CONNECTING", ";", "watchState", "=", "WatchStates", ".", "OFF", ";", "watchType", "=", "WatchType", ".", "DIGITAL", ";", "if", "(", "bluetoothAdapter", "==", "null", ")", "bluetoothAdapter", "=", "BluetoothAdapter", ".", "getDefaultAdapter", "(", ")", ";", "powerManger", "=", "(", "PowerManager", ")", "getSystemService", "(", "Context", ".", "POWER_SERVICE", ")", ";", "wakeLock", "=", "powerManger", ".", "newWakeLock", "(", "PowerManager", ".", "PARTIAL_WAKE_LOCK", ",", "\"MetaWatch\"", ")", ";", "audioManager", "=", "(", "AudioManager", ")", "getSystemService", "(", "Context", ".", "AUDIO_SERVICE", ")", ";", "Monitors", ".", "start", "(", "this", ",", "telephonyManager", ")", ";", "start", "(", ")", ";", "}", "@", "Override", "public", "void", "onDestroy", "(", ")", "{", "disconnectExit", "(", ")", ";", "super", ".", "onDestroy", "(", ")", ";", "Monitors", ".", "stop", "(", ")", ";", "removeNotification", "(", ")", ";", "}", "void", "connect", "(", "Context", "context", ")", "{", "try", "{", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"\"", "+", "Preferences", ".", "watchMacAddress", ")", ";", "if", "(", "Preferences", ".", "watchMacAddress", ".", "equals", "(", "\"\"", ")", ")", "loadPreferences", "(", "context", ")", ";", "BluetoothDevice", "bluetoothDevice", "=", "bluetoothAdapter", ".", "getRemoteDevice", "(", "Preferences", ".", "watchMacAddress", ")", ";", "if", "(", "Preferences", ".", "skipSDP", ")", "{", "Method", "method", "=", "bluetoothDevice", ".", "getClass", "(", ")", ".", "getMethod", "(", "\"\"", ",", "new", "Class", "[", "]", "{", "int", ".", "class", "}", ")", ";", "bluetoothSocket", "=", "(", "BluetoothSocket", ")", "method", ".", "invoke", "(", "bluetoothDevice", ",", "1", ")", ";", "}", "else", "{", "UUID", "uuid", "=", "UUID", ".", "fromString", "(", "\"\"", ")", ";", "bluetoothSocket", "=", "bluetoothDevice", ".", "createRfcommSocketToServiceRecord", "(", "uuid", ")", ";", "}", "bluetoothSocket", ".", "connect", "(", ")", ";", "inputStream", "=", "bluetoothSocket", ".", "getInputStream", "(", ")", ";", "outputStream", "=", "bluetoothSocket", ".", "getOutputStream", "(", ")", ";", "connectionState", "=", "ConnectionState", ".", "CONNECTED", ";", "updateNotification", "(", "true", ")", ";", "Protocol", ".", "sendRtcNow", "(", "context", ")", ";", "Protocol", ".", "getDeviceType", "(", ")", ";", "}", "catch", "(", "IOException", "ioexception", ")", "{", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "ioexception", ".", "toString", "(", ")", ")", ";", "sendToast", "(", "ioexception", ".", "toString", "(", ")", ")", ";", "}", "catch", "(", "SecurityException", "e", ")", "{", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "e", ".", "toString", "(", ")", ")", ";", "}", "catch", "(", "NoSuchMethodException", "e", ")", "{", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "e", ".", "toString", "(", ")", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "e", ".", "toString", "(", ")", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "e", ".", "toString", "(", ")", ")", ";", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "e", ".", "toString", "(", ")", ")", ";", "}", "}", "public", "void", "sendToast", "(", "String", "text", ")", "{", "Message", "m", "=", "new", "Message", "(", ")", ";", "m", ".", "what", "=", "1", ";", "m", ".", "obj", "=", "text", ";", "messageHandler", ".", "sendMessage", "(", "m", ")", ";", "}", "private", "Handler", "messageHandler", "=", "new", "Handler", "(", ")", "{", "@", "Override", "public", "void", "handleMessage", "(", "Message", "msg", ")", "{", "switch", "(", "msg", ".", "what", ")", "{", "case", "1", ":", "Toast", ".", "makeText", "(", "context", ",", "(", "CharSequence", ")", "msg", ".", "obj", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "break", ";", "}", "}", "}", ";", "void", "disconnect", "(", ")", "{", "try", "{", "if", "(", "outputStream", "!=", "null", ")", "outputStream", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "}", "try", "{", "if", "(", "inputStream", "!=", "null", ")", "inputStream", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "}", "try", "{", "if", "(", "bluetoothSocket", "!=", "null", ")", "bluetoothSocket", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "}", "}", "void", "disconnectExit", "(", ")", "{", "connectionState", "=", "ConnectionState", ".", "DISCONNECTING", ";", "disconnect", "(", ")", ";", "}", "public", "static", "void", "nap", "(", "long", "time", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "time", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "}", "void", "start", "(", ")", "{", "Thread", "thread", "=", "new", "Thread", "(", ")", "{", "public", "void", "run", "(", ")", "{", "boolean", "run", "=", "true", ";", "Looper", ".", "prepare", "(", ")", ";", "while", "(", "run", ")", "{", "switch", "(", "connectionState", ")", "{", "case", "ConnectionState", ".", "DISCONNECTED", ":", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"\"", ")", ";", "break", ";", "case", "ConnectionState", ".", "CONNECTING", ":", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"\"", ")", ";", "updateNotification", "(", "false", ")", ";", "connect", "(", "context", ")", ";", "nap", "(", "2000", ")", ";", "break", ";", "case", "ConnectionState", ".", "CONNECTED", ":", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"\"", ")", ";", "readFromDevice", "(", ")", ";", "break", ";", "case", "ConnectionState", ".", "DISCONNECTING", ":", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"\"", ")", ";", "run", "=", "false", ";", "break", ";", "}", "}", "}", "}", ";", "thread", ".", "start", "(", ")", ";", "}", "void", "readFromDevice", "(", ")", "{", "try", "{", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "256", "]", ";", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"\"", ")", ";", "inputStream", ".", "read", "(", "bytes", ")", ";", "wakeLock", ".", "acquire", "(", "5000", ")", ";", "String", "str", "=", "\"received:", "\"", ";", "int", "len", "=", "(", "bytes", "[", "1", "]", "&", "0xFF", ")", ";", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"\"", "+", "len", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "str", "+=", "\"0x\"", "+", "Integer", ".", "toString", "(", "(", "bytes", "[", "i", "]", "&", "0xff", ")", "+", "0x100", ",", "16", ")", ".", "substring", "(", "1", ")", "+", "\",", "\"", ";", "}", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "str", ")", ";", "switch", "(", "bytes", "[", "2", "]", ")", "{", "case", "0x02", ":", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"\"", ")", ";", "break", ";", "case", "0x31", ":", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"\"", ")", ";", "break", ";", "case", "0x33", ":", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"\"", ")", ";", "break", ";", "}", "if", "(", "bytes", "[", "2", "]", "==", "0x33", ")", "{", "if", "(", "bytes", "[", "4", "]", "==", "0x11", ")", "{", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"\"", ")", ";", "synchronized", "(", "Notification", ".", "scrollRequest", ")", "{", "Notification", ".", "scrollRequest", ".", "notify", "(", ")", ";", "}", "}", "if", "(", "bytes", "[", "4", "]", "==", "0x10", ")", "{", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"\"", ")", ";", "}", "}", "if", "(", "bytes", "[", "2", "]", "==", "0x34", ")", "{", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"button", "event\"", ")", ";", "pressedButton", "(", "bytes", "[", "3", "]", ")", ";", "}", "if", "(", "bytes", "[", "2", "]", "==", "0x02", ")", "{", "if", "(", "bytes", "[", "4", "]", "==", "1", "||", "bytes", "[", "4", "]", "==", "4", ")", "{", "watchType", "=", "WatchType", ".", "ANALOG", ";", "}", "else", "{", "watchType", "=", "WatchType", ".", "DIGITAL", ";", "if", "(", "Preferences", ".", "idleMusicControls", ")", "Protocol", ".", "enableMediaButtons", "(", ")", ";", "if", "(", "Preferences", ".", "idleReplay", ")", "Protocol", ".", "enableReplayButton", "(", ")", ";", "Protocol", ".", "configureMode", "(", ")", ";", "Idle", ".", "toIdle", "(", "this", ")", ";", "Idle", ".", "updateLcdIdle", "(", "this", ")", ";", "Protocol", ".", "queryNvalTime", "(", ")", ";", "}", "}", "}", "catch", "(", "IOException", "e", ")", "{", "wakeLock", ".", "acquire", "(", "5000", ")", ";", "if", "(", "connectionState", "!=", "ConnectionState", ".", "DISCONNECTING", ")", "connectionState", "=", "ConnectionState", ".", "CONNECTING", ";", "}", "}", "void", "pressedButton", "(", "byte", "button", ")", "{", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"\"", "+", "Byte", ".", "toString", "(", "button", ")", ")", ";", "switch", "(", "watchState", ")", "{", "case", "WatchStates", ".", "IDLE", ":", "{", "switch", "(", "button", ")", "{", "case", "MediaControl", ".", "VOLUME_UP", ":", "MediaControl", ".", "volumeUp", "(", "audioManager", ")", ";", "break", ";", "case", "MediaControl", ".", "VOLUME_DOWN", ":", "MediaControl", ".", "volumeDown", "(", "audioManager", ")", ";", "break", ";", "case", "MediaControl", ".", "NEXT", ":", "MediaControl", ".", "next", "(", "this", ")", ";", "break", ";", "case", "MediaControl", ".", "PREVIOUS", ":", "MediaControl", ".", "previous", "(", "this", ")", ";", "break", ";", "case", "MediaControl", ".", "TOGGLE", ":", "MediaControl", ".", "togglePause", "(", "this", ")", ";", "break", ";", "case", "Protocol", ".", "REPLAY", ":", "Notification", ".", "replay", "(", "this", ")", ";", "break", ";", "}", "}", "break", ";", "case", "WatchStates", ".", "APPLICATION", ":", "broadcastButton", "(", "button", ",", "watchState", ")", ";", "break", ";", "case", "WatchStates", ".", "NOTIFICATION", ":", "break", ";", "}", "}", "void", "broadcastButton", "(", "byte", "button", ",", "int", "state", ")", "{", "Intent", "intent", "=", "new", "Intent", "(", "\"\"", ")", ";", "intent", ".", "putExtra", "(", "\"button\"", ",", "button", ")", ";", "switch", "(", "state", ")", "{", "case", "WatchStates", ".", "IDLE", ":", "intent", ".", "putExtra", "(", "\"mode\"", ",", "\"idle\"", ")", ";", "break", ";", "case", "WatchStates", ".", "APPLICATION", ":", "intent", ".", "putExtra", "(", "\"mode\"", ",", "\"application\"", ")", ";", "break", ";", "}", "sendBroadcast", "(", "intent", ")", ";", "}", "}", "</s>" ]
8,214
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "android", ".", "content", ".", "Context", ";", "public", "class", "TestSmsLoop", "implements", "Runnable", "{", "Context", "context", ";", "boolean", "runLoop", ";", "public", "TestSmsLoop", "(", "Context", "context", ")", "{", "this", ".", "context", "=", "context", ";", "}", "public", "void", "run", "(", ")", "{", "runLoop", "=", "true", ";", "for", "(", "int", "i", "=", "1", ";", "runLoop", ";", "i", "++", ")", "{", "NotificationBuilder", ".", "createSMS", "(", "context", ",", "\"123-456-789\"", ",", "\"\"", "+", "i", ")", ";", "try", "{", "Thread", ".", "sleep", "(", "MetaWatchService", ".", "Preferences", ".", "smsLoopInterval", "*", "1000", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "}", "}", "public", "void", "stop", "(", ")", "{", "runLoop", "=", "false", ";", "}", "}", "</s>" ]
8,215
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "org", ".", "metawatch", ".", "manager", ".", "MetaWatchService", ".", "Preferences", ";", "import", "android", ".", "content", ".", "BroadcastReceiver", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "content", ".", "SharedPreferences", ";", "import", "android", ".", "preference", ".", "PreferenceManager", ";", "public", "class", "BootUpReceiver", "extends", "BroadcastReceiver", "{", "@", "Override", "public", "void", "onReceive", "(", "Context", "context", ",", "Intent", "intent", ")", "{", "SharedPreferences", "sharedPreferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "context", ")", ";", "if", "(", "sharedPreferences", ".", "getBoolean", "(", "\"StartOnBoot\"", ",", "Preferences", ".", "startOnBoot", ")", ")", "{", "context", ".", "startService", "(", "new", "Intent", "(", "context", ",", "MetaWatchService", ".", "class", ")", ")", ";", "}", "}", "}", "</s>" ]
8,216
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "java", ".", "io", ".", "ByteArrayOutputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Calendar", ";", "import", "java", ".", "util", ".", "Date", ";", "import", "org", ".", "metawatch", ".", "manager", ".", "MetaWatchService", ".", "Preferences", ";", "import", "org", ".", "metawatch", ".", "manager", ".", "NotificationBuilder", ".", "FontSize", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "graphics", ".", "Bitmap", ";", "import", "android", ".", "graphics", ".", "Canvas", ";", "import", "android", ".", "graphics", ".", "Color", ";", "import", "android", ".", "graphics", ".", "Paint", ";", "import", "android", ".", "graphics", ".", "Typeface", ";", "import", "android", ".", "text", ".", "StaticLayout", ";", "import", "android", ".", "text", ".", "TextPaint", ";", "import", "android", ".", "text", ".", "format", ".", "DateFormat", ";", "import", "android", ".", "util", ".", "Log", ";", "public", "class", "Protocol", "{", "public", "static", "final", "byte", "REPLAY", "=", "30", ";", "public", "static", "ArrayList", "<", "byte", "[", "]", ">", "sendQueue", "=", "new", "ArrayList", "<", "byte", "[", "]", ">", "(", ")", ";", "public", "static", "boolean", "isSending", "=", "false", ";", "public", "static", "void", "sendLcdBitmap", "(", "Bitmap", "bitmap", ",", "int", "bufferType", ")", "{", "int", "pixelArray", "[", "]", "=", "new", "int", "[", "96", "*", "96", "]", ";", "bitmap", ".", "getPixels", "(", "pixelArray", ",", "0", ",", "96", ",", "0", ",", "0", ",", "96", ",", "96", ")", ";", "sendLcdArray", "(", "pixelArray", ",", "bufferType", ")", ";", "}", "static", "void", "sendLcdArray", "(", "int", "[", "]", "pixelArray", ",", "int", "bufferType", ")", "{", "byte", "send", "[", "]", "=", "new", "byte", "[", "1152", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "1152", ";", "i", "++", ")", "{", "int", "p", "[", "]", "=", "new", "int", "[", "8", "]", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "8", ";", "j", "++", ")", "{", "if", "(", "pixelArray", "[", "i", "*", "8", "+", "j", "]", "==", "Color", ".", "WHITE", ")", "p", "[", "j", "]", "=", "0", ";", "else", "p", "[", "j", "]", "=", "1", ";", "}", "send", "[", "i", "]", "=", "(", "byte", ")", "(", "p", "[", "7", "]", "*", "128", "+", "p", "[", "6", "]", "*", "64", "+", "p", "[", "5", "]", "*", "32", "+", "p", "[", "4", "]", "*", "16", "+", "p", "[", "3", "]", "*", "8", "+", "p", "[", "2", "]", "*", "4", "+", "p", "[", "1", "]", "*", "2", "+", "p", "[", "0", "]", "*", "1", ")", ";", "}", "sendLcdBuffer", "(", "send", ",", "bufferType", ")", ";", "}", "static", "void", "sendLcdBuffer", "(", "byte", "[", "]", "buffer", ",", "int", "bufferType", ")", "{", "if", "(", "MetaWatchService", ".", "connectionState", "!=", "MetaWatchService", ".", "ConnectionState", ".", "CONNECTED", ")", "return", ";", "int", "i", "=", "0", ";", "if", "(", "bufferType", "==", "MetaWatchService", ".", "WatchBuffers", ".", "IDLE", ")", "i", "=", "30", ";", "for", "(", ";", "i", "<", "96", ";", "i", "+=", "2", ")", "{", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "30", "]", ";", "bytes", "[", "0", "]", "=", "Message", ".", "start", ";", "bytes", "[", "1", "]", "=", "(", "byte", ")", "(", "bytes", ".", "length", "+", "2", ")", ";", "bytes", "[", "2", "]", "=", "Message", ".", "WriteBuffer", ".", "msg", ";", "bytes", "[", "3", "]", "=", "(", "byte", ")", "bufferType", ";", "bytes", "[", "4", "]", "=", "(", "byte", ")", "i", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "12", ";", "j", "++", ")", "bytes", "[", "j", "+", "5", "]", "=", "buffer", "[", "i", "*", "12", "+", "j", "]", ";", "bytes", "[", "4", "+", "13", "]", "=", "(", "byte", ")", "(", "i", "+", "1", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "12", ";", "j", "++", ")", "bytes", "[", "j", "+", "5", "+", "13", "]", "=", "buffer", "[", "i", "*", "12", "+", "j", "+", "12", "]", ";", "sendQueue", ".", "add", "(", "bytes", ")", ";", "}", "processSendQueue", "(", ")", ";", "}", "public", "static", "void", "processSendQueue", "(", ")", "{", "if", "(", "isSending", ")", "return", ";", "else", "isSending", "=", "true", ";", "Thread", "thread", "=", "new", "Thread", "(", ")", "{", "public", "void", "run", "(", ")", "{", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"\"", ")", ";", "while", "(", "sendQueue", ".", "size", "(", ")", ">", "0", ")", "{", "try", "{", "send", "(", "sendQueue", ".", "get", "(", "0", ")", ")", ";", "sendQueue", ".", "remove", "(", "0", ")", ";", "Thread", ".", "sleep", "(", "Preferences", ".", "packetWait", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "sendQueue", ".", "clear", "(", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "}", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"\"", ")", ";", "isSending", "=", "false", ";", "}", "}", ";", "thread", ".", "start", "(", ")", ";", "}", "public", "static", "void", "send", "(", "byte", "[", "]", "bytes", ")", "throws", "IOException", ",", "NullPointerException", "{", "if", "(", "bytes", "==", "null", ")", "return", ";", "ByteArrayOutputStream", "byteArrayOutputStream", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "byteArrayOutputStream", ".", "write", "(", "bytes", ")", ";", "byteArrayOutputStream", ".", "write", "(", "crc", "(", "bytes", ")", ")", ";", "String", "str", "=", "\"sending:", "\"", ";", "byte", "[", "]", "b", "=", "byteArrayOutputStream", ".", "toByteArray", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "b", ".", "length", ";", "i", "++", ")", "{", "str", "+=", "\"0x\"", "+", "Integer", ".", "toString", "(", "(", "b", "[", "i", "]", "&", "0xff", ")", "+", "0x100", ",", "16", ")", ".", "substring", "(", "1", ")", "+", "\",", "\"", ";", "}", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "str", ")", ";", "if", "(", "MetaWatchService", ".", "outputStream", "==", "null", ")", "throw", "new", "IOException", "(", "\"\"", ")", ";", "MetaWatchService", ".", "outputStream", ".", "write", "(", "byteArrayOutputStream", ".", "toByteArray", "(", ")", ")", ";", "MetaWatchService", ".", "outputStream", ".", "flush", "(", ")", ";", "}", "public", "static", "void", "sendAdvanceHands", "(", ")", "{", "try", "{", "Date", "date", "=", "new", "Date", "(", ")", ";", "Calendar", "calendar", "=", "Calendar", ".", "getInstance", "(", ")", ";", "calendar", ".", "setTime", "(", "date", ")", ";", "int", "hour", "=", "calendar", ".", "get", "(", "Calendar", ".", "HOUR", ")", ";", "int", "minute", "=", "calendar", ".", "get", "(", "Calendar", ".", "MINUTE", ")", ";", "int", "second", "=", "calendar", ".", "get", "(", "Calendar", ".", "SECOND", ")", ";", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "7", "]", ";", "bytes", "[", "0", "]", "=", "Message", ".", "start", ";", "bytes", "[", "1", "]", "=", "9", ";", "bytes", "[", "2", "]", "=", "Message", ".", "AdvanceWatchHandsMsg", ".", "msg", ";", "bytes", "[", "3", "]", "=", "0x04", ";", "bytes", "[", "4", "]", "=", "(", "byte", ")", "hour", ";", "bytes", "[", "5", "]", "=", "(", "byte", ")", "minute", ";", "bytes", "[", "6", "]", "=", "(", "byte", ")", "second", ";", "}", "catch", "(", "Exception", "x", ")", "{", "}", "}", "public", "static", "void", "sendRtcNow", "(", "Context", "context", ")", "{", "try", "{", "boolean", "isMMDD", "=", "true", ";", "char", "[", "]", "ch", "=", "DateFormat", ".", "getDateFormatOrder", "(", "context", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "ch", ".", "length", ";", "i", "++", ")", "{", "if", "(", "ch", "[", "i", "]", "==", "DateFormat", ".", "DATE", ")", "{", "isMMDD", "=", "false", ";", "break", ";", "}", "if", "(", "ch", "[", "i", "]", "==", "DateFormat", ".", "MONTH", ")", "{", "isMMDD", "=", "true", ";", "break", ";", "}", "}", "Date", "date", "=", "new", "Date", "(", ")", ";", "Calendar", "calendar", "=", "Calendar", ".", "getInstance", "(", ")", ";", "calendar", ".", "setTime", "(", "date", ")", ";", "int", "year", "=", "calendar", ".", "get", "(", "Calendar", ".", "YEAR", ")", ";", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "14", "]", ";", "bytes", "[", "0", "]", "=", "Message", ".", "start", ";", "bytes", "[", "1", "]", "=", "(", "byte", ")", "(", "bytes", ".", "length", "+", "2", ")", ";", "bytes", "[", "2", "]", "=", "Message", ".", "SetRealTimeClock", ".", "msg", ";", "bytes", "[", "3", "]", "=", "0x00", ";", "bytes", "[", "4", "]", "=", "(", "byte", ")", "(", "year", "/", "256", ")", ";", "bytes", "[", "5", "]", "=", "(", "byte", ")", "(", "year", "%", "256", ")", ";", "bytes", "[", "6", "]", "=", "(", "byte", ")", "(", "calendar", ".", "get", "(", "Calendar", ".", "MONTH", ")", "+", "1", ")", ";", "bytes", "[", "7", "]", "=", "(", "byte", ")", "calendar", ".", "get", "(", "Calendar", ".", "DAY_OF_MONTH", ")", ";", "bytes", "[", "8", "]", "=", "(", "byte", ")", "(", "calendar", ".", "get", "(", "Calendar", ".", "DAY_OF_WEEK", ")", "-", "1", ")", ";", "bytes", "[", "9", "]", "=", "(", "byte", ")", "calendar", ".", "get", "(", "Calendar", ".", "HOUR_OF_DAY", ")", ";", "bytes", "[", "10", "]", "=", "(", "byte", ")", "calendar", ".", "get", "(", "Calendar", ".", "MINUTE", ")", ";", "bytes", "[", "11", "]", "=", "(", "byte", ")", "calendar", ".", "get", "(", "Calendar", ".", "SECOND", ")", ";", "if", "(", "DateFormat", ".", "is24HourFormat", "(", "context", ")", ")", "bytes", "[", "12", "]", "=", "(", "byte", ")", "1", ";", "else", "bytes", "[", "12", "]", "=", "(", "byte", ")", "0", ";", "if", "(", "isMMDD", ")", "bytes", "[", "13", "]", "=", "(", "byte", ")", "0", ";", "else", "bytes", "[", "13", "]", "=", "(", "byte", ")", "1", ";", "sendQueue", ".", "add", "(", "bytes", ")", ";", "processSendQueue", "(", ")", ";", "}", "catch", "(", "Exception", "x", ")", "{", "}", "}", "public", "static", "byte", "[", "]", "crc", "(", "byte", "[", "]", "bytes", ")", "{", "byte", "[", "]", "result", "=", "new", "byte", "[", "2", "]", ";", "short", "crc", "=", "(", "short", ")", "0xFFFF", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "bytes", ".", "length", ";", "j", "++", ")", "{", "byte", "c", "=", "bytes", "[", "j", "]", ";", "for", "(", "int", "i", "=", "7", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "boolean", "c15", "=", "(", "(", "crc", ">>", "15", "&", "1", ")", "==", "1", ")", ";", "boolean", "bit", "=", "(", "(", "c", ">>", "(", "7", "-", "i", ")", "&", "1", ")", "==", "1", ")", ";", "crc", "<<=", "1", ";", "if", "(", "c15", "^", "bit", ")", "crc", "^=", "0x1021", ";", "}", "}", "int", "crc2", "=", "crc", "-", "0xffff0000", ";", "result", "[", "0", "]", "=", "(", "byte", ")", "(", "crc2", "%", "256", ")", ";", "result", "[", "1", "]", "=", "(", "byte", ")", "(", "crc2", "/", "256", ")", ";", "return", "result", ";", "}", "public", "static", "Bitmap", "createTextBitmap", "(", "Context", "context", ",", "String", "text", ")", "{", "String", "font", "=", "null", ";", "int", "size", "=", "8", ";", "switch", "(", "Preferences", ".", "fontSize", ")", "{", "case", "FontSize", ".", "SMALL", ":", "font", "=", "\"\"", ";", "break", ";", "case", "FontSize", ".", "MEDIUM", ":", "font", "=", "\"\"", ";", "break", ";", "case", "FontSize", ".", "LARGE", ":", "font", "=", "\"\"", ";", "size", "=", "16", ";", "break", ";", "}", "Bitmap", "bitmap", "=", "Bitmap", ".", "createBitmap", "(", "96", ",", "96", ",", "Bitmap", ".", "Config", ".", "RGB_565", ")", ";", "Canvas", "canvas", "=", "new", "Canvas", "(", "bitmap", ")", ";", "Paint", "paint", "=", "new", "Paint", "(", ")", ";", "paint", ".", "setColor", "(", "Color", ".", "BLACK", ")", ";", "paint", ".", "setTextSize", "(", "size", ")", ";", "Typeface", "typeface", "=", "Typeface", ".", "createFromAsset", "(", "context", ".", "getAssets", "(", ")", ",", "font", ")", ";", "paint", ".", "setTypeface", "(", "typeface", ")", ";", "canvas", ".", "drawColor", "(", "Color", ".", "WHITE", ")", ";", "canvas", "=", "breakText", "(", "canvas", ",", "text", ",", "paint", ",", "0", ",", "0", ")", ";", "return", "bitmap", ";", "}", "public", "static", "Canvas", "breakText", "(", "Canvas", "canvas", ",", "String", "text", ",", "Paint", "pen", ",", "int", "x", ",", "int", "y", ")", "{", "TextPaint", "textPaint", "=", "new", "TextPaint", "(", "pen", ")", ";", "StaticLayout", "staticLayout", "=", "new", "StaticLayout", "(", "text", ",", "textPaint", ",", "98", ",", "android", ".", "text", ".", "Layout", ".", "Alignment", ".", "ALIGN_NORMAL", ",", "1.3f", ",", "0", ",", "false", ")", ";", "canvas", ".", "translate", "(", "x", ",", "y", ")", ";", "staticLayout", ".", "draw", "(", "canvas", ")", ";", "return", "canvas", ";", "}", "public", "static", "void", "loadTemplate", "(", "int", "mode", ")", "{", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "5", "]", ";", "bytes", "[", "0", "]", "=", "Message", ".", "start", ";", "bytes", "[", "1", "]", "=", "(", "byte", ")", "(", "bytes", ".", "length", "+", "2", ")", ";", "bytes", "[", "2", "]", "=", "Message", ".", "LoadTemplate", ".", "msg", ";", "bytes", "[", "3", "]", "=", "(", "byte", ")", "mode", ";", "bytes", "[", "4", "]", "=", "(", "byte", ")", "0", ";", "sendQueue", ".", "add", "(", "bytes", ")", ";", "processSendQueue", "(", ")", ";", "}", "public", "static", "void", "activateBuffer", "(", "int", "mode", ")", "{", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "4", "]", ";", "bytes", "[", "0", "]", "=", "Message", ".", "start", ";", "bytes", "[", "1", "]", "=", "(", "byte", ")", "(", "bytes", ".", "length", "+", "2", ")", ";", "bytes", "[", "2", "]", "=", "Message", ".", "ConfigureIdleBufferSize", ".", "msg", ";", "bytes", "[", "3", "]", "=", "(", "byte", ")", "mode", ";", "sendQueue", ".", "add", "(", "bytes", ")", ";", "processSendQueue", "(", ")", ";", "}", "public", "static", "void", "updateDisplay", "(", "int", "bufferType", ")", "{", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "4", "]", ";", "bytes", "[", "0", "]", "=", "Message", ".", "start", ";", "bytes", "[", "1", "]", "=", "(", "byte", ")", "(", "bytes", ".", "length", "+", "2", ")", ";", "bytes", "[", "2", "]", "=", "Message", ".", "UpdateDisplay", ".", "msg", ";", "bytes", "[", "3", "]", "=", "(", "byte", ")", "(", "bufferType", "+", "16", ")", ";", "sendQueue", ".", "add", "(", "bytes", ")", ";", "processSendQueue", "(", ")", ";", "}", "public", "static", "void", "vibrate", "(", "int", "on", ",", "int", "off", ",", "int", "cycles", ")", "{", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "10", "]", ";", "bytes", "[", "0", "]", "=", "Message", ".", "start", ";", "bytes", "[", "1", "]", "=", "12", ";", "bytes", "[", "2", "]", "=", "Message", ".", "SetVibrateMode", ".", "msg", ";", "bytes", "[", "3", "]", "=", "0x00", ";", "bytes", "[", "4", "]", "=", "0x01", ";", "bytes", "[", "5", "]", "=", "(", "byte", ")", "(", "on", "%", "256", ")", ";", "bytes", "[", "6", "]", "=", "(", "byte", ")", "(", "on", "/", "256", ")", ";", "bytes", "[", "7", "]", "=", "(", "byte", ")", "(", "off", "%", "256", ")", ";", "bytes", "[", "8", "]", "=", "(", "byte", ")", "(", "off", "/", "256", ")", ";", "bytes", "[", "9", "]", "=", "(", "byte", ")", "cycles", ";", "sendQueue", ".", "add", "(", "bytes", ")", ";", "processSendQueue", "(", ")", ";", "}", "public", "static", "void", "writeBuffer", "(", ")", "{", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "17", "]", ";", "bytes", "[", "0", "]", "=", "Message", ".", "start", ";", "bytes", "[", "1", "]", "=", "(", "byte", ")", "(", "bytes", ".", "length", "+", "2", ")", ";", "bytes", "[", "2", "]", "=", "Message", ".", "WriteBuffer", ".", "msg", ";", "bytes", "[", "3", "]", "=", "0", ";", "bytes", "[", "4", "]", "=", "31", ";", "bytes", "[", "5", "]", "=", "15", ";", "bytes", "[", "6", "]", "=", "15", ";", "bytes", "[", "7", "]", "=", "15", ";", "bytes", "[", "8", "]", "=", "15", ";", "bytes", "[", "9", "]", "=", "15", ";", "bytes", "[", "10", "]", "=", "15", ";", "bytes", "[", "11", "]", "=", "15", ";", "bytes", "[", "12", "]", "=", "15", ";", "bytes", "[", "13", "]", "=", "15", ";", "bytes", "[", "14", "]", "=", "15", ";", "bytes", "[", "15", "]", "=", "15", ";", "bytes", "[", "16", "]", "=", "15", ";", "sendQueue", ".", "add", "(", "bytes", ")", ";", "processSendQueue", "(", ")", ";", "}", "public", "static", "void", "enableButton", "(", "int", "button", ",", "int", "type", ",", "int", "code", ")", "{", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "9", "]", ";", "bytes", "[", "0", "]", "=", "Message", ".", "start", ";", "bytes", "[", "1", "]", "=", "(", "byte", ")", "(", "bytes", ".", "length", "+", "2", ")", ";", "bytes", "[", "2", "]", "=", "Message", ".", "EnableButtonMsg", ".", "msg", ";", "bytes", "[", "3", "]", "=", "0", ";", "bytes", "[", "4", "]", "=", "0", ";", "bytes", "[", "5", "]", "=", "(", "byte", ")", "button", ";", "bytes", "[", "6", "]", "=", "(", "byte", ")", "type", ";", "bytes", "[", "7", "]", "=", "0x34", ";", "bytes", "[", "8", "]", "=", "(", "byte", ")", "code", ";", "sendQueue", ".", "add", "(", "bytes", ")", ";", "processSendQueue", "(", ")", ";", "}", "public", "static", "void", "disableButton", "(", "int", "button", ",", "int", "type", ")", "{", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "7", "]", ";", "bytes", "[", "0", "]", "=", "Message", ".", "start", ";", "bytes", "[", "1", "]", "=", "(", "byte", ")", "(", "bytes", ".", "length", "+", "2", ")", ";", "bytes", "[", "2", "]", "=", "Message", ".", "DisableButtonMsg", ".", "msg", ";", "bytes", "[", "3", "]", "=", "0", ";", "bytes", "[", "4", "]", "=", "0", ";", "bytes", "[", "5", "]", "=", "(", "byte", ")", "button", ";", "bytes", "[", "6", "]", "=", "(", "byte", ")", "type", ";", "sendQueue", ".", "add", "(", "bytes", ")", ";", "processSendQueue", "(", ")", ";", "}", "public", "static", "void", "enableReplayButton", "(", ")", "{", "enableButton", "(", "1", ",", "0", ",", "REPLAY", ")", ";", "}", "public", "static", "void", "disableReplayButton", "(", ")", "{", "disableButton", "(", "1", ",", "0", ")", ";", "}", "public", "static", "void", "enableMediaButtons", "(", ")", "{", "enableButton", "(", "3", ",", "0", ",", "0", ")", ";", "enableButton", "(", "3", ",", "1", ",", "MediaControl", ".", "VOLUME_DOWN", ")", ";", "enableButton", "(", "3", ",", "2", ",", "MediaControl", ".", "PREVIOUS", ")", ";", "enableButton", "(", "5", ",", "0", ",", "MediaControl", ".", "TOGGLE", ")", ";", "enableButton", "(", "6", ",", "0", ",", "0", ")", ";", "enableButton", "(", "6", ",", "1", ",", "MediaControl", ".", "VOLUME_UP", ")", ";", "enableButton", "(", "6", ",", "2", ",", "MediaControl", ".", "NEXT", ")", ";", "}", "public", "static", "void", "disableMediaButtons", "(", ")", "{", "disableButton", "(", "3", ",", "0", ")", ";", "disableButton", "(", "3", ",", "1", ")", ";", "disableButton", "(", "3", ",", "2", ")", ";", "disableButton", "(", "5", ",", "0", ")", ";", "disableButton", "(", "6", ",", "0", ")", ";", "disableButton", "(", "6", ",", "1", ")", ";", "disableButton", "(", "6", ",", "2", ")", ";", "}", "public", "static", "void", "readButtonConfiguration", "(", ")", "{", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "9", "]", ";", "bytes", "[", "0", "]", "=", "Message", ".", "start", ";", "bytes", "[", "1", "]", "=", "(", "byte", ")", "(", "bytes", ".", "length", "+", "2", ")", ";", "bytes", "[", "2", "]", "=", "Message", ".", "ReadButtonConfigMsg", ".", "msg", ";", "bytes", "[", "3", "]", "=", "0", ";", "bytes", "[", "4", "]", "=", "0", ";", "bytes", "[", "5", "]", "=", "1", ";", "bytes", "[", "6", "]", "=", "2", ";", "bytes", "[", "7", "]", "=", "0x34", ";", "bytes", "[", "8", "]", "=", "0", ";", "sendQueue", ".", "add", "(", "bytes", ")", ";", "processSendQueue", "(", ")", ";", "}", "public", "static", "void", "configureMode", "(", ")", "{", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "6", "]", ";", "bytes", "[", "0", "]", "=", "Message", ".", "start", ";", "bytes", "[", "1", "]", "=", "(", "byte", ")", "(", "bytes", ".", "length", "+", "2", ")", ";", "bytes", "[", "2", "]", "=", "Message", ".", "ConfigureMode", ".", "msg", ";", "bytes", "[", "3", "]", "=", "0", ";", "bytes", "[", "4", "]", "=", "10", ";", "bytes", "[", "5", "]", "=", "(", "byte", ")", "(", "MetaWatchService", ".", "Preferences", ".", "invertLCD", "?", "1", ":", "0", ")", ";", "sendQueue", ".", "add", "(", "bytes", ")", ";", "processSendQueue", "(", ")", ";", "}", "public", "static", "void", "getDeviceType", "(", ")", "{", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "4", "]", ";", "bytes", "[", "0", "]", "=", "Message", ".", "start", ";", "bytes", "[", "1", "]", "=", "(", "byte", ")", "(", "bytes", ".", "length", "+", "2", ")", ";", "bytes", "[", "2", "]", "=", "Message", ".", "GetDeviceType", ".", "msg", ";", "bytes", "[", "3", "]", "=", "0", ";", "sendQueue", ".", "add", "(", "bytes", ")", ";", "processSendQueue", "(", ")", ";", "}", "public", "static", "void", "queryNvalTime", "(", ")", "{", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "7", "]", ";", "bytes", "[", "0", "]", "=", "Message", ".", "start", ";", "bytes", "[", "1", "]", "=", "(", "byte", ")", "(", "bytes", ".", "length", "+", "2", ")", ";", "bytes", "[", "2", "]", "=", "Message", ".", "NvalOperationMsg", ".", "msg", ";", "bytes", "[", "3", "]", "=", "0x01", ";", "bytes", "[", "4", "]", "=", "0x09", ";", "bytes", "[", "5", "]", "=", "0x20", ";", "bytes", "[", "6", "]", "=", "0x01", ";", "sendQueue", ".", "add", "(", "bytes", ")", ";", "processSendQueue", "(", ")", ";", "}", "public", "static", "void", "setNvalTime", "(", "boolean", "militaryTime", ")", "{", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "8", "]", ";", "bytes", "[", "0", "]", "=", "Message", ".", "start", ";", "bytes", "[", "1", "]", "=", "(", "byte", ")", "(", "bytes", ".", "length", "+", "2", ")", ";", "bytes", "[", "2", "]", "=", "Message", ".", "NvalOperationMsg", ".", "msg", ";", "bytes", "[", "3", "]", "=", "0x02", ";", "bytes", "[", "4", "]", "=", "0x09", ";", "bytes", "[", "5", "]", "=", "0x20", ";", "bytes", "[", "6", "]", "=", "0x01", ";", "if", "(", "militaryTime", ")", "bytes", "[", "7", "]", "=", "0x01", ";", "else", "bytes", "[", "7", "]", "=", "0x00", ";", "sendQueue", ".", "add", "(", "bytes", ")", ";", "processSendQueue", "(", ")", ";", "}", "public", "static", "void", "test", "(", "Context", "context", ")", "{", "sendOledDisplay", "(", "createOled1line", "(", "context", ",", "null", ",", "\"test", "abc", "123\"", ")", ",", "true", ",", "false", ")", ";", "sendOledDisplay", "(", "createOled2lines", "(", "context", ",", "\"\"", ",", "\"\"", ")", ",", "false", ",", "true", ")", ";", "byte", "[", "]", "display", "=", "new", "byte", "[", "800", "]", ";", "createOled2linesLong", "(", "context", ",", "\"\"", ",", "display", ")", ";", "sendOledBufferPart", "(", "display", ",", "0", ",", "80", ",", "true", ",", "true", ")", ";", "}", "public", "static", "byte", "[", "]", "createOled1line", "(", "Context", "context", ",", "String", "icon", ",", "String", "line", ")", "{", "int", "offset", "=", "0", ";", "if", "(", "icon", "!=", "null", ")", "offset", "+=", "17", ";", "Bitmap", "image", "=", "Bitmap", ".", "createBitmap", "(", "80", ",", "16", ",", "Bitmap", ".", "Config", ".", "RGB_565", ")", ";", "Canvas", "canvas", "=", "new", "Canvas", "(", "image", ")", ";", "Paint", "paint", "=", "new", "Paint", "(", ")", ";", "paint", ".", "setColor", "(", "Color", ".", "BLACK", ")", ";", "paint", ".", "setTextSize", "(", "16", ")", ";", "Typeface", "typeface", "=", "Typeface", ".", "createFromAsset", "(", "context", ".", "getAssets", "(", ")", ",", "\"\"", ")", ";", "paint", ".", "setTypeface", "(", "typeface", ")", ";", "canvas", ".", "drawColor", "(", "Color", ".", "WHITE", ")", ";", "canvas", ".", "drawText", "(", "line", ",", "offset", ",", "14", ",", "paint", ")", ";", "if", "(", "icon", "!=", "null", ")", "{", "canvas", ".", "drawBitmap", "(", "Utils", ".", "loadBitmapFromAssets", "(", "context", ",", "icon", ")", ",", "0", ",", "0", ",", "null", ")", ";", "}", "int", "poleInt", "[", "]", "=", "new", "int", "[", "16", "*", "80", "]", ";", "image", ".", "getPixels", "(", "poleInt", ",", "0", ",", "80", ",", "0", ",", "0", ",", "80", ",", "16", ")", ";", "byte", "[", "]", "display", "=", "new", "byte", "[", "160", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "160", ";", "i", "++", ")", "{", "boolean", "[", "]", "column", "=", "new", "boolean", "[", "8", "]", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "8", ";", "j", "++", ")", "{", "if", "(", "i", "<", "80", ")", "{", "if", "(", "poleInt", "[", "80", "*", "j", "+", "i", "]", "==", "Color", ".", "WHITE", ")", "column", "[", "j", "]", "=", "false", ";", "else", "column", "[", "j", "]", "=", "true", ";", "}", "else", "{", "if", "(", "poleInt", "[", "80", "*", "8", "+", "80", "*", "j", "+", "i", "-", "80", "]", "==", "Color", ".", "WHITE", ")", "column", "[", "j", "]", "=", "false", ";", "else", "column", "[", "j", "]", "=", "true", ";", "}", "}", "for", "(", "int", "j", "=", "0", ";", "j", "<", "8", ";", "j", "++", ")", "{", "if", "(", "column", "[", "j", "]", ")", "display", "[", "i", "]", "+=", "Math", ".", "pow", "(", "2", ",", "j", ")", ";", "}", "}", "return", "display", ";", "}", "public", "static", "byte", "[", "]", "createOled2lines", "(", "Context", "context", ",", "String", "line1", ",", "String", "line2", ")", "{", "int", "offset", "=", "0", ";", "Bitmap", "image", "=", "Bitmap", ".", "createBitmap", "(", "80", ",", "16", ",", "Bitmap", ".", "Config", ".", "RGB_565", ")", ";", "Canvas", "canvas", "=", "new", "Canvas", "(", "image", ")", ";", "Paint", "paint", "=", "new", "Paint", "(", ")", ";", "paint", ".", "setColor", "(", "Color", ".", "BLACK", ")", ";", "paint", ".", "setTextSize", "(", "8", ")", ";", "Typeface", "typeface", "=", "Typeface", ".", "createFromAsset", "(", "context", ".", "getAssets", "(", ")", ",", "\"\"", ")", ";", "paint", ".", "setTypeface", "(", "typeface", ")", ";", "canvas", ".", "drawColor", "(", "Color", ".", "WHITE", ")", ";", "canvas", ".", "drawText", "(", "line1", ",", "offset", ",", "7", ",", "paint", ")", ";", "canvas", ".", "drawText", "(", "line2", ",", "offset", ",", "15", ",", "paint", ")", ";", "int", "poleInt", "[", "]", "=", "new", "int", "[", "16", "*", "80", "]", ";", "image", ".", "getPixels", "(", "poleInt", ",", "0", ",", "80", ",", "0", ",", "0", ",", "80", ",", "16", ")", ";", "byte", "[", "]", "display", "=", "new", "byte", "[", "160", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "160", ";", "i", "++", ")", "{", "boolean", "[", "]", "column", "=", "new", "boolean", "[", "8", "]", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "8", ";", "j", "++", ")", "{", "if", "(", "i", "<", "80", ")", "{", "if", "(", "poleInt", "[", "80", "*", "j", "+", "i", "]", "==", "Color", ".", "WHITE", ")", "column", "[", "j", "]", "=", "false", ";", "else", "column", "[", "j", "]", "=", "true", ";", "}", "else", "{", "if", "(", "poleInt", "[", "80", "*", "8", "+", "80", "*", "j", "+", "i", "-", "80", "]", "==", "Color", ".", "WHITE", ")", "column", "[", "j", "]", "=", "false", ";", "else", "column", "[", "j", "]", "=", "true", ";", "}", "}", "for", "(", "int", "j", "=", "0", ";", "j", "<", "8", ";", "j", "++", ")", "{", "if", "(", "column", "[", "j", "]", ")", "display", "[", "i", "]", "+=", "Math", ".", "pow", "(", "2", ",", "j", ")", ";", "}", "}", "return", "display", ";", "}", "public", "static", "int", "createOled2linesLong", "(", "Context", "context", ",", "String", "line", ",", "byte", "[", "]", "display", ")", "{", "int", "offset", "=", "0", "-", "79", ";", "final", "int", "width", "=", "800", ";", "Bitmap", "image", "=", "Bitmap", ".", "createBitmap", "(", "width", ",", "8", ",", "Bitmap", ".", "Config", ".", "RGB_565", ")", ";", "Canvas", "canvas", "=", "new", "Canvas", "(", "image", ")", ";", "Paint", "paint", "=", "new", "Paint", "(", ")", ";", "paint", ".", "setColor", "(", "Color", ".", "BLACK", ")", ";", "paint", ".", "setTextSize", "(", "8", ")", ";", "Typeface", "typeface", "=", "Typeface", ".", "createFromAsset", "(", "context", ".", "getAssets", "(", ")", ",", "\"\"", ")", ";", "paint", ".", "setTypeface", "(", "typeface", ")", ";", "canvas", ".", "drawColor", "(", "Color", ".", "WHITE", ")", ";", "canvas", ".", "drawText", "(", "line", ",", "offset", ",", "7", ",", "paint", ")", ";", "int", "poleInt", "[", "]", "=", "new", "int", "[", "8", "*", "width", "]", ";", "image", ".", "getPixels", "(", "poleInt", ",", "0", ",", "width", ",", "0", ",", "0", ",", "width", ",", "8", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "width", ";", "i", "++", ")", "{", "boolean", "[", "]", "column", "=", "new", "boolean", "[", "8", "]", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "8", ";", "j", "++", ")", "{", "if", "(", "poleInt", "[", "width", "*", "j", "+", "i", "]", "==", "Color", ".", "WHITE", ")", "column", "[", "j", "]", "=", "false", ";", "else", "column", "[", "j", "]", "=", "true", ";", "}", "for", "(", "int", "j", "=", "0", ";", "j", "<", "8", ";", "j", "++", ")", "{", "if", "(", "column", "[", "j", "]", ")", "display", "[", "i", "]", "+=", "Math", ".", "pow", "(", "2", ",", "j", ")", ";", "}", "}", "int", "len", "=", "(", "int", ")", "paint", ".", "measureText", "(", "line", ")", ";", "return", "(", "int", ")", "paint", ".", "measureText", "(", "line", ")", "-", "79", ";", "}", "public", "static", "void", "sendOledDisplay", "(", "byte", "[", "]", "display", ",", "boolean", "top", ",", "boolean", "scroll", ")", "{", "try", "{", "byte", "[", "]", "bytes", ";", "for", "(", "int", "a", "=", "0", ";", "a", "<", "160", ";", "a", "+=", "20", ")", "{", "bytes", "=", "new", "byte", "[", "27", "]", ";", "bytes", "[", "0", "]", "=", "Message", ".", "start", ";", "bytes", "[", "1", "]", "=", "(", "byte", ")", "(", "bytes", ".", "length", "+", "2", ")", ";", "bytes", "[", "2", "]", "=", "Message", ".", "OledWriteBufferMsg", ".", "msg", ";", "if", "(", "scroll", ")", "bytes", "[", "3", "]", "=", "(", "byte", ")", "0x82", ";", "else", "bytes", "[", "3", "]", "=", "0x02", ";", "if", "(", "top", ")", "bytes", "[", "4", "]", "=", "0x00", ";", "else", "bytes", "[", "4", "]", "=", "0x01", ";", "bytes", "[", "5", "]", "=", "(", "byte", ")", "a", ";", "bytes", "[", "6", "]", "=", "0x14", ";", "System", ".", "arraycopy", "(", "display", ",", "a", ",", "bytes", ",", "7", ",", "20", ")", ";", "sendQueue", ".", "add", "(", "bytes", ")", ";", "processSendQueue", "(", ")", ";", "}", "updateOledNotification", "(", "top", ",", "scroll", ")", ";", "}", "catch", "(", "Exception", "x", ")", "{", "}", "}", "public", "static", "void", "updateOledNotification", "(", "boolean", "top", ",", "boolean", "scroll", ")", "{", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "7", "]", ";", "bytes", "[", "0", "]", "=", "Message", ".", "start", ";", "bytes", "[", "1", "]", "=", "(", "byte", ")", "(", "bytes", ".", "length", "+", "2", ")", ";", "bytes", "[", "2", "]", "=", "Message", ".", "OledWriteBufferMsg", ".", "msg", ";", "if", "(", "scroll", ")", "bytes", "[", "3", "]", "=", "(", "byte", ")", "0xC2", ";", "else", "bytes", "[", "3", "]", "=", "0x42", ";", "if", "(", "top", ")", "bytes", "[", "4", "]", "=", "0x00", ";", "else", "bytes", "[", "4", "]", "=", "0x01", ";", "bytes", "[", "5", "]", "=", "0x00", ";", "bytes", "[", "6", "]", "=", "0x00", ";", "sendQueue", ".", "add", "(", "bytes", ")", ";", "processSendQueue", "(", ")", ";", "}", "public", "static", "void", "updateOledsNotification", "(", ")", "{", "updateOledNotification", "(", "true", ",", "false", ")", ";", "updateOledNotification", "(", "false", ",", "false", ")", ";", "}", "public", "static", "void", "sendOledBuffer", "(", "boolean", "startScroll", ")", "{", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "25", "]", ";", "bytes", "[", "0", "]", "=", "Message", ".", "start", ";", "bytes", "[", "1", "]", "=", "(", "byte", ")", "(", "bytes", ".", "length", "+", "2", ")", ";", "bytes", "[", "2", "]", "=", "Message", ".", "OledWriteScrollBufferMsg", ".", "msg", ";", "if", "(", "startScroll", ")", "bytes", "[", "3", "]", "=", "0x02", ";", "else", "bytes", "[", "3", "]", "=", "0x00", ";", "bytes", "[", "4", "]", "=", "20", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "20", ";", "i", "++", ")", "bytes", "[", "5", "+", "i", "]", "=", "(", "byte", ")", "0xAA", ";", "sendQueue", ".", "add", "(", "bytes", ")", ";", "processSendQueue", "(", ")", ";", "}", "public", "static", "void", "sendOledBufferPart", "(", "byte", "[", "]", "display", ",", "int", "start", ",", "int", "length", ",", "boolean", "startScroll", ",", "boolean", "last", ")", "{", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"\"", "+", "start", "+", "\",", "length:", "\"", "+", "length", ")", ";", "for", "(", "int", "j", "=", "start", ";", "j", "<", "start", "+", "length", ";", "j", "+=", "20", ")", "{", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "25", "]", ";", "bytes", "[", "0", "]", "=", "Message", ".", "start", ";", "bytes", "[", "1", "]", "=", "(", "byte", ")", "(", "bytes", ".", "length", "+", "2", ")", ";", "bytes", "[", "2", "]", "=", "Message", ".", "OledWriteScrollBufferMsg", ".", "msg", ";", "bytes", "[", "3", "]", "=", "0x00", ";", "if", "(", "j", "+", "20", ">=", "start", "+", "length", ")", "{", "if", "(", "startScroll", ")", "bytes", "[", "3", "]", "=", "0x02", ";", "if", "(", "last", ")", "bytes", "[", "3", "]", "=", "0x01", ";", "if", "(", "startScroll", "&&", "last", ")", "bytes", "[", "3", "]", "=", "0x03", ";", "}", "bytes", "[", "4", "]", "=", "20", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "20", ";", "i", "++", ")", "bytes", "[", "5", "+", "i", "]", "=", "display", "[", "j", "+", "i", "]", ";", "sendQueue", ".", "add", "(", "bytes", ")", ";", "processSendQueue", "(", ")", ";", "}", "}", "}", "</s>" ]
8,217
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "android", ".", "app", ".", "Activity", ";", "import", "android", ".", "app", ".", "ProgressDialog", ";", "import", "android", ".", "bluetooth", ".", "BluetoothAdapter", ";", "import", "android", ".", "bluetooth", ".", "BluetoothDevice", ";", "import", "android", ".", "content", ".", "BroadcastReceiver", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "DialogInterface", ";", "import", "android", ".", "content", ".", "DialogInterface", ".", "OnCancelListener", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "content", ".", "IntentFilter", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "os", ".", "Handler", ";", "import", "android", ".", "os", ".", "Message", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "widget", ".", "AdapterView", ";", "import", "android", ".", "widget", ".", "AdapterView", ".", "OnItemClickListener", ";", "import", "android", ".", "widget", ".", "ListView", ";", "import", "android", ".", "widget", ".", "SimpleAdapter", ";", "import", "android", ".", "widget", ".", "Toast", ";", "public", "class", "DeviceSelection", "extends", "Activity", "{", "class", "Receiver", "extends", "BroadcastReceiver", "{", "@", "Override", "public", "void", "onReceive", "(", "Context", "context", ",", "Intent", "intent", ")", "{", "if", "(", "intent", ".", "getAction", "(", ")", ".", "equals", "(", "BluetoothAdapter", ".", "ACTION_DISCOVERY_FINISHED", ")", ")", "{", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"\"", ")", ";", "pdWait", ".", "dismiss", "(", ")", ";", "if", "(", "list", ".", "size", "(", ")", "==", "0", ")", "{", "sendToast", "(", "\"\"", ")", ";", "finish", "(", ")", ";", "}", "}", "if", "(", "intent", ".", "getAction", "(", ")", ".", "equals", "(", "BluetoothDevice", ".", "ACTION_FOUND", ")", ")", "{", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"device", "found\"", ")", ";", "BluetoothDevice", "device", "=", "intent", ".", "getParcelableExtra", "(", "BluetoothDevice", ".", "EXTRA_DEVICE", ")", ";", "if", "(", "device", ".", "getBondState", "(", ")", "==", "BluetoothDevice", ".", "BOND_BONDED", ")", "return", ";", "String", "deviceName", "=", "device", ".", "getName", "(", ")", ";", "String", "deviceMac", "=", "device", ".", "getAddress", "(", ")", ";", "addToList", "(", "deviceMac", ",", "deviceName", ")", ";", "}", "}", "}", "ProgressDialog", "pdWait", "=", "null", ";", "Context", "context", ";", "ListView", "listView", ";", "List", "<", "Map", "<", "String", ",", "String", ">", ">", "list", "=", "new", "ArrayList", "<", "Map", "<", "String", ",", "String", ">", ">", "(", ")", ";", "@", "Override", "protected", "void", "onCreate", "(", "Bundle", "savedInstanceState", ")", "{", "super", ".", "onCreate", "(", "savedInstanceState", ")", ";", "context", "=", "this", ";", "pdWait", "=", "ProgressDialog", ".", "show", "(", "this", ",", "\"Please", "wait\"", ",", "\"\"", ")", ";", "pdWait", ".", "setCancelable", "(", "true", ")", ";", "pdWait", ".", "setOnCancelListener", "(", "new", "OnCancelListener", "(", ")", "{", "public", "void", "onCancel", "(", "DialogInterface", "dialog", ")", "{", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"canceled\"", ")", ";", "if", "(", "MetaWatchService", ".", "bluetoothAdapter", ".", "isDiscovering", "(", ")", ")", "MetaWatchService", ".", "bluetoothAdapter", ".", "cancelDiscovery", "(", ")", ";", "finish", "(", ")", ";", "}", "}", ")", ";", "pdWait", ".", "show", "(", ")", ";", "setContentView", "(", "R", ".", "layout", ".", "device_selection", ")", ";", "listView", "=", "(", "ListView", ")", "findViewById", "(", "android", ".", "R", ".", "id", ".", "list", ")", ";", "listView", ".", "setOnItemClickListener", "(", "new", "OnItemClickListener", "(", ")", "{", "public", "void", "onItemClick", "(", "AdapterView", "<", "?", ">", "arg0", ",", "View", "arg1", ",", "int", "arg2", ",", "long", "arg3", ")", "{", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"\"", "+", "arg2", ")", ";", "Map", "<", "String", ",", "String", ">", "map", "=", "list", ".", "get", "(", "arg2", ")", ";", "String", "mac", "=", "map", ".", "get", "(", "\"mac\"", ")", ";", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"\"", "+", "mac", ")", ";", "MetaWatchService", ".", "Preferences", ".", "watchMacAddress", "=", "mac", ";", "MetaWatchService", ".", "saveMac", "(", "context", ",", "mac", ")", ";", "sendToast", "(", "\"\"", ")", ";", "finish", "(", ")", ";", "}", "}", ")", ";", "if", "(", "MetaWatchService", ".", "bluetoothAdapter", "==", "null", ")", "MetaWatchService", ".", "bluetoothAdapter", "=", "BluetoothAdapter", ".", "getDefaultAdapter", "(", ")", ";", "Set", "<", "BluetoothDevice", ">", "pairedDevices", "=", "MetaWatchService", ".", "bluetoothAdapter", ".", "getBondedDevices", "(", ")", ";", "if", "(", "pairedDevices", ".", "size", "(", ")", ">", "0", ")", "{", "for", "(", "BluetoothDevice", "device", ":", "pairedDevices", ")", "{", "addToList", "(", "device", ".", "getAddress", "(", ")", ",", "device", ".", "getName", "(", ")", ")", ";", "}", "}", "Receiver", "receiver", "=", "new", "Receiver", "(", ")", ";", "IntentFilter", "intentFilter", "=", "new", "IntentFilter", "(", "BluetoothAdapter", ".", "ACTION_DISCOVERY_FINISHED", ")", ";", "intentFilter", ".", "addAction", "(", "BluetoothDevice", ".", "ACTION_FOUND", ")", ";", "registerReceiver", "(", "receiver", ",", "intentFilter", ")", ";", "MetaWatchService", ".", "bluetoothAdapter", ".", "startDiscovery", "(", ")", ";", "}", "void", "addToList", "(", "String", "mac", ",", "String", "name", ")", "{", "Map", "<", "String", ",", "String", ">", "map", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "map", ".", "put", "(", "\"mac\"", ",", "mac", ")", ";", "map", ".", "put", "(", "\"name\"", ",", "name", ")", ";", "list", ".", "add", "(", "map", ")", ";", "displayList", "(", ")", ";", "}", "void", "displayList", "(", ")", "{", "listView", ".", "setAdapter", "(", "new", "SimpleAdapter", "(", "this", ",", "list", ",", "R", ".", "layout", ".", "list_item", ",", "new", "String", "[", "]", "{", "\"name\"", ",", "\"mac\"", "}", ",", "new", "int", "[", "]", "{", "R", ".", "id", ".", "text1", ",", "R", ".", "id", ".", "text2", "}", ")", ")", ";", "}", "public", "void", "sendToast", "(", "String", "text", ")", "{", "Message", "m", "=", "new", "Message", "(", ")", ";", "m", ".", "what", "=", "1", ";", "m", ".", "obj", "=", "text", ";", "messageHandler", ".", "sendMessage", "(", "m", ")", ";", "}", "private", "Handler", "messageHandler", "=", "new", "Handler", "(", ")", "{", "@", "Override", "public", "void", "handleMessage", "(", "Message", "msg", ")", "{", "switch", "(", "msg", ".", "what", ")", "{", "case", "1", ":", "Toast", ".", "makeText", "(", "context", ",", "(", "CharSequence", ")", "msg", ".", "obj", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "break", ";", "}", "}", "}", ";", "@", "Override", "protected", "void", "onDestroy", "(", ")", "{", "super", ".", "onDestroy", "(", ")", ";", "}", "}", "</s>" ]
8,218
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "telephony", ".", "PhoneStateListener", ";", "import", "android", ".", "telephony", ".", "TelephonyManager", ";", "class", "CallStateListener", "extends", "PhoneStateListener", "{", "Context", "context", ";", "public", "CallStateListener", "(", "Context", "ctx", ")", "{", "super", "(", ")", ";", "context", "=", "ctx", ";", "}", "@", "Override", "public", "void", "onCallStateChanged", "(", "int", "state", ",", "String", "incomingNumber", ")", "{", "super", ".", "onCallStateChanged", "(", "state", ",", "incomingNumber", ")", ";", "if", "(", "!", "MetaWatchService", ".", "Preferences", ".", "notifyCall", ")", "return", ";", "if", "(", "incomingNumber", "==", "null", ")", "incomingNumber", "=", "\"\"", ";", "switch", "(", "state", ")", "{", "case", "TelephonyManager", ".", "CALL_STATE_RINGING", ":", "Call", ".", "startCall", "(", "context", ",", "incomingNumber", ")", ";", "break", ";", "case", "TelephonyManager", ".", "CALL_STATE_IDLE", ":", "Call", ".", "endCall", "(", "context", ")", ";", "break", ";", "case", "TelephonyManager", ".", "CALL_STATE_OFFHOOK", ":", "Call", ".", "endCall", "(", "context", ")", ";", "break", ";", "}", "}", "}", "</s>" ]
8,219
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "org", ".", "metawatch", ".", "manager", ".", "MetaWatchService", ".", "WatchType", ";", "import", "org", ".", "metawatch", ".", "manager", ".", "Notification", ".", "VibratePattern", ";", "import", "android", ".", "app", ".", "Activity", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "view", ".", "Menu", ";", "import", "android", ".", "view", ".", "MenuInflater", ";", "import", "android", ".", "view", ".", "MenuItem", ";", "public", "class", "Test", "extends", "Activity", "{", "@", "Override", "protected", "void", "onCreate", "(", "Bundle", "savedInstanceState", ")", "{", "super", ".", "onCreate", "(", "savedInstanceState", ")", ";", "setTitle", "(", "getString", "(", "R", ".", "string", ".", "app_name", ")", "+", "\"", "-", "\"", "+", "getString", "(", "R", ".", "string", ".", "activitiy_title_tests", ")", ")", ";", "}", "@", "Override", "public", "boolean", "onCreateOptionsMenu", "(", "Menu", "menu", ")", "{", "MenuInflater", "inflater", "=", "getMenuInflater", "(", ")", ";", "inflater", ".", "inflate", "(", "R", ".", "menu", ".", "test", ",", "menu", ")", ";", "return", "true", ";", "}", "@", "Override", "public", "boolean", "onOptionsItemSelected", "(", "MenuItem", "item", ")", "{", "switch", "(", "item", ".", "getItemId", "(", ")", ")", "{", "case", "R", ".", "id", ".", "notification", ":", "if", "(", "MetaWatchService", ".", "watchType", "==", "WatchType", ".", "DIGITAL", ")", "Notification", ".", "addTextNotification", "(", "this", ",", "\"Notification\"", ",", "new", "VibratePattern", "(", "true", ",", "500", ",", "500", ",", "3", ")", ",", "Notification", ".", "notificationTimeout", ")", ";", "else", "Notification", ".", "addOledNotification", "(", "this", ",", "Protocol", ".", "createOled2lines", "(", "this", ",", "\"\"", ",", "\"\"", ")", ",", "Protocol", ".", "createOled2lines", "(", "this", ",", "\"\"", ",", "\"\"", ")", ",", "null", ",", "0", ",", "null", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "application_start", ":", "if", "(", "MetaWatchService", ".", "watchType", "==", "WatchType", ".", "DIGITAL", ")", "Application", ".", "startAppMode", "(", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "sms_start", ":", "startSmsTestLoop", "(", "this", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "sms_stop", ":", "stopSmsTestLoop", "(", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "application_update", ":", "if", "(", "MetaWatchService", ".", "watchType", "==", "WatchType", ".", "DIGITAL", ")", "Application", ".", "updateAppMode", "(", "this", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "application_stop", ":", "if", "(", "MetaWatchService", ".", "watchType", "==", "WatchType", ".", "DIGITAL", ")", "Application", ".", "stopAppMode", "(", "this", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "sms", ":", "NotificationBuilder", ".", "createSMS", "(", "this", ",", "\"555-123-456\"", ",", "\"\"", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "k9", ":", "NotificationBuilder", ".", "createK9", "(", "this", ",", "\"[email protected]\"", ",", "\"Subject", "line\"", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "alarm", ":", "NotificationBuilder", ".", "createAlarm", "(", "this", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "music", ":", "NotificationBuilder", ".", "createMusic", "(", "this", ",", "\"Park\"", ",", "\"\"", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "call_start", ":", "Call", ".", "startCall", "(", "this", ",", "\"555-123-4567\"", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "call_stop", ":", "Call", ".", "endCall", "(", "this", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "vibrate", ":", "Protocol", ".", "vibrate", "(", "300", ",", "500", ",", "3", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "set_rtc", ":", "Protocol", ".", "sendRtcNow", "(", "this", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "load_template", ":", "if", "(", "MetaWatchService", ".", "watchType", "==", "WatchType", ".", "DIGITAL", ")", "Protocol", ".", "loadTemplate", "(", "0", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "activate_buffer", ":", "if", "(", "MetaWatchService", ".", "watchType", "==", "WatchType", ".", "DIGITAL", ")", "Protocol", ".", "activateBuffer", "(", "0", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "update_display", ":", "if", "(", "MetaWatchService", ".", "watchType", "==", "WatchType", ".", "DIGITAL", ")", "Protocol", ".", "updateDisplay", "(", "0", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "write_bufer", ":", "if", "(", "MetaWatchService", ".", "watchType", "==", "WatchType", ".", "DIGITAL", ")", "Protocol", ".", "writeBuffer", "(", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "test", ":", "{", "Protocol", ".", "setNvalTime", "(", "true", ")", ";", "}", "return", "true", ";", "default", ":", "return", "super", ".", "onOptionsItemSelected", "(", "item", ")", ";", "}", "}", "void", "startSmsTestLoop", "(", "final", "Context", "context", ")", "{", "if", "(", "MetaWatchService", ".", "testSmsLoop", "!=", "null", ")", "MetaWatchService", ".", "testSmsLoop", ".", "stop", "(", ")", ";", "MetaWatchService", ".", "testSmsLoop", "=", "new", "TestSmsLoop", "(", "context", ")", ";", "Thread", "thread", "=", "new", "Thread", "(", "MetaWatchService", ".", "testSmsLoop", ")", ";", "thread", ".", "start", "(", ")", ";", "}", "void", "stopSmsTestLoop", "(", ")", "{", "MetaWatchService", ".", "testSmsLoop", ".", "stop", "(", ")", ";", "}", "}", "</s>" ]
8,220
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "preference", ".", "EditTextPreference", ";", "import", "android", ".", "preference", ".", "Preference", ";", "import", "android", ".", "preference", ".", "Preference", ".", "OnPreferenceClickListener", ";", "import", "android", ".", "preference", ".", "PreferenceActivity", ";", "import", "android", ".", "preference", ".", "PreferenceScreen", ";", "import", "android", ".", "util", ".", "Log", ";", "public", "class", "Settings", "extends", "PreferenceActivity", "{", "Context", "context", ";", "PreferenceScreen", "preferenceScreen", ";", "Preference", "discovery", ";", "EditTextPreference", "editTextMac", ";", "@", "Override", "protected", "void", "onCreate", "(", "Bundle", "savedInstanceState", ")", "{", "super", ".", "onCreate", "(", "savedInstanceState", ")", ";", "context", "=", "this", ";", "setTitle", "(", "getString", "(", "R", ".", "string", ".", "app_name", ")", "+", "\"", "-", "\"", "+", "getString", "(", "R", ".", "string", ".", "activitiy_title_settings", ")", ")", ";", "addPreferencesFromResource", "(", "R", ".", "layout", ".", "settings", ")", ";", "preferenceScreen", "=", "getPreferenceScreen", "(", ")", ";", "}", "@", "Override", "protected", "void", "onStart", "(", ")", "{", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"set", "onstart\"", ")", ";", "editTextMac", "=", "(", "EditTextPreference", ")", "preferenceScreen", ".", "findPreference", "(", "\"MAC\"", ")", ";", "editTextMac", ".", "setText", "(", "MetaWatchService", ".", "Preferences", ".", "watchMacAddress", ")", ";", "discovery", "=", "preferenceScreen", ".", "findPreference", "(", "\"Discovery\"", ")", ";", "discovery", ".", "setOnPreferenceClickListener", "(", "new", "OnPreferenceClickListener", "(", ")", "{", "public", "boolean", "onPreferenceClick", "(", "Preference", "arg0", ")", "{", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"\"", ")", ";", "startActivity", "(", "new", "Intent", "(", "context", ",", "DeviceSelection", ".", "class", ")", ")", ";", "return", "false", ";", "}", "}", ")", ";", "super", ".", "onStart", "(", ")", ";", "}", "}", "</s>" ]
8,221
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "android", ".", "content", ".", "BroadcastReceiver", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "telephony", ".", "SmsMessage", ";", "import", "android", ".", "util", ".", "Log", ";", "public", "class", "IntentReceiver", "extends", "BroadcastReceiver", "{", "@", "Override", "public", "void", "onReceive", "(", "Context", "context", ",", "Intent", "intent", ")", "{", "String", "action", "=", "intent", ".", "getAction", "(", ")", ";", "if", "(", "action", ".", "equals", "(", "\"\"", ")", ")", "{", "if", "(", "!", "MetaWatchService", ".", "Preferences", ".", "notifyGmail", ")", "return", ";", "if", "(", "!", "Utils", ".", "isGmailAccessSupported", "(", "context", ")", ")", "{", "String", "recipient", "=", "\"You\"", ";", "Bundle", "bundle", "=", "intent", ".", "getExtras", "(", ")", ";", "if", "(", "bundle", ".", "containsKey", "(", "\"account\"", ")", ")", "recipient", "=", "bundle", ".", "getString", "(", "\"account\"", ")", ";", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"count", "for", "\"", "+", "recipient", "+", "\":", "\"", "+", "bundle", ".", "getInt", "(", "\"count\"", ")", ")", ";", "int", "count", "=", "bundle", ".", "getInt", "(", "\"count\"", ")", ";", "Monitors", ".", "updateGmailUnreadCount", "(", "recipient", ",", "count", ")", ";", "if", "(", "count", ">", "0", ")", "NotificationBuilder", ".", "createGmailBlank", "(", "context", ",", "recipient", ")", ";", "else", "Idle", ".", "updateLcdIdle", "(", "context", ")", ";", "return", ";", "}", "}", "if", "(", "action", ".", "equals", "(", "\"\"", ")", ")", "{", "if", "(", "!", "MetaWatchService", ".", "Preferences", ".", "notifySMS", ")", "return", ";", "Bundle", "bundle", "=", "intent", ".", "getExtras", "(", ")", ";", "if", "(", "bundle", ".", "containsKey", "(", "\"pdus\"", ")", ")", "{", "Object", "[", "]", "pdus", "=", "(", "Object", "[", "]", ")", "bundle", ".", "get", "(", "\"pdus\"", ")", ";", "SmsMessage", "[", "]", "smsMessage", "=", "new", "SmsMessage", "[", "pdus", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "smsMessage", ".", "length", ";", "i", "++", ")", "{", "smsMessage", "[", "i", "]", "=", "SmsMessage", ".", "createFromPdu", "(", "(", "byte", "[", "]", ")", "pdus", "[", "i", "]", ")", ";", "String", "number", "=", "smsMessage", "[", "i", "]", ".", "getOriginatingAddress", "(", ")", ";", "String", "body", "=", "smsMessage", "[", "i", "]", ".", "getDisplayMessageBody", "(", ")", ";", "NotificationBuilder", ".", "createSMS", "(", "context", ",", "number", ",", "body", ")", ";", "}", "}", "return", ";", "}", "if", "(", "action", ".", "equals", "(", "\"\"", ")", ")", "{", "if", "(", "!", "MetaWatchService", ".", "Preferences", ".", "notifyK9", ")", "return", ";", "Bundle", "bundle", "=", "intent", ".", "getExtras", "(", ")", ";", "String", "subject", "=", "bundle", ".", "getString", "(", "\"\"", ")", ";", "String", "sender", "=", "bundle", ".", "getString", "(", "\"\"", ")", ";", "NotificationBuilder", ".", "createK9", "(", "context", ",", "sender", ",", "subject", ")", ";", "return", ";", "}", "if", "(", "action", ".", "equals", "(", "\"\"", ")", "||", "action", ".", "equals", "(", "\"\"", ")", "||", "action", ".", "equals", "(", "\"\"", ")", "||", "action", ".", "equals", "(", "\"\"", ")", ")", "{", "if", "(", "!", "MetaWatchService", ".", "Preferences", ".", "notifyAlarm", ")", "return", ";", "NotificationBuilder", ".", "createAlarm", "(", "context", ")", ";", "return", ";", "}", "if", "(", "intent", ".", "getAction", "(", ")", ".", "equals", "(", "\"\"", ")", "||", "intent", ".", "getAction", "(", ")", ".", "equals", "(", "\"\"", ")", ")", "{", "if", "(", "!", "MetaWatchService", ".", "Preferences", ".", "notifyMusic", ")", "return", ";", "String", "artist", "=", "\"\"", ";", "String", "track", "=", "\"\"", ";", "if", "(", "intent", ".", "hasExtra", "(", "\"artist\"", ")", ")", "artist", "=", "intent", ".", "getStringExtra", "(", "\"artist\"", ")", ";", "if", "(", "intent", ".", "hasExtra", "(", "\"track\"", ")", ")", "track", "=", "intent", ".", "getStringExtra", "(", "\"track\"", ")", ";", "NotificationBuilder", ".", "createMusic", "(", "context", ",", "artist", ",", "track", ")", ";", "return", ";", "}", "}", "}", "</s>" ]
8,222
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "android", ".", "content", ".", "BroadcastReceiver", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "util", ".", "Log", ";", "public", "class", "AlarmReceiver", "extends", "BroadcastReceiver", "{", "@", "Override", "public", "void", "onReceive", "(", "Context", "context", ",", "Intent", "intent", ")", "{", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"intent", "rec:", "\"", "+", "intent", ".", "toString", "(", ")", ")", ";", "if", "(", "intent", ".", "hasExtra", "(", "\"\"", ")", ")", "{", "Monitors", ".", "updateWeatherData", "(", "context", ")", ";", "return", ";", "}", "}", "}", "</s>" ]
8,223
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "util", ".", "Hashtable", ";", "import", "javax", ".", "xml", ".", "parsers", ".", "SAXParser", ";", "import", "javax", ".", "xml", ".", "parsers", ".", "SAXParserFactory", ";", "import", "org", ".", "anddev", ".", "android", ".", "weatherforecast", ".", "weather", ".", "GoogleWeatherHandler", ";", "import", "org", ".", "anddev", ".", "android", ".", "weatherforecast", ".", "weather", ".", "WeatherCurrentCondition", ";", "import", "org", ".", "anddev", ".", "android", ".", "weatherforecast", ".", "weather", ".", "WeatherForecastCondition", ";", "import", "org", ".", "anddev", ".", "android", ".", "weatherforecast", ".", "weather", ".", "WeatherSet", ";", "import", "org", ".", "anddev", ".", "android", ".", "weatherforecast", ".", "weather", ".", "WeatherUtils", ";", "import", "org", ".", "metawatch", ".", "manager", ".", "MetaWatchService", ".", "Preferences", ";", "import", "org", ".", "xml", ".", "sax", ".", "InputSource", ";", "import", "org", ".", "xml", ".", "sax", ".", "XMLReader", ";", "import", "android", ".", "app", ".", "AlarmManager", ";", "import", "android", ".", "app", ".", "PendingIntent", ";", "import", "android", ".", "content", ".", "ContentResolver", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "database", ".", "ContentObserver", ";", "import", "android", ".", "net", ".", "Uri", ";", "import", "android", ".", "telephony", ".", "PhoneStateListener", ";", "import", "android", ".", "telephony", ".", "TelephonyManager", ";", "import", "android", ".", "util", ".", "Log", ";", "public", "class", "Monitors", "{", "public", "static", "AlarmManager", "alarmManager", ";", "public", "static", "Intent", "intent", ";", "public", "static", "PendingIntent", "sender", ";", "static", "GmailMonitor", "gmailMonitor", ";", "private", "static", "ContentObserverMessages", "contentObserverMessages", ";", "static", "ContentResolver", "contentResolverMessages", ";", "private", "static", "ContentObserverCalls", "contentObserverCalls", ";", "static", "ContentResolver", "contentResolverCalls", ";", "static", "Hashtable", "<", "String", ",", "Integer", ">", "gmailUnreadCounts", "=", "new", "Hashtable", "<", "String", ",", "Integer", ">", "(", ")", ";", "public", "static", "class", "WeatherData", "{", "public", "static", "boolean", "received", "=", "false", ";", "public", "static", "String", "icon", ";", "public", "static", "String", "tempHigh", ";", "public", "static", "String", "tempLow", ";", "public", "static", "String", "temp", ";", "public", "static", "String", "condition", ";", "public", "static", "String", "city", ";", "}", "public", "static", "void", "updateGmailUnreadCount", "(", "String", "account", ",", "int", "count", ")", "{", "gmailUnreadCounts", ".", "put", "(", "account", ",", "count", ")", ";", "}", "public", "static", "int", "getGmailUnreadCount", "(", ")", "{", "int", "count", "=", "0", ";", "for", "(", "int", "i", ":", "gmailUnreadCounts", ".", "values", "(", ")", ")", "count", "+=", "i", ";", "return", "count", ";", "}", "public", "static", "void", "start", "(", "Context", "context", ",", "TelephonyManager", "telephonyManager", ")", "{", "updateWeatherData", "(", "context", ")", ";", "CallStateListener", "phoneListener", "=", "new", "CallStateListener", "(", "context", ")", ";", "telephonyManager", "=", "(", "TelephonyManager", ")", "context", ".", "getSystemService", "(", "Context", ".", "TELEPHONY_SERVICE", ")", ";", "int", "phoneEvents", "=", "PhoneStateListener", ".", "LISTEN_CALL_STATE", ";", "telephonyManager", ".", "listen", "(", "phoneListener", ",", "phoneEvents", ")", ";", "if", "(", "Utils", ".", "isGmailAccessSupported", "(", "context", ")", ")", "{", "gmailMonitor", "=", "new", "GmailMonitor", "(", "context", ")", ";", "gmailMonitor", ".", "startMonitor", "(", ")", ";", "}", "try", "{", "contentObserverMessages", "=", "new", "ContentObserverMessages", "(", "context", ")", ";", "Uri", "uri", "=", "Uri", ".", "parse", "(", "\"\"", ")", ";", "contentResolverMessages", "=", "context", ".", "getContentResolver", "(", ")", ";", "contentResolverMessages", ".", "registerContentObserver", "(", "uri", ",", "true", ",", "contentObserverMessages", ")", ";", "}", "catch", "(", "Exception", "x", ")", "{", "}", "try", "{", "contentObserverCalls", "=", "new", "ContentObserverCalls", "(", "context", ")", ";", "contentResolverCalls", "=", "context", ".", "getContentResolver", "(", ")", ";", "contentResolverCalls", ".", "registerContentObserver", "(", "android", ".", "provider", ".", "CallLog", ".", "Calls", ".", "CONTENT_URI", ",", "true", ",", "contentObserverCalls", ")", ";", "}", "catch", "(", "Exception", "x", ")", "{", "}", "startAlarmTicker", "(", "context", ")", ";", "}", "public", "static", "void", "stop", "(", ")", "{", "contentResolverMessages", ".", "unregisterContentObserver", "(", "contentObserverMessages", ")", ";", "stopAlarmTicker", "(", ")", ";", "}", "public", "static", "void", "updateWeatherData", "(", "Context", "context", ")", "{", "try", "{", "URL", "url", ";", "String", "queryString", "=", "\"\"", "+", "Preferences", ".", "weatherCity", ";", "url", "=", "new", "URL", "(", "queryString", ".", "replace", "(", "\"", "\"", ",", "\"%20\"", ")", ")", ";", "SAXParserFactory", "spf", "=", "SAXParserFactory", ".", "newInstance", "(", ")", ";", "SAXParser", "sp", "=", "spf", ".", "newSAXParser", "(", ")", ";", "XMLReader", "xr", "=", "sp", ".", "getXMLReader", "(", ")", ";", "GoogleWeatherHandler", "gwh", "=", "new", "GoogleWeatherHandler", "(", ")", ";", "xr", ".", "setContentHandler", "(", "gwh", ")", ";", "InputSource", "src", "=", "new", "InputSource", "(", "url", ".", "openStream", "(", ")", ")", ";", "src", ".", "setEncoding", "(", "\"ISO-8859-1\"", ")", ";", "xr", ".", "parse", "(", "src", ")", ";", "WeatherSet", "ws", "=", "gwh", ".", "getWeatherSet", "(", ")", ";", "WeatherCurrentCondition", "wcc", "=", "ws", ".", "getWeatherCurrentCondition", "(", ")", ";", "WeatherForecastCondition", "wfc", "=", "ws", ".", "getWeatherForecastConditions", "(", ")", ".", "get", "(", "0", ")", ";", "WeatherData", ".", "city", "=", "Preferences", ".", "weatherCity", ";", "String", "cond", "=", "wcc", ".", "getCondition", "(", ")", ";", "String", "temp", ";", "if", "(", "Preferences", ".", "weatherCelsius", ")", "{", "WeatherData", ".", "tempHigh", "=", "\"High", "\"", "+", "Integer", ".", "toString", "(", "wfc", ".", "getTempMaxCelsius", "(", ")", ")", ";", "WeatherData", ".", "tempLow", "=", "\"Low", "\"", "+", "Integer", ".", "toString", "(", "wfc", ".", "getTempMinCelsius", "(", ")", ")", ";", "temp", "=", "Integer", ".", "toString", "(", "wcc", ".", "getTempCelcius", "(", ")", ")", "+", "(", "char", ")", "0x00B0", "+", "\"C\"", ";", "}", "else", "{", "WeatherData", ".", "tempHigh", "=", "\"High", "\"", "+", "Integer", ".", "toString", "(", "WeatherUtils", ".", "celsiusToFahrenheit", "(", "wfc", ".", "getTempMaxCelsius", "(", ")", ")", ")", ";", "WeatherData", ".", "tempLow", "=", "\"Low", "\"", "+", "Integer", ".", "toString", "(", "WeatherUtils", ".", "celsiusToFahrenheit", "(", "wfc", ".", "getTempMinCelsius", "(", ")", ")", ")", ";", "temp", "=", "Integer", ".", "toString", "(", "wcc", ".", "getTempFahrenheit", "(", ")", ")", "+", "(", "char", ")", "0x00B0", "+", "\"F\"", ";", "}", "WeatherData", ".", "condition", "=", "cond", ";", "WeatherData", ".", "temp", "=", "temp", ";", "cond", "=", "cond", ".", "toLowerCase", "(", ")", ";", "if", "(", "cond", ".", "equals", "(", "\"clear\"", ")", "||", "cond", ".", "equals", "(", "\"mostly", "sunny\"", ")", "||", "cond", ".", "equals", "(", "\"partly", "sunny\"", ")", "||", "cond", ".", "equals", "(", "\"sunny\"", ")", ")", "WeatherData", ".", "icon", "=", "\"\"", ";", "else", "if", "(", "cond", ".", "equals", "(", "\"cloudy\"", ")", "||", "cond", ".", "equals", "(", "\"\"", ")", "||", "cond", ".", "equals", "(", "\"overcast\"", ")", "||", "cond", ".", "equals", "(", "\"\"", ")", ")", "WeatherData", ".", "icon", "=", "\"\"", ";", "else", "if", "(", "cond", ".", "equals", "(", "\"light", "rain\"", ")", "||", "cond", ".", "equals", "(", "\"rain\"", ")", "||", "cond", ".", "equals", "(", "\"rain", "showers\"", ")", "||", "cond", ".", "equals", "(", "\"showers\"", ")", "||", "cond", ".", "equals", "(", "\"\"", ")", "||", "cond", ".", "equals", "(", "\"\"", ")", "||", "cond", ".", "equals", "(", "\"\"", ")", "||", "cond", ".", "equals", "(", "\"\"", ")", "||", "cond", ".", "equals", "(", "\"\"", ")", ")", "WeatherData", ".", "icon", "=", "\"\"", ";", "else", "if", "(", "cond", ".", "equals", "(", "\"thunderstorm\"", ")", "||", "cond", ".", "equals", "(", "\"\"", ")", "||", "cond", ".", "equals", "(", "\"\"", ")", ")", "WeatherData", ".", "icon", "=", "\"\"", ";", "else", "if", "(", "cond", ".", "equals", "(", "\"\"", ")", "||", "cond", ".", "equals", "(", "\"snow", "showers\"", ")", "||", "cond", ".", "equals", "(", "\"ice/snow\"", ")", "||", "cond", ".", "equals", "(", "\"flurries\"", ")", ")", "WeatherData", ".", "icon", "=", "\"\"", ";", "else", "WeatherData", ".", "icon", "=", "\"\"", ";", "WeatherData", ".", "received", "=", "true", ";", "Idle", ".", "updateLcdIdle", "(", "context", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "Log", ".", "e", "(", "MetaWatch", ".", "TAG", ",", "e", ".", "toString", "(", ")", ")", ";", "}", "}", "static", "void", "startAlarmTicker", "(", "Context", "context", ")", "{", "alarmManager", "=", "(", "AlarmManager", ")", "context", ".", "getSystemService", "(", "Context", ".", "ALARM_SERVICE", ")", ";", "intent", "=", "new", "Intent", "(", "context", ",", "AlarmReceiver", ".", "class", ")", ";", "intent", ".", "putExtra", "(", "\"\"", ",", "\"update\"", ")", ";", "sender", "=", "PendingIntent", ".", "getBroadcast", "(", "context", ",", "1", ",", "intent", ",", "PendingIntent", ".", "FLAG_UPDATE_CURRENT", ")", ";", "alarmManager", ".", "setRepeating", "(", "AlarmManager", ".", "RTC_WAKEUP", ",", "0", ",", "30", "*", "60", "*", "1000", ",", "sender", ")", ";", "}", "static", "void", "stopAlarmTicker", "(", ")", "{", "alarmManager", ".", "cancel", "(", "sender", ")", ";", "}", "private", "static", "class", "ContentObserverMessages", "extends", "ContentObserver", "{", "Context", "context", ";", "public", "ContentObserverMessages", "(", "Context", "context", ")", "{", "super", "(", "null", ")", ";", "this", ".", "context", "=", "context", ";", "}", "@", "Override", "public", "void", "onChange", "(", "boolean", "selfChange", ")", "{", "super", ".", "onChange", "(", "selfChange", ")", ";", "Idle", ".", "updateLcdIdle", "(", "context", ")", ";", "}", "}", "private", "static", "class", "ContentObserverCalls", "extends", "ContentObserver", "{", "Context", "context", ";", "public", "ContentObserverCalls", "(", "Context", "context", ")", "{", "super", "(", "null", ")", ";", "this", ".", "context", "=", "context", ";", "}", "@", "Override", "public", "void", "onChange", "(", "boolean", "selfChange", ")", "{", "super", ".", "onChange", "(", "selfChange", ")", ";", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "\"\"", ")", ";", "Idle", ".", "updateLcdIdle", "(", "context", ")", ";", "}", "}", "}", "</s>" ]
8,224
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "org", ".", "metawatch", ".", "manager", ".", "MetaWatchService", ".", "WatchType", ";", "public", "class", "CallVibrate", "implements", "Runnable", "{", "public", "void", "run", "(", ")", "{", "while", "(", "Call", ".", "isRinging", ")", "{", "Protocol", ".", "vibrate", "(", "1000", ",", "0", ",", "1", ")", ";", "if", "(", "MetaWatchService", ".", "watchType", "==", "WatchType", ".", "DIGITAL", ")", "Protocol", ".", "updateDisplay", "(", "2", ")", ";", "else", "Protocol", ".", "updateOledsNotification", "(", ")", ";", "try", "{", "Thread", ".", "sleep", "(", "2000", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "}", "}", "}", "</s>" ]
8,225
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "media", ".", "AudioManager", ";", "public", "class", "MediaControl", "{", "final", "static", "byte", "VOLUME_UP", "=", "10", ";", "final", "static", "byte", "VOLUME_DOWN", "=", "11", ";", "final", "static", "byte", "NEXT", "=", "15", ";", "final", "static", "byte", "PREVIOUS", "=", "16", ";", "final", "static", "byte", "TOGGLE", "=", "20", ";", "public", "static", "void", "next", "(", "Context", "context", ")", "{", "context", ".", "sendBroadcast", "(", "new", "Intent", "(", "\"\"", ")", ")", ";", "}", "public", "static", "void", "previous", "(", "Context", "context", ")", "{", "context", ".", "sendBroadcast", "(", "new", "Intent", "(", "\"\"", ")", ")", ";", "}", "public", "static", "void", "togglePause", "(", "Context", "context", ")", "{", "context", ".", "sendBroadcast", "(", "new", "Intent", "(", "\"\"", ")", ")", ";", "}", "public", "static", "void", "volumeDown", "(", "AudioManager", "audioManager", ")", "{", "audioManager", ".", "adjustStreamVolume", "(", "AudioManager", ".", "STREAM_MUSIC", ",", "AudioManager", ".", "ADJUST_LOWER", ",", "0", ")", ";", "}", "public", "static", "void", "volumeUp", "(", "AudioManager", "audioManager", ")", "{", "audioManager", ".", "adjustStreamVolume", "(", "AudioManager", ".", "STREAM_MUSIC", ",", "AudioManager", ".", "ADJUST_RAISE", ",", "0", ")", ";", "}", "}", "</s>" ]
8,226
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "org", ".", "metawatch", ".", "manager", ".", "MetaWatchService", ".", "WatchType", ";", "import", "org", ".", "metawatch", ".", "manager", ".", "Notification", ".", "VibratePattern", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "graphics", ".", "Bitmap", ";", "public", "class", "Call", "{", "public", "static", "boolean", "isRinging", "=", "false", ";", "public", "static", "void", "startCall", "(", "Context", "context", ",", "String", "number", ")", "{", "toCall", "(", ")", ";", "isRinging", "=", "true", ";", "Bitmap", "bitmap", ";", "String", "name", "=", "Utils", ".", "getContactNameFromNumber", "(", "context", ",", "number", ")", ";", "if", "(", "name", ".", "equals", "(", "number", ")", ")", "bitmap", "=", "NotificationBuilder", ".", "smartLines", "(", "context", ",", "\"phone.bmp\"", ",", "new", "String", "[", "]", "{", "number", "}", ")", ";", "else", "bitmap", "=", "NotificationBuilder", ".", "smartLines", "(", "context", ",", "\"phone.bmp\"", ",", "new", "String", "[", "]", "{", "number", ",", "name", "}", ")", ";", "if", "(", "MetaWatchService", ".", "watchType", "==", "WatchType", ".", "DIGITAL", ")", "{", "Protocol", ".", "sendLcdBitmap", "(", "bitmap", ",", "MetaWatchService", ".", "WatchBuffers", ".", "NOTIFICATION", ")", ";", "Protocol", ".", "updateDisplay", "(", "2", ")", ";", "}", "else", "{", "Notification", ".", "addOledNotification", "(", "context", ",", "Protocol", ".", "createOled1line", "(", "context", ",", "\"phone.bmp\"", ",", "\"Call", "from\"", ")", ",", "Protocol", ".", "createOled1line", "(", "context", ",", "null", ",", "name", ")", ",", "null", ",", "0", ",", "new", "VibratePattern", "(", "true", ",", "500", ",", "500", ",", "3", ")", ")", ";", "}", "Thread", "ringer", "=", "new", "Thread", "(", "new", "CallVibrate", "(", ")", ")", ";", "ringer", ".", "start", "(", ")", ";", "}", "public", "static", "void", "endCall", "(", "Context", "context", ")", "{", "isRinging", "=", "false", ";", "exitCall", "(", "context", ")", ";", "}", "static", "void", "toCall", "(", ")", "{", "MetaWatchService", ".", "watchState", "=", "MetaWatchService", ".", "WatchStates", ".", "CALL", ";", "MetaWatchService", ".", "WatchModes", ".", "CALL", "=", "true", ";", "}", "static", "void", "exitCall", "(", "Context", "context", ")", "{", "MetaWatchService", ".", "WatchModes", ".", "CALL", "=", "false", ";", "if", "(", "MetaWatchService", ".", "WatchModes", ".", "NOTIFICATION", "==", "true", ")", "Notification", ".", "toNotification", "(", "context", ")", ";", "else", "if", "(", "MetaWatchService", ".", "WatchModes", ".", "APPLICATION", "==", "true", ")", "Application", ".", "toApp", "(", ")", ";", "else", "if", "(", "MetaWatchService", ".", "WatchModes", ".", "IDLE", "==", "true", ")", "Idle", ".", "toIdle", "(", "context", ")", ";", "}", "}", "</s>" ]
8,227
[ "<s>", "package", "org", ".", "metawatch", ".", "manager", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "android", ".", "accounts", ".", "Account", ";", "import", "android", ".", "accounts", ".", "AccountManager", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "pm", ".", "PackageInfo", ";", "import", "android", ".", "content", ".", "pm", ".", "PackageManager", ";", "import", "android", ".", "content", ".", "pm", ".", "PackageManager", ".", "NameNotFoundException", ";", "import", "android", ".", "database", ".", "Cursor", ";", "import", "android", ".", "graphics", ".", "Bitmap", ";", "import", "android", ".", "graphics", ".", "BitmapFactory", ";", "import", "android", ".", "net", ".", "Uri", ";", "import", "android", ".", "provider", ".", "CallLog", ";", "import", "android", ".", "provider", ".", "ContactsContract", ".", "PhoneLookup", ";", "import", "android", ".", "util", ".", "Log", ";", "public", "class", "Utils", "{", "public", "static", "String", "getContactNameFromNumber", "(", "Context", "context", ",", "String", "number", ")", "{", "if", "(", "number", ".", "equals", "(", "\"\"", ")", ")", "return", "\"\"", ";", "String", "[", "]", "projection", "=", "new", "String", "[", "]", "{", "PhoneLookup", ".", "DISPLAY_NAME", ",", "PhoneLookup", ".", "NUMBER", "}", ";", "Uri", "contactUri", "=", "Uri", ".", "withAppendedPath", "(", "PhoneLookup", ".", "CONTENT_FILTER_URI", ",", "Uri", ".", "encode", "(", "number", ")", ")", ";", "Cursor", "c", "=", "context", ".", "getContentResolver", "(", ")", ".", "query", "(", "contactUri", ",", "projection", ",", "null", ",", "null", ",", "null", ")", ";", "if", "(", "c", ".", "moveToFirst", "(", ")", ")", "{", "String", "name", "=", "c", ".", "getString", "(", "c", ".", "getColumnIndex", "(", "PhoneLookup", ".", "DISPLAY_NAME", ")", ")", ";", "if", "(", "name", ".", "length", "(", ")", ">", "0", ")", "return", "name", ";", "else", "return", "number", ";", "}", "return", "number", ";", "}", "public", "static", "int", "getUnreadSmsCount", "(", "Context", "context", ")", "{", "int", "count", "=", "0", ";", "Cursor", "cursor", "=", "context", ".", "getContentResolver", "(", ")", ".", "query", "(", "Uri", ".", "withAppendedPath", "(", "Uri", ".", "parse", "(", "\"\"", ")", ",", "\"inbox\"", ")", ",", "new", "String", "[", "]", "{", "\"_id\"", "}", ",", "\"read=0\"", ",", "null", ",", "null", ")", ";", "if", "(", "cursor", "!=", "null", ")", "{", "try", "{", "count", "=", "cursor", ".", "getCount", "(", ")", ";", "}", "finally", "{", "cursor", ".", "close", "(", ")", ";", "}", "}", "return", "count", ";", "}", "public", "static", "int", "getMissedCallsCount", "(", "Context", "context", ")", "{", "int", "missed", "=", "0", ";", "try", "{", "Cursor", "cursor", "=", "context", ".", "getContentResolver", "(", ")", ".", "query", "(", "android", ".", "provider", ".", "CallLog", ".", "Calls", ".", "CONTENT_URI", ",", "null", ",", "null", ",", "null", ",", "null", ")", ";", "cursor", ".", "moveToFirst", "(", ")", ";", "while", "(", "true", ")", "{", "if", "(", "cursor", ".", "getInt", "(", "cursor", ".", "getColumnIndex", "(", "CallLog", ".", "Calls", ".", "TYPE", ")", ")", "==", "3", ")", "missed", "+=", "cursor", ".", "getInt", "(", "cursor", ".", "getColumnIndex", "(", "CallLog", ".", "Calls", ".", "NEW", ")", ")", ";", "if", "(", "cursor", ".", "isLast", "(", ")", ")", "break", ";", "cursor", ".", "moveToNext", "(", ")", ";", "}", "}", "catch", "(", "Exception", "x", ")", "{", "}", "return", "missed", ";", "}", "public", "static", "int", "getUnreadGmailCount", "(", "Context", "context", ",", "String", "account", ",", "String", "label", ")", "{", "try", "{", "int", "nameColumn", "=", "0", ";", "Cursor", "c", "=", "context", ".", "getContentResolver", "(", ")", ".", "query", "(", "Uri", ".", "parse", "(", "\"\"", "+", "account", ")", ",", "null", ",", "null", ",", "null", ",", "null", ")", ";", "c", ".", "moveToFirst", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "c", ".", "getColumnCount", "(", ")", ";", "i", "++", ")", "if", "(", "c", ".", "getColumnName", "(", "i", ")", ".", "equals", "(", "\"\"", ")", ")", "{", "nameColumn", "=", "i", ";", "break", ";", "}", "while", "(", "true", ")", "{", "if", "(", "c", ".", "getString", "(", "nameColumn", ")", ".", "equals", "(", "label", ")", ")", "for", "(", "int", "i", "=", "0", ";", "i", "<", "c", ".", "getColumnCount", "(", ")", ";", "i", "++", ")", "{", "if", "(", "c", ".", "getColumnName", "(", "i", ")", ".", "equals", "(", "\"\"", ")", ")", "{", "return", "Integer", ".", "parseInt", "(", "c", ".", "getString", "(", "i", ")", ")", ";", "}", "}", "c", ".", "moveToNext", "(", ")", ";", "if", "(", "c", ".", "isLast", "(", ")", ")", "{", "break", ";", "}", "}", "}", "catch", "(", "Exception", "x", ")", "{", "Log", ".", "d", "(", "MetaWatch", ".", "TAG", ",", "x", ".", "toString", "(", ")", ")", ";", "}", "return", "0", ";", "}", "public", "static", "String", "getGoogleAccountName", "(", "Context", "context", ")", "{", "AccountManager", "accountManager", "=", "AccountManager", ".", "get", "(", "context", ")", ";", "Account", "[", "]", "accounts", "=", "accountManager", ".", "getAccounts", "(", ")", ";", "int", "count", "=", "accounts", ".", "length", ";", "Account", "account", "=", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "count", ";", "i", "++", ")", "{", "account", "=", "accounts", "[", "i", "]", ";", "if", "(", "account", ".", "type", ".", "equals", "(", "\"com.google\"", ")", ")", "{", "return", "account", ".", "name", ";", "}", "}", "return", "\"\"", ";", "}", "public", "static", "Bitmap", "loadBitmapFromAssets", "(", "Context", "context", ",", "String", "path", ")", "{", "try", "{", "InputStream", "inputStream", "=", "context", ".", "getAssets", "(", ")", ".", "open", "(", "path", ")", ";", "Bitmap", "bitmap", "=", "BitmapFactory", ".", "decodeStream", "(", "inputStream", ")", ";", "inputStream", ".", "close", "(", ")", ";", "return", "bitmap", ";", "}", "catch", "(", "IOException", "e", ")", "{", "return", "null", ";", "}", "}", "public", "static", "String", "getVersion", "(", "Context", "context", ")", "{", "try", "{", "PackageManager", "packageManager", "=", "context", ".", "getPackageManager", "(", ")", ";", "PackageInfo", "packageInfo", "=", "packageManager", ".", "getPackageInfo", "(", "context", ".", "getPackageName", "(", ")", ",", "0", ")", ";", "return", "packageInfo", ".", "versionName", ";", "}", "catch", "(", "NameNotFoundException", "e", ")", "{", "}", "return", "\"unknown\"", ";", "}", "public", "static", "boolean", "isGmailAccessSupported", "(", "Context", "context", ")", "{", "try", "{", "PackageManager", "packageManager", "=", "context", ".", "getPackageManager", "(", ")", ";", "PackageInfo", "packageInfo", "=", "packageManager", ".", "getPackageInfo", "(", "\"\"", ",", "0", ")", ";", "if", "(", "packageInfo", ".", "versionCode", "<", "169", ")", "return", "true", ";", "}", "catch", "(", "NameNotFoundException", "e", ")", "{", "}", "return", "false", ";", "}", "}", "</s>" ]
8,228
[ "<s>", "package", "org", ".", "anddev", ".", "android", ".", "weatherforecast", ".", "weather", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "public", "class", "WeatherSet", "{", "private", "WeatherCurrentCondition", "myCurrentCondition", "=", "null", ";", "private", "ArrayList", "<", "WeatherForecastCondition", ">", "myForecastConditions", "=", "new", "ArrayList", "<", "WeatherForecastCondition", ">", "(", "4", ")", ";", "public", "WeatherCurrentCondition", "getWeatherCurrentCondition", "(", ")", "{", "return", "myCurrentCondition", ";", "}", "public", "void", "setWeatherCurrentCondition", "(", "WeatherCurrentCondition", "myCurrentWeather", ")", "{", "this", ".", "myCurrentCondition", "=", "myCurrentWeather", ";", "}", "public", "ArrayList", "<", "WeatherForecastCondition", ">", "getWeatherForecastConditions", "(", ")", "{", "return", "this", ".", "myForecastConditions", ";", "}", "public", "WeatherForecastCondition", "getLastWeatherForecastCondition", "(", ")", "{", "return", "this", ".", "myForecastConditions", ".", "get", "(", "this", ".", "myForecastConditions", ".", "size", "(", ")", "-", "1", ")", ";", "}", "}", "</s>" ]
8,229
[ "<s>", "package", "org", ".", "anddev", ".", "android", ".", "weatherforecast", ".", "weather", ";", "import", "org", ".", "xml", ".", "sax", ".", "Attributes", ";", "import", "org", ".", "xml", ".", "sax", ".", "SAXException", ";", "import", "org", ".", "xml", ".", "sax", ".", "helpers", ".", "DefaultHandler", ";", "public", "class", "GoogleWeatherHandler", "extends", "DefaultHandler", "{", "@", "SuppressWarnings", "(", "\"unused\"", ")", "private", "String", "city", "=", "\"\"", ";", "private", "WeatherSet", "myWeatherSet", "=", "null", ";", "@", "SuppressWarnings", "(", "\"unused\"", ")", "private", "boolean", "in_forecast_information", "=", "false", ";", "private", "boolean", "in_current_conditions", "=", "false", ";", "private", "boolean", "in_forecast_conditions", "=", "false", ";", "private", "boolean", "usingSITemperature", "=", "false", ";", "public", "WeatherSet", "getWeatherSet", "(", ")", "{", "return", "this", ".", "myWeatherSet", ";", "}", "@", "Override", "public", "void", "startDocument", "(", ")", "throws", "SAXException", "{", "this", ".", "myWeatherSet", "=", "new", "WeatherSet", "(", ")", ";", "}", "@", "Override", "public", "void", "endDocument", "(", ")", "throws", "SAXException", "{", "}", "@", "Override", "public", "void", "startElement", "(", "String", "namespaceURI", ",", "String", "localName", ",", "String", "qName", ",", "Attributes", "atts", ")", "throws", "SAXException", "{", "if", "(", "localName", ".", "equals", "(", "\"\"", ")", ")", "{", "this", ".", "in_forecast_information", "=", "true", ";", "}", "else", "if", "(", "localName", ".", "equals", "(", "\"\"", ")", ")", "{", "this", ".", "myWeatherSet", ".", "setWeatherCurrentCondition", "(", "new", "WeatherCurrentCondition", "(", ")", ")", ";", "this", ".", "in_current_conditions", "=", "true", ";", "}", "else", "if", "(", "localName", ".", "equals", "(", "\"\"", ")", ")", "{", "this", ".", "myWeatherSet", ".", "getWeatherForecastConditions", "(", ")", ".", "add", "(", "new", "WeatherForecastCondition", "(", ")", ")", ";", "this", ".", "in_forecast_conditions", "=", "true", ";", "}", "else", "{", "String", "dataAttribute", "=", "atts", ".", "getValue", "(", "\"data\"", ")", ";", "if", "(", "localName", ".", "equals", "(", "\"city\"", ")", ")", "{", "this", ".", "city", "=", "dataAttribute", ";", "}", "else", "if", "(", "localName", ".", "equals", "(", "\"postal_code\"", ")", ")", "{", "}", "else", "if", "(", "localName", ".", "equals", "(", "\"latitude_e6\"", ")", ")", "{", "}", "else", "if", "(", "localName", ".", "equals", "(", "\"longitude_e6\"", ")", ")", "{", "}", "else", "if", "(", "localName", ".", "equals", "(", "\"\"", ")", ")", "{", "}", "else", "if", "(", "localName", ".", "equals", "(", "\"\"", ")", ")", "{", "}", "else", "if", "(", "localName", ".", "equals", "(", "\"unit_system\"", ")", ")", "{", "if", "(", "dataAttribute", ".", "equals", "(", "\"SI\"", ")", ")", "this", ".", "usingSITemperature", "=", "true", ";", "}", "else", "if", "(", "localName", ".", "equals", "(", "\"day_of_week\"", ")", ")", "{", "if", "(", "this", ".", "in_current_conditions", ")", "{", "this", ".", "myWeatherSet", ".", "getWeatherCurrentCondition", "(", ")", ".", "setDayofWeek", "(", "dataAttribute", ")", ";", "}", "else", "if", "(", "this", ".", "in_forecast_conditions", ")", "{", "this", ".", "myWeatherSet", ".", "getLastWeatherForecastCondition", "(", ")", ".", "setDayofWeek", "(", "dataAttribute", ")", ";", "}", "}", "else", "if", "(", "localName", ".", "equals", "(", "\"icon\"", ")", ")", "{", "if", "(", "this", ".", "in_current_conditions", ")", "{", "this", ".", "myWeatherSet", ".", "getWeatherCurrentCondition", "(", ")", ".", "setIconURL", "(", "dataAttribute", ")", ";", "}", "else", "if", "(", "this", ".", "in_forecast_conditions", ")", "{", "this", ".", "myWeatherSet", ".", "getLastWeatherForecastCondition", "(", ")", ".", "setIconURL", "(", "dataAttribute", ")", ";", "}", "}", "else", "if", "(", "localName", ".", "equals", "(", "\"condition\"", ")", ")", "{", "if", "(", "this", ".", "in_current_conditions", ")", "{", "this", ".", "myWeatherSet", ".", "getWeatherCurrentCondition", "(", ")", ".", "setCondition", "(", "dataAttribute", ")", ";", "}", "else", "if", "(", "this", ".", "in_forecast_conditions", ")", "{", "this", ".", "myWeatherSet", ".", "getLastWeatherForecastCondition", "(", ")", ".", "setCondition", "(", "dataAttribute", ")", ";", "}", "}", "else", "if", "(", "localName", ".", "equals", "(", "\"temp_f\"", ")", ")", "{", "this", ".", "myWeatherSet", ".", "getWeatherCurrentCondition", "(", ")", ".", "setTempFahrenheit", "(", "Integer", ".", "parseInt", "(", "dataAttribute", ")", ")", ";", "}", "else", "if", "(", "localName", ".", "equals", "(", "\"temp_c\"", ")", ")", "{", "this", ".", "myWeatherSet", ".", "getWeatherCurrentCondition", "(", ")", ".", "setTempCelcius", "(", "Integer", ".", "parseInt", "(", "dataAttribute", ")", ")", ";", "}", "else", "if", "(", "localName", ".", "equals", "(", "\"humidity\"", ")", ")", "{", "this", ".", "myWeatherSet", ".", "getWeatherCurrentCondition", "(", ")", ".", "setHumidity", "(", "dataAttribute", ")", ";", "}", "else", "if", "(", "localName", ".", "equals", "(", "\"\"", ")", ")", "{", "this", ".", "myWeatherSet", ".", "getWeatherCurrentCondition", "(", ")", ".", "setWindCondition", "(", "dataAttribute", ")", ";", "}", "else", "if", "(", "localName", ".", "equals", "(", "\"low\"", ")", ")", "{", "int", "temp", "=", "Integer", ".", "parseInt", "(", "dataAttribute", ")", ";", "if", "(", "this", ".", "usingSITemperature", ")", "{", "this", ".", "myWeatherSet", ".", "getLastWeatherForecastCondition", "(", ")", ".", "setTempMinCelsius", "(", "temp", ")", ";", "}", "else", "{", "this", ".", "myWeatherSet", ".", "getLastWeatherForecastCondition", "(", ")", ".", "setTempMinCelsius", "(", "WeatherUtils", ".", "fahrenheitToCelsius", "(", "temp", ")", ")", ";", "}", "}", "else", "if", "(", "localName", ".", "equals", "(", "\"high\"", ")", ")", "{", "int", "temp", "=", "Integer", ".", "parseInt", "(", "dataAttribute", ")", ";", "if", "(", "this", ".", "usingSITemperature", ")", "{", "this", ".", "myWeatherSet", ".", "getLastWeatherForecastCondition", "(", ")", ".", "setTempMaxCelsius", "(", "temp", ")", ";", "}", "else", "{", "this", ".", "myWeatherSet", ".", "getLastWeatherForecastCondition", "(", ")", ".", "setTempMaxCelsius", "(", "WeatherUtils", ".", "fahrenheitToCelsius", "(", "temp", ")", ")", ";", "}", "}", "}", "}", "@", "Override", "public", "void", "endElement", "(", "String", "namespaceURI", ",", "String", "localName", ",", "String", "qName", ")", "throws", "SAXException", "{", "if", "(", "localName", ".", "equals", "(", "\"\"", ")", ")", "{", "this", ".", "in_forecast_information", "=", "false", ";", "}", "else", "if", "(", "localName", ".", "equals", "(", "\"\"", ")", ")", "{", "this", ".", "in_current_conditions", "=", "false", ";", "}", "else", "if", "(", "localName", ".", "equals", "(", "\"\"", ")", ")", "{", "this", ".", "in_forecast_conditions", "=", "false", ";", "}", "}", "@", "Override", "public", "void", "characters", "(", "char", "ch", "[", "]", ",", "int", "start", ",", "int", "length", ")", "{", "}", "}", "</s>" ]
8,230
[ "<s>", "package", "org", ".", "anddev", ".", "android", ".", "weatherforecast", ".", "weather", ";", "public", "class", "WeatherForecastCondition", "{", "private", "String", "dayofWeek", "=", "null", ";", "private", "Integer", "tempMin", "=", "null", ";", "private", "Integer", "tempMax", "=", "null", ";", "private", "String", "iconURL", "=", "null", ";", "private", "String", "condition", "=", "null", ";", "public", "WeatherForecastCondition", "(", ")", "{", "}", "public", "String", "getDayofWeek", "(", ")", "{", "return", "dayofWeek", ";", "}", "public", "void", "setDayofWeek", "(", "String", "dayofWeek", ")", "{", "this", ".", "dayofWeek", "=", "dayofWeek", ";", "}", "public", "Integer", "getTempMinCelsius", "(", ")", "{", "return", "tempMin", ";", "}", "public", "void", "setTempMinCelsius", "(", "Integer", "tempMin", ")", "{", "this", ".", "tempMin", "=", "tempMin", ";", "}", "public", "Integer", "getTempMaxCelsius", "(", ")", "{", "return", "tempMax", ";", "}", "public", "void", "setTempMaxCelsius", "(", "Integer", "tempMax", ")", "{", "this", ".", "tempMax", "=", "tempMax", ";", "}", "public", "String", "getIconURL", "(", ")", "{", "return", "iconURL", ";", "}", "public", "void", "setIconURL", "(", "String", "iconURL", ")", "{", "this", ".", "iconURL", "=", "iconURL", ";", "}", "public", "String", "getCondition", "(", ")", "{", "return", "condition", ";", "}", "public", "void", "setCondition", "(", "String", "condition", ")", "{", "this", ".", "condition", "=", "condition", ";", "}", "}", "</s>" ]
8,231
[ "<s>", "package", "org", ".", "anddev", ".", "android", ".", "weatherforecast", ".", "weather", ";", "public", "class", "WeatherUtils", "{", "public", "static", "int", "fahrenheitToCelsius", "(", "int", "tFahrenheit", ")", "{", "return", "(", "int", ")", "(", "(", "5.0f", "/", "9.0f", ")", "*", "(", "tFahrenheit", "-", "32", ")", ")", ";", "}", "public", "static", "int", "celsiusToFahrenheit", "(", "int", "tCelsius", ")", "{", "return", "(", "int", ")", "(", "(", "9.0f", "/", "5.0f", ")", "*", "tCelsius", "+", "32", ")", ";", "}", "}", "</s>" ]
8,232
[ "<s>", "package", "org", ".", "anddev", ".", "android", ".", "weatherforecast", ".", "weather", ";", "public", "class", "WeatherCurrentCondition", "{", "private", "String", "dayofWeek", "=", "null", ";", "private", "Integer", "tempCelcius", "=", "null", ";", "private", "Integer", "tempFahrenheit", "=", "null", ";", "private", "String", "iconURL", "=", "null", ";", "private", "String", "condition", "=", "null", ";", "private", "String", "windCondition", "=", "null", ";", "private", "String", "humidity", "=", "null", ";", "private", "String", "city", "=", "null", ";", "public", "WeatherCurrentCondition", "(", ")", "{", "}", "public", "String", "getCity", "(", ")", "{", "return", "this", ".", "city", ";", "}", "public", "String", "getDayofWeek", "(", ")", "{", "return", "this", ".", "dayofWeek", ";", "}", "public", "void", "setDayofWeek", "(", "String", "dayofWeek", ")", "{", "this", ".", "dayofWeek", "=", "dayofWeek", ";", "}", "public", "Integer", "getTempCelcius", "(", ")", "{", "return", "this", ".", "tempCelcius", ";", "}", "public", "void", "setTempCelcius", "(", "Integer", "temp", ")", "{", "this", ".", "tempCelcius", "=", "temp", ";", "}", "public", "Integer", "getTempFahrenheit", "(", ")", "{", "return", "this", ".", "tempFahrenheit", ";", "}", "public", "void", "setTempFahrenheit", "(", "Integer", "temp", ")", "{", "this", ".", "tempFahrenheit", "=", "temp", ";", "}", "public", "String", "getIconURL", "(", ")", "{", "return", "this", ".", "iconURL", ";", "}", "public", "void", "setCity", "(", "String", "city", ")", "{", "this", ".", "city", "=", "city", ";", "}", "public", "void", "setIconURL", "(", "String", "iconURL", ")", "{", "this", ".", "iconURL", "=", "iconURL", ";", "}", "public", "String", "getCondition", "(", ")", "{", "return", "this", ".", "condition", ";", "}", "public", "void", "setCondition", "(", "String", "condition", ")", "{", "this", ".", "condition", "=", "condition", ";", "}", "public", "String", "getWindCondition", "(", ")", "{", "return", "this", ".", "windCondition", ";", "}", "public", "void", "setWindCondition", "(", "String", "windCondition", ")", "{", "this", ".", "windCondition", "=", "windCondition", ";", "}", "public", "String", "getHumidity", "(", ")", "{", "return", "this", ".", "humidity", ";", "}", "public", "void", "setHumidity", "(", "String", "humidity", ")", "{", "this", ".", "humidity", "=", "humidity", ";", "}", "}", "</s>" ]
8,233
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "io", ".", "ByteArrayOutputStream", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "http", ".", "HttpResponse", ";", "import", "org", ".", "apache", ".", "http", ".", "NameValuePair", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "entity", ".", "UrlEncodedFormEntity", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "methods", ".", "HttpPost", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "params", ".", "ClientPNames", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "params", ".", "CookiePolicy", ";", "import", "org", ".", "apache", ".", "http", ".", "impl", ".", "client", ".", "DefaultHttpClient", ";", "import", "org", ".", "apache", ".", "http", ".", "message", ".", "BasicNameValuePair", ";", "import", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ".", "R", ".", "id", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "util", ".", "AttributeSet", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "view", ".", "View", ".", "OnClickListener", ";", "import", "android", ".", "widget", ".", "Button", ";", "import", "android", ".", "widget", ".", "LinearLayout", ";", "import", "android", ".", "widget", ".", "TextView", ";", "public", "class", "PostView", "extends", "LinearLayout", "{", "public", "PostView", "(", "Context", "context", ")", "{", "this", "(", "context", ",", "null", ")", ";", "}", "public", "PostView", "(", "Context", "context", ",", "AttributeSet", "attrs", ")", "{", "super", "(", "context", ",", "attrs", ")", ";", "}", "}", "</s>" ]
8,234
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "SharedPreferences", ";", "import", "android", ".", "content", ".", "SharedPreferences", ".", "Editor", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "preference", ".", "PreferenceActivity", ";", "import", "android", ".", "preference", ".", "PreferenceManager", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "android", ".", "util", ".", "Log", ";", "public", "class", "FocusedSettings", "{", "private", "static", "final", "String", "OPT_KEYWORDS", "=", "\"keywords\"", ";", "public", "static", "ArrayList", "<", "String", ">", "get", "(", "Context", "context", ")", "throws", "IOException", "{", "ArrayList", "<", "String", ">", "keywords", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "try", "{", "if", "(", "SDCard", ".", "existSeriarized", "(", "OPT_KEYWORDS", ")", ")", "{", "keywords", "=", "(", "ArrayList", "<", "String", ">", ")", "SDCard", ".", "getSerialized", "(", "OPT_KEYWORDS", ")", ".", "readObject", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "return", "keywords", ";", "}", "public", "static", "void", "set", "(", "Context", "context", ",", "ArrayList", "<", "String", ">", "futabaBBSs", ")", "throws", "IOException", "{", "SDCard", ".", "setSerialized", "(", "OPT_KEYWORDS", ",", "futabaBBSs", ")", ";", "}", "}", "</s>" ]
8,235
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "android", ".", "app", ".", "Activity", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "view", ".", "Display", ";", "import", "android", ".", "view", ".", "KeyEvent", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "view", ".", "WindowManager", ";", "import", "android", ".", "widget", ".", "AdapterView", ";", "import", "android", ".", "widget", ".", "ArrayAdapter", ";", "import", "android", ".", "widget", ".", "ListView", ";", "import", "android", ".", "widget", ".", "Toast", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "content", ".", "SharedPreferences", ";", "import", "android", ".", "app", ".", "ProgressDialog", ";", "import", "java", ".", "lang", ".", "Thread", ";", "import", "android", ".", "os", ".", "Handler", ";", "import", "android", ".", "os", ".", "Message", ";", "import", "android", ".", "preference", ".", "PreferenceManager", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "TreeMap", ";", "import", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ".", "R", ".", "id", ";", "public", "class", "FutabaBBSMenu", "extends", "Activity", "implements", "Runnable", "{", "private", "ProgressDialog", "waitDialog", ";", "private", "Thread", "thread", ";", "public", "FutabaBBSMenuAdapter", "adapter", "=", "null", ";", "public", "boolean", "initial_loading", "=", "true", ";", "private", "ListView", "listView", ";", "String", "mode", ";", "@", "Override", "public", "void", "onCreate", "(", "Bundle", "savedInstanceState", ")", "{", "super", ".", "onCreate", "(", "savedInstanceState", ")", ";", "try", "{", "Intent", "intent", "=", "getIntent", "(", ")", ";", "mode", "=", "(", "String", ")", "intent", ".", "getSerializableExtra", "(", "\"mode\"", ")", ";", "setWait", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "public", "void", "setWait", "(", ")", "{", "waitDialog", "=", "new", "ProgressDialog", "(", "this", ")", ";", "waitDialog", ".", "setMessage", "(", "this", ".", "getString", "(", "R", ".", "string", ".", "loading", ")", ")", ";", "waitDialog", ".", "setProgressStyle", "(", "ProgressDialog", ".", "STYLE_SPINNER", ")", ";", "waitDialog", ".", "show", "(", ")", ";", "thread", "=", "new", "Thread", "(", "this", ")", ";", "thread", ".", "start", "(", ")", ";", "}", "public", "void", "run", "(", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "100", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "handler", ".", "sendEmptyMessage", "(", "0", ")", ";", "}", "private", "Handler", "handler", "=", "new", "Handler", "(", ")", "{", "public", "void", "handleMessage", "(", "Message", "msg", ")", "{", "try", "{", "loading", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", ";", "private", "void", "loading", "(", ")", "{", "try", "{", "SharedPreferences", "preferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "this", ")", ";", "boolean", "dispCensored", "=", "preferences", ".", "getBoolean", "(", "getString", "(", "R", ".", "string", ".", "dispcensored", ")", ",", "false", ")", ";", "setContentView", "(", "R", ".", "layout", ".", "bbsmenu", ")", ";", "Intent", "intent", "=", "getIntent", "(", ")", ";", "ArrayList", "<", "FutabaBBSContent", ">", "BBSs", "=", "new", "ArrayList", "<", "FutabaBBSContent", ">", "(", ")", ";", "if", "(", "mode", "==", "null", "||", "mode", ".", "equals", "(", "\"all\"", ")", ")", "{", "FutabaBBSMenuParser", "parser", "=", "new", "FutabaBBSMenuParser", "(", "\"\"", ")", ";", "parser", ".", "setDisplayCensored", "(", "dispCensored", ")", ";", "parser", ".", "parse", "(", ")", ";", "if", "(", "!", "parser", ".", "network_ok", ")", "{", "if", "(", "parser", ".", "cache_ok", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "\"\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "else", "{", "Toast", ".", "makeText", "(", "this", ",", "\"\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "}", "BBSs", "=", "parser", ".", "getBBSs", "(", ")", ";", "if", "(", "initial_loading", ")", "{", "initial_loading", "=", "false", ";", "ftbt", "parent_activity", "=", "(", "ftbt", ")", "this", ".", "getParent", "(", ")", ";", "ArrayList", "<", "FutabaBBSContent", ">", "BBSs_faved", "=", "parent_activity", ".", "favoriteBBSs", ";", "HashSet", "<", "String", ">", "BBS_urls", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "BBSs_faved", ".", "size", "(", ")", ";", "i", "++", ")", "{", "BBS_urls", ".", "add", "(", "BBSs_faved", ".", "get", "(", "i", ")", ".", "url", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "BBSs", ".", "size", "(", ")", ";", "i", "++", ")", "{", "if", "(", "BBS_urls", ".", "contains", "(", "BBSs", ".", "get", "(", "i", ")", ".", "url", ")", ")", "{", "BBSs", ".", "get", "(", "i", ")", ".", "faved", "=", "true", ";", "}", "}", "}", "}", "else", "{", "ftbt", "parent_activity", "=", "(", "ftbt", ")", "this", ".", "getParent", "(", ")", ";", "BBSs", "=", "parent_activity", ".", "favoriteBBSs", ";", "}", "adapter", "=", "new", "FutabaBBSMenuAdapter", "(", "this", ",", "R", ".", "layout", ".", "futaba_bbs_row", ",", "BBSs", ")", ";", "listView", "=", "(", "ListView", ")", "findViewById", "(", "id", ".", "listview", ")", ";", "listView", ".", "setAdapter", "(", "adapter", ")", ";", "FLog", ".", "d", "(", "\"start\"", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "waitDialog", ".", "dismiss", "(", ")", ";", "}", "public", "void", "transSetting", "(", "FutabaBBSContent", "item", ")", "{", "Intent", "intent", "=", "new", "Intent", "(", ")", ";", "FLog", ".", "d", "(", "item", ".", "url", ")", ";", "intent", ".", "putExtra", "(", "\"baseUrl\"", ",", "item", ".", "url", ")", ";", "intent", ".", "putExtra", "(", "\"BBSName\"", ",", "item", ".", "name", ")", ";", "intent", ".", "putExtra", "(", "\"mode\"", ",", "\"normal\"", ")", ";", "intent", ".", "setClassName", "(", "getPackageName", "(", ")", ",", "getClass", "(", ")", ".", "getPackage", "(", ")", ".", "getName", "(", ")", "+", "\".Catalog\"", ")", ";", "startActivity", "(", "intent", ")", ";", "}", "@", "Override", "protected", "void", "onResume", "(", ")", "{", "super", ".", "onResume", "(", ")", ";", "try", "{", "if", "(", "mode", ".", "equals", "(", "\"fav\"", ")", ")", "{", "ftbt", "parent_activity", "=", "(", "ftbt", ")", "this", ".", "getParent", "(", ")", ";", "if", "(", "adapter", "!=", "null", ")", "{", "adapter", ".", "items", "=", "parent_activity", ".", "favoriteBBSs", ";", "adapter", ".", "notifyDataSetChanged", "(", ")", ";", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "FLog", ".", "d", "(", "\"\"", ")", ";", "}", "public", "boolean", "dispatchKeyEvent", "(", "KeyEvent", "event", ")", "{", "FLog", ".", "d", "(", "\"\"", "+", "event", ".", "getAction", "(", ")", ")", ";", "int", "action", "=", "event", ".", "getAction", "(", ")", ";", "int", "keyCode", "=", "event", ".", "getKeyCode", "(", ")", ";", "if", "(", "keyCode", "==", "KeyEvent", ".", "KEYCODE_VOLUME_DOWN", ")", "{", "if", "(", "action", "==", "KeyEvent", ".", "ACTION_UP", ")", "{", "FLog", ".", "d", "(", "\"vdown\"", "+", "listView", ".", "getFirstVisiblePosition", "(", ")", ")", ";", "int", "topPositionY", "=", "listView", ".", "getChildAt", "(", "0", ")", ".", "getTop", "(", ")", ";", "WindowManager", "wm", "=", "(", "WindowManager", ")", "getSystemService", "(", "Context", ".", "WINDOW_SERVICE", ")", ";", "Display", "disp", "=", "wm", ".", "getDefaultDisplay", "(", ")", ";", "int", "height", "=", "disp", ".", "getHeight", "(", ")", ";", "listView", ".", "setSelectionFromTop", "(", "listView", ".", "getFirstVisiblePosition", "(", ")", ",", "topPositionY", "-", "(", "height", "-", "200", ")", ")", ";", "}", "return", "true", ";", "}", "else", "if", "(", "keyCode", "==", "KeyEvent", ".", "KEYCODE_VOLUME_UP", ")", "{", "if", "(", "action", "==", "KeyEvent", ".", "ACTION_UP", ")", "{", "int", "topPositionY", "=", "listView", ".", "getChildAt", "(", "0", ")", ".", "getTop", "(", ")", ";", "WindowManager", "wm", "=", "(", "WindowManager", ")", "getSystemService", "(", "Context", ".", "WINDOW_SERVICE", ")", ";", "Display", "disp", "=", "wm", ".", "getDefaultDisplay", "(", ")", ";", "int", "height", "=", "disp", ".", "getHeight", "(", ")", ";", "listView", ".", "setSelectionFromTop", "(", "listView", ".", "getFirstVisiblePosition", "(", ")", ",", "topPositionY", "+", "(", "height", "-", "200", ")", ")", ";", "}", "return", "true", ";", "}", "return", "super", ".", "dispatchKeyEvent", "(", "event", ")", ";", "}", "}", "</s>" ]
8,236
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "security", ".", "MessageDigest", ";", "import", "android", ".", "util", ".", "Log", ";", "class", "FutabaCrypt", "{", "public", "static", "String", "createDigest", "(", "String", "source", ")", "{", "MessageDigest", "md", ";", "try", "{", "md", "=", "MessageDigest", ".", "getInstance", "(", "\"MD5\"", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "return", "\"\"", ";", "}", "byte", "[", "]", "data", "=", "source", ".", "getBytes", "(", ")", ";", "md", ".", "update", "(", "data", ")", ";", "byte", "[", "]", "digest", "=", "md", ".", "digest", "(", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "digest", ".", "length", ";", "i", "++", ")", "{", "sb", ".", "append", "(", "Integer", ".", "toHexString", "(", "0xff", "&", "digest", "[", "i", "]", ")", ")", ";", "}", "if", "(", "FutabaCrypt", ".", "isHTMLName", "(", "source", ")", ")", "{", "return", "sb", ".", "toString", "(", ")", "+", "\".htm\"", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "public", "static", "boolean", "isHTMLName", "(", "String", "str", ")", "{", "String", "last_str", "=", "str", ".", "substring", "(", "Math", ".", "max", "(", "0", ",", "str", ".", "length", "(", ")", "-", "4", ")", ")", ";", "boolean", "is_html", "=", "last_str", ".", "equals", "(", "\".htm\"", ")", "||", "last_str", ".", "equals", "(", "\"html\"", ")", "||", "str", ".", "contains", "(", "\".php\"", ")", ";", "return", "is_html", ";", "}", "}", "</s>" ]
8,237
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "net", ".", "URLEncoder", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "android", ".", "webkit", ".", "MimeTypeMap", ";", "public", "class", "StringUtil", "{", "static", "String", "safeCut", "(", "String", "str", ",", "int", "length", ")", "{", "if", "(", "str", ".", "length", "(", ")", ">", "length", ")", "{", "return", "str", ".", "substring", "(", "0", ",", "length", ")", "+", "\"...\"", ";", "}", "return", "str", ";", "}", "static", "String", "safeCutNoDot", "(", "String", "str", ",", "int", "length", ")", "{", "if", "(", "str", ".", "length", "(", ")", ">", "length", ")", "{", "return", "str", ".", "substring", "(", "0", ",", "length", ")", ";", "}", "return", "str", ";", "}", "static", "String", "[", "]", "nonBlankSplit", "(", "String", "str", ",", "String", "[", "]", "addition", ")", "{", "String", "[", "]", "elems", "=", "str", ".", "split", "(", "\"n\"", ")", ";", "ArrayList", "<", "String", ">", "filtered_elems", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "elems", ".", "length", ";", "++", "i", ")", "{", "if", "(", "elems", "[", "i", "]", ".", "length", "(", ")", ">", "0", ")", "{", "filtered_elems", ".", "add", "(", "elems", "[", "i", "]", ")", ";", "}", "}", "if", "(", "elems", ".", "length", ">", "1", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "addition", ".", "length", ";", "++", "i", ")", "{", "filtered_elems", ".", "add", "(", "addition", "[", "i", "]", ")", ";", "}", "}", "return", "(", "String", "[", "]", ")", "filtered_elems", ".", "toArray", "(", "new", "String", "[", "0", "]", ")", ";", "}", "static", "String", "quote", "(", "String", "str", ")", "{", "String", "ret", "=", "\"\"", ";", "String", "[", "]", "elems", "=", "str", ".", "split", "(", "\"n\"", ")", ";", "ArrayList", "<", "String", ">", "filtered_elems", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "elems", ".", "length", ";", "++", "i", ")", "{", "if", "(", "elems", "[", "i", "]", ".", "length", "(", ")", ">", "0", ")", "{", "ret", "+=", "\">\"", "+", "elems", "[", "i", "]", ".", "trim", "(", ")", "+", "\"n\"", ";", "}", "}", "return", "ret", ";", "}", "static", "String", "[", "]", "queryNormalize", "(", "String", "str", ")", "{", "String", "temp", "=", "normalize", "(", "str", ")", ";", "String", "[", "]", "splits", "=", "temp", ".", "split", "(", "\"[", "-UNK-]\"", ")", ";", "ArrayList", "<", "String", ">", "splits_tmp", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "splits", ".", "length", ";", "++", "i", ")", "{", "if", "(", "splits", "[", "i", "]", ".", "length", "(", ")", ">", "0", ")", "{", "String", "elem", "=", "splits", "[", "i", "]", ".", "replaceAll", "(", "\"<\"", ",", "\"&lt;\"", ")", ";", "elem", "=", "elem", ".", "replaceAll", "(", "\">\"", ",", "\"&gt;\"", ")", ";", "elem", "=", "elem", ".", "replaceAll", "(", "\"\\\"\"", ",", "\"&quot;\"", ")", ";", "splits_tmp", ".", "add", "(", "elem", ")", ";", "}", "}", "return", "(", "String", "[", "]", ")", "splits_tmp", ".", "toArray", "(", "new", "String", "[", "0", "]", ")", ";", "}", "static", "String", "[", "]", "querySplit", "(", "String", "str", ")", "{", "String", "[", "]", "splits", "=", "str", ".", "split", "(", "\"[", "-UNK-]\"", ")", ";", "ArrayList", "<", "String", ">", "splits_tmp", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "splits", ".", "length", ";", "++", "i", ")", "{", "if", "(", "splits", "[", "i", "]", ".", "length", "(", ")", ">", "0", ")", "{", "String", "elem", "=", "splits", "[", "i", "]", ".", "replaceAll", "(", "\"<\"", ",", "\"&lt;\"", ")", ";", "elem", "=", "elem", ".", "replaceAll", "(", "\">\"", ",", "\"&gt;\"", ")", ";", "elem", "=", "elem", ".", "replaceAll", "(", "\"\\\"\"", ",", "\"&quot;\"", ")", ";", "splits_tmp", ".", "add", "(", "elem", ")", ";", "}", "}", "return", "(", "String", "[", "]", ")", "splits_tmp", ".", "toArray", "(", "new", "String", "[", "0", "]", ")", ";", "}", "static", "boolean", "isQueryMatch", "(", "String", "str", ",", "String", "[", "]", "query", ")", "{", "String", "temp", "=", "normalize", "(", "str", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "query", ".", "length", ";", "++", "i", ")", "{", "if", "(", "!", "temp", ".", "contains", "(", "query", "[", "i", "]", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}", "static", "boolean", "isQueryMatchOr", "(", "String", "str", ",", "String", "[", "]", "query", ",", "boolean", "doNormalize", ")", "{", "String", "temp", "=", "str", ";", "if", "(", "doNormalize", ")", "{", "temp", "=", "normalize", "(", "temp", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "query", ".", "length", ";", "++", "i", ")", "{", "if", "(", "temp", ".", "contains", "(", "query", "[", "i", "]", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "private", "static", "String", "zenkakuToHankaku", "(", "String", "value", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "value", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "sb", ".", "length", "(", ")", ";", "i", "++", ")", "{", "int", "c", "=", "(", "int", ")", "sb", ".", "charAt", "(", "i", ")", ";", "if", "(", "(", "c", ">=", "0xFF10", "&&", "c", "<=", "0xFF19", ")", "||", "(", "c", ">=", "0xFF21", "&&", "c", "<=", "0xFF3A", ")", "||", "(", "c", ">=", "0xFF41", "&&", "c", "<=", "0xFF5A", ")", ")", "{", "sb", ".", "setCharAt", "(", "i", ",", "(", "char", ")", "(", "c", "-", "0xFEE0", ")", ")", ";", "}", "}", "value", "=", "sb", ".", "toString", "(", ")", ";", "return", "value", ";", "}", "public", "static", "String", "zenkakuHiraganaToZenkakuKatakana", "(", "String", "s", ")", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", "s", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "sb", ".", "length", "(", ")", ";", "i", "++", ")", "{", "char", "c", "=", "sb", ".", "charAt", "(", "i", ")", ";", "if", "(", "c", ">=", "'-UNK-'", "&&", "c", "<=", "'-UNK-'", ")", "{", "sb", ".", "setCharAt", "(", "i", ",", "(", "char", ")", "(", "c", "-", "'-UNK-'", "+", "'-UNK-'", ")", ")", ";", "}", "else", "if", "(", "c", "==", "'-UNK-'", ")", "{", "sb", ".", "setCharAt", "(", "i", ",", "'-UNK-'", ")", ";", "}", "else", "if", "(", "c", "==", "'-UNK-'", ")", "{", "sb", ".", "setCharAt", "(", "i", ",", "'-UNK-'", ")", ";", "}", "else", "if", "(", "c", "==", "'-UNK-'", ")", "{", "sb", ".", "setCharAt", "(", "i", ",", "'-UNK-'", ")", ";", "sb", ".", "insert", "(", "i", "+", "1", ",", "'-UNK-'", ")", ";", "i", "++", ";", "}", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "static", "String", "normalize", "(", "String", "str", ")", "{", "String", "temp", "=", "str", ".", "toLowerCase", "(", ")", ";", "temp", "=", "zenkakuToHankaku", "(", "temp", ")", ";", "temp", "=", "zenkakuHiraganaToZenkakuKatakana", "(", "temp", ")", ";", "return", "temp", ";", "}", "public", "static", "String", "getMIMEType", "(", "String", "targetFile", ")", "{", "String", "url", "=", "URLEncoder", ".", "encode", "(", "targetFile", ")", ";", "String", "extention", "=", "MimeTypeMap", ".", "getFileExtensionFromUrl", "(", "url", ")", ";", "String", "mtype", "=", "\"\"", ";", "extention", "=", "extention", ".", "toLowerCase", "(", ")", ";", "mtype", "=", "MimeTypeMap", ".", "getSingleton", "(", ")", ".", "getMimeTypeFromExtension", "(", "extention", ")", ";", "if", "(", "mtype", "==", "null", ")", "{", "String", "PLANETEXT", "=", "\"text/plain\"", ";", "if", "(", "(", "targetFile", ".", "endsWith", "(", "\".c\"", ")", ")", "||", "(", "targetFile", ".", "endsWith", "(", "\".cp\"", ")", ")", "||", "(", "targetFile", ".", "endsWith", "(", "\".cpp\"", ")", ")", "||", "(", "targetFile", ".", "endsWith", "(", "\".java\"", ")", ")", "||", "(", "targetFile", ".", "endsWith", "(", "\".txt\"", ")", ")", "||", "(", "targetFile", ".", "endsWith", "(", "\".c++\"", ")", ")", "||", "(", "targetFile", ".", "endsWith", "(", "\".sh\"", ")", ")", "||", "(", "targetFile", ".", "endsWith", "(", "\".cmake\"", ")", ")", "||", "(", "targetFile", ".", "endsWith", "(", "\".ini\"", ")", ")", "||", "(", "targetFile", ".", "endsWith", "(", "\".php\"", ")", ")", "||", "(", "targetFile", ".", "endsWith", "(", "\".py\"", ")", ")", ")", "mtype", "=", "PLANETEXT", ";", "}", "if", "(", "mtype", "==", "null", ")", "mtype", "=", "\"\"", ";", "return", "mtype", ";", "}", "static", "boolean", "validateFocusWord", "(", "String", "word", ")", "throws", "Exception", "{", "String", "[", "]", "splits", "=", "word", ".", "split", "(", "\"[", "-UNK-]\"", ")", ";", "if", "(", "splits", ".", "length", ">", "1", ")", "{", "throw", "new", "Exception", "(", "\"spaces_exist\"", ")", ";", "}", "splits", "=", "word", ".", "split", "(", "\"n\"", ")", ";", "if", "(", "splits", ".", "length", ">", "1", ")", "{", "throw", "new", "Exception", "(", "\"\"", ")", ";", "}", "if", "(", "word", ".", "equals", "(", "\"\"", ")", ")", "{", "throw", "new", "Exception", "(", "\"noword\"", ")", ";", "}", "if", "(", "word", ".", "length", "(", ")", ">", "10", ")", "{", "throw", "new", "Exception", "(", "\"toolongword\"", ")", ";", "}", "return", "true", ";", "}", "static", "boolean", "focusWordMatched", "(", "String", "text", ",", "ArrayList", "<", "String", ">", "focuswords", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "focuswords", ".", "size", "(", ")", ";", "++", "i", ")", "{", "if", "(", "text", ".", "contains", "(", "focuswords", ".", "get", "(", "i", ")", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "static", "String", "highlightFocusWordMatched", "(", "String", "text", ",", "ArrayList", "<", "String", ">", "focuswords", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "focuswords", ".", "size", "(", ")", ";", "++", "i", ")", "{", "String", "fword", "=", "focuswords", ".", "get", "(", "i", ")", ";", "if", "(", "text", ".", "contains", "(", "fword", ")", ")", "{", "return", "text", ".", "replace", "(", "fword", ",", "\"\"", "+", "fword", "+", "\"</font>\"", ")", ";", "}", "}", "return", "text", ";", "}", "}", "</s>" ]
8,238
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "util", ".", "Log", ";", "public", "class", "PostParser", "{", "private", "static", "Pattern", "tagPattern", "=", "Pattern", ".", "compile", "(", "\"<.+?>\"", ",", "Pattern", ".", "DOTALL", ")", ";", "Pattern", "honbunPattern", "=", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "DOTALL", ")", ";", "public", "String", "parse", "(", "Context", "context", ",", "String", "str", ")", "{", "FLog", ".", "d", "(", "\"str=\"", "+", "str", ")", ";", "try", "{", "Matcher", "mc", "=", "honbunPattern", ".", "matcher", "(", "str", ")", ";", "mc", ".", "find", "(", ")", ";", "return", "removeTag", "(", "mc", ".", "group", "(", "1", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "return", "\"\"", ";", "}", "public", "static", "String", "removeTag", "(", "String", "str", ")", "{", "return", "tagPattern", ".", "matcher", "(", "str", ")", ".", "replaceAll", "(", "\"\"", ")", ";", "}", "}", "</s>" ]
8,239
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "util", ".", "Log", ";", "public", "class", "DelpostParser", "{", "private", "static", "Pattern", "tagPattern", "=", "Pattern", ".", "compile", "(", "\"<.+?>\"", ",", "Pattern", ".", "DOTALL", ")", ";", "Pattern", "honbunPattern", "=", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "DOTALL", ")", ";", "public", "String", "parse", "(", "Context", "context", ",", "String", "str", ")", "{", "FLog", ".", "d", "(", "\"str=\"", "+", "str", ")", ";", "try", "{", "Matcher", "mc", "=", "honbunPattern", ".", "matcher", "(", "str", ")", ";", "mc", ".", "find", "(", ")", ";", "return", "removeTag", "(", "mc", ".", "group", "(", "1", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "return", "\"\"", ";", "}", "public", "static", "String", "removeTag", "(", "String", "str", ")", "{", "return", "tagPattern", ".", "matcher", "(", "str", ")", ".", "replaceAll", "(", "\"\"", ")", ";", "}", "}", "</s>" ]
8,240
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "public", "class", "FutabaStatus", "{", "public", "String", "userName", ";", "public", "String", "title", ";", "public", "String", "text", ";", "public", "String", "name", ";", "public", "String", "datestr", ";", "public", "String", "mailTo", ";", "public", "int", "id", ";", "public", "String", "imgURL", ";", "public", "String", "bigImgURL", ";", "public", "int", "width", ";", "public", "int", "height", ";", "public", "String", "endTime", ";", "public", "boolean", "deleted", ";", "FutabaStatus", "(", ")", "{", "userName", "=", "\"\"", ";", "title", "=", "\"\"", ";", "text", "=", "\"\"", ";", "mailTo", "=", "\"\"", ";", "id", "=", "0", ";", "width", "=", "0", ";", "height", "=", "0", ";", "endTime", "=", "\"\"", ";", "deleted", "=", "false", ";", "}", "public", "static", "FutabaStatus", "createBlank", "(", ")", "{", "FutabaStatus", "st", "=", "new", "FutabaStatus", "(", ")", ";", "st", ".", "id", "=", "-", "1", ";", "return", "st", ";", "}", "public", "static", "FutabaStatus", "createEndTime", "(", "String", "str", ")", "{", "FutabaStatus", "st", "=", "new", "FutabaStatus", "(", ")", ";", "st", ".", "id", "=", "-", "2", ";", "st", ".", "text", "=", "\"\"", "+", "str", "+", "\")</font>\"", ";", "return", "st", ";", "}", "public", "static", "boolean", "isBlank", "(", "FutabaStatus", "st", ")", "{", "return", "st", ".", "id", "==", "-", "1", ";", "}", "public", "static", "boolean", "isEndTime", "(", "FutabaStatus", "st", ")", "{", "return", "st", ".", "id", "==", "-", "2", ";", "}", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "userName", "+", "\"", "title=\"", "+", "title", "+", "\"", "text=\"", "+", "text", "+", "\"", "name=\"", "+", "name", "+", "\"", "datestr=\"", "+", "datestr", "+", "\"", "mailTo=\"", "+", "mailTo", "+", "\"", "id=\"", "+", "id", "+", "\"", "imgURL=\"", "+", "imgURL", "+", "\"", "bigImgURL=\"", "+", "bigImgURL", "+", "\"", "width=\"", "+", "width", "+", "\"", "height=\"", "+", "height", ";", "}", "}", "</s>" ]
8,241
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "android", ".", "app", ".", "Activity", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "widget", ".", "LinearLayout", ";", "public", "class", "DummyTab", "extends", "Activity", "{", "@", "Override", "public", "void", "onCreate", "(", "Bundle", "savedInstanceState", ")", "{", "super", ".", "onCreate", "(", "savedInstanceState", ")", ";", "LinearLayout", "linearLayout", "=", "new", "LinearLayout", "(", "this", ")", ";", "setContentView", "(", "linearLayout", ")", ";", "}", "}", "</s>" ]
8,242
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "android", ".", "view", ".", "Gravity", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "view", ".", "ViewGroup", ".", "LayoutParams", ";", "import", "android", ".", "widget", ".", "Button", ";", "import", "android", ".", "widget", ".", "LinearLayout", ";", "import", "android", ".", "widget", ".", "TextView", ";", "import", "android", ".", "widget", ".", "Toast", ";", "import", "android", ".", "graphics", ".", "Typeface", ";", "import", "android", ".", "view", ".", "ViewGroup", ";", "import", "android", ".", "widget", ".", "ArrayAdapter", ";", "import", "android", ".", "content", ".", "ContentResolver", ";", "import", "android", ".", "content", ".", "ContentValues", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "SharedPreferences", ";", "import", "android", ".", "view", ".", "LayoutInflater", ";", "import", "android", ".", "text", ".", "Html", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "os", ".", "AsyncTask", ";", "import", "android", ".", "preference", ".", "PreferenceManager", ";", "import", "android", ".", "provider", ".", "MediaStore", ".", "Images", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "io", ".", "ByteArrayOutputStream", ";", "import", "java", ".", "io", ".", "BufferedOutputStream", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "BufferedInputStream", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "java", ".", "net", ".", "HttpURLConnection", ";", "import", "android", ".", "graphics", ".", "Bitmap", ";", "import", "android", ".", "graphics", ".", "BitmapFactory", ";", "import", "android", ".", "graphics", ".", "Color", ";", "import", "android", ".", "widget", ".", "ImageView", ";", "import", "android", ".", "view", ".", "WindowManager", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "view", ".", "Display", ";", "import", "java", ".", "lang", ".", "Thread", ";", "public", "class", "FutabaThreadAdapter", "extends", "ArrayAdapter", "{", "public", "ArrayList", "items", ";", "private", "LayoutInflater", "inflater", ";", "private", "int", "width", ";", "private", "int", "height", ";", "public", "String", "[", "]", "searchQueries", ";", "public", "int", "shioriPosition", "=", "0", ";", "public", "FutabaThreadAdapter", "(", "Context", "context", ",", "int", "textViewResourceId", ",", "ArrayList", "items", ")", "{", "super", "(", "context", ",", "textViewResourceId", ",", "items", ")", ";", "this", ".", "items", "=", "items", ";", "this", ".", "inflater", "=", "(", "LayoutInflater", ")", "context", ".", "getSystemService", "(", "Context", ".", "LAYOUT_INFLATER_SERVICE", ")", ";", "WindowManager", "wm", "=", "(", "(", "WindowManager", ")", "context", ".", "getSystemService", "(", "Context", ".", "WINDOW_SERVICE", ")", ")", ";", "Display", "display", "=", "wm", ".", "getDefaultDisplay", "(", ")", ";", "width", "=", "display", ".", "getWidth", "(", ")", ";", "height", "=", "display", ".", "getHeight", "(", ")", ";", "}", "@", "Override", "public", "View", "getView", "(", "int", "position", ",", "View", "convertView", ",", "ViewGroup", "parent", ")", "{", "View", "view", "=", "convertView", ";", "try", "{", "if", "(", "view", "==", "null", ")", "{", "view", "=", "inflater", ".", "inflate", "(", "StateMan", ".", "getThreadRowResourceId", "(", "getContext", "(", ")", ")", ",", "null", ")", ";", "}", "FutabaThread", "activity", "=", "(", "FutabaThread", ")", "getContext", "(", ")", ";", "FutabaStatus", "item", "=", "(", "FutabaStatus", ")", "items", ".", "get", "(", "position", ")", ";", "if", "(", "item", "!=", "null", ")", "{", "TextView", "title", "=", "(", "TextView", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "title", ")", ";", "title", ".", "setTextSize", "(", "StateMan", ".", "getDescFontSize", "(", "getContext", "(", ")", ")", ")", ";", "TextView", "bottomtext", "=", "(", "TextView", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "bottomtext", ")", ";", "bottomtext", ".", "setTextSize", "(", "StateMan", ".", "getDescFontSize", "(", "getContext", "(", ")", ")", ")", ";", "TextView", "text", "=", "(", "TextView", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "maintext", ")", ";", "bottomtext", ".", "setTextSize", "(", "StateMan", ".", "getMainFontSize", "(", "getContext", "(", ")", ")", ")", ";", "LinearLayout", "iif", "=", "(", "LinearLayout", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "imageinnerframe", ")", ";", "iif", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "if", "(", "FutabaStatus", ".", "isBlank", "(", "item", ")", ")", "{", "ImageView", "iv", "=", "(", "ImageView", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "image", ")", ";", "iv", ".", "setImageBitmap", "(", "null", ")", ";", "text", ".", "setText", "(", "\"\"", ")", ";", "text", ".", "setGravity", "(", "Gravity", ".", "CENTER", ")", ";", "title", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "bottomtext", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "bottomtext", ".", "setText", "(", "\"\"", ")", ";", "view", ".", "setBackgroundColor", "(", "Color", ".", "parseColor", "(", "\"#CCCCFF\"", ")", ")", ";", "Button", "saveButton", "=", "(", "Button", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "savebutton", ")", ";", "saveButton", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "}", "else", "if", "(", "FutabaStatus", ".", "isEndTime", "(", "item", ")", ")", "{", "ImageView", "iv", "=", "(", "ImageView", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "image", ")", ";", "iv", ".", "setImageBitmap", "(", "null", ")", ";", "String", "text_html", "=", "item", ".", "text", ";", "CharSequence", "cs", "=", "Html", ".", "fromHtml", "(", "text_html", ")", ";", "text", ".", "setText", "(", "cs", ")", ";", "text", ".", "setGravity", "(", "Gravity", ".", "CENTER", ")", ";", "title", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "bottomtext", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "bottomtext", ".", "setText", "(", "\"\"", ")", ";", "view", ".", "setBackgroundColor", "(", "Color", ".", "parseColor", "(", "\"#FFFFEE\"", ")", ")", ";", "Button", "saveButton", "=", "(", "Button", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "savebutton", ")", ";", "saveButton", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "}", "else", "{", "String", "title_base", "=", "item", ".", "title", ";", "if", "(", "item", ".", "name", "!=", "null", ")", "{", "title_base", "+=", "\"\"", "+", "item", ".", "name", "+", "\"</font>\"", ";", "if", "(", "item", ".", "mailTo", "!=", "null", "&&", "!", "item", ".", "mailTo", ".", "equals", "(", "\"\"", ")", ")", "{", "title_base", "+=", "\"\"", "+", "item", ".", "mailTo", "+", "\"</font>\"", ";", "}", "if", "(", "item", ".", "imgURL", "!=", "null", ")", "{", "File", "imgFile", "=", "new", "File", "(", "item", ".", "bigImgURL", ")", ";", "title_base", "+=", "\"\"", "+", "imgFile", ".", "getName", "(", ")", "+", "\"</font>\"", ";", "}", "if", "(", "activity", ".", "currentSize", "!=", "0", "&&", "position", ">=", "activity", ".", "prevSize", ")", "{", "title_base", "+=", "\"", "New!\"", ";", "if", "(", "position", "!=", "0", ")", "{", "title_base", "=", "\"\"", "+", "(", "position", "-", "1", ")", "+", "\"]</font>", "\"", "+", "title_base", ";", "}", "}", "else", "{", "if", "(", "position", "!=", "0", ")", "{", "title_base", "=", "\"\"", "+", "position", "+", "\"]</font>", "\"", "+", "title_base", ";", "}", "}", "}", "else", "{", "if", "(", "position", "!=", "0", ")", "{", "title_base", "=", "\"\"", "+", "position", "+", "\"</font>]", "\"", "+", "title_base", ";", "}", "if", "(", "item", ".", "mailTo", "!=", "null", "&&", "!", "item", ".", "mailTo", ".", "equals", "(", "\"\"", ")", ")", "{", "title_base", "+=", "\"\"", "+", "item", ".", "mailTo", "+", "\"</font>\"", ";", "}", "}", "CharSequence", "cs_title", "=", "Html", ".", "fromHtml", "(", "title_base", ")", ";", "title", ".", "setText", "(", "cs_title", ")", ";", "text", ".", "setTextSize", "(", "StateMan", ".", "getMainFontSize", "(", "getContext", "(", ")", ")", ")", ";", "bottomtext", ".", "setTextSize", "(", "StateMan", ".", "getDescFontSize", "(", "getContext", "(", ")", ")", ")", ";", "if", "(", "item", ".", "datestr", "!=", "null", ")", "{", "bottomtext", ".", "setText", "(", "item", ".", "datestr", "+", "\"", "No.\"", "+", "item", ".", "id", ")", ";", "}", "if", "(", "position", "==", "0", ")", "{", "view", ".", "setBackgroundColor", "(", "Color", ".", "rgb", "(", "255", ",", "255", ",", "238", ")", ")", ";", "}", "else", "{", "if", "(", "item", ".", "id", "!=", "0", "&&", "item", ".", "id", "==", "shioriPosition", ")", "{", "setShioriStatus", "(", "view", ")", ";", "}", "else", "{", "view", ".", "setBackgroundColor", "(", "Color", ".", "rgb", "(", "240", ",", "224", ",", "214", ")", ")", ";", "}", "}", "text", ".", "setGravity", "(", "Gravity", ".", "LEFT", ")", ";", "title", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "bottomtext", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "Bitmap", "bm", "=", "null", ";", "LinearLayout", "imageframe", "=", "(", "LinearLayout", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "imageframe", ")", ";", "Button", "saveButton", "=", "(", "Button", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "savebutton", ")", ";", "ImageView", "iv", "=", "(", "ImageView", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "image", ")", ";", "iv", ".", "setImageBitmap", "(", "bm", ")", ";", "try", "{", "if", "(", "item", ".", "imgURL", "!=", "null", ")", "{", "iv", ".", "setTag", "(", "item", ".", "bigImgURL", ")", ";", "bm", "=", "Bitmap", ".", "createBitmap", "(", "item", ".", "width", ",", "item", ".", "height", ",", "Bitmap", ".", "Config", ".", "ALPHA_8", ")", ";", "iv", ".", "setImageBitmap", "(", "bm", ")", ";", "ImageGetTask", "task", "=", "new", "ImageGetTask", "(", "view", ")", ";", "SharedPreferences", "preferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "getContext", "(", ")", ")", ";", "boolean", "enableSaveButton", "=", "preferences", ".", "getBoolean", "(", "getContext", "(", ")", ".", "getString", "(", "R", ".", "string", ".", "enablesavebutton", ")", ",", "false", ")", ";", "if", "(", "enableSaveButton", ")", "{", "saveButton", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "}", "else", "{", "saveButton", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "}", "view", ".", "setLongClickable", "(", "true", ")", ";", "iif", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "if", "(", "!", "StateMan", ".", "getVerticalThreadRow", "(", "getContext", "(", ")", ")", ")", "{", "final", "float", "dip2pxscale", "=", "getContext", "(", ")", ".", "getResources", "(", ")", ".", "getDisplayMetrics", "(", ")", ".", "density", ";", "int", "imageRectWidth", "=", "Math", ".", "max", "(", "(", "int", ")", "(", "dip2pxscale", "*", "110.0", ")", ",", "item", ".", "width", ")", "+", "(", "int", ")", "(", "dip2pxscale", "*", "12.0", ")", ";", "iif", ".", "setLayoutParams", "(", "createParam", "(", "imageRectWidth", ",", "LayoutParams", ".", "FILL_PARENT", ")", ")", ";", "}", "task", ".", "execute", "(", "item", ".", "imgURL", ")", ";", "}", "else", "{", "iv", ".", "setTag", "(", "null", ")", ";", "iif", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "saveButton", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "if", "(", "text", "!=", "null", ")", "{", "String", "text_html", "=", "item", ".", "text", ";", "text_html", "=", "addHighlight", "(", "text_html", ")", ";", "CharSequence", "cs", "=", "Html", ".", "fromHtml", "(", "text_html", ")", ";", "text", ".", "setText", "(", "cs", ")", ";", "}", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "return", "view", ";", "}", "private", "LinearLayout", ".", "LayoutParams", "createParam", "(", "int", "width", ",", "int", "height", ")", "{", "return", "new", "LinearLayout", ".", "LayoutParams", "(", "width", ",", "height", ")", ";", "}", "void", "setShioriStatus", "(", "View", "view", ")", "{", "view", ".", "setBackgroundColor", "(", "Color", ".", "parseColor", "(", "\"#BBFFBB\"", ")", ")", ";", "TextView", "bottomText", "=", "(", "TextView", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "bottomtext", ")", ";", "String", "bottomTextStr", "=", "\"[-UNK-]\"", "+", "bottomText", ".", "getText", "(", ")", ".", "toString", "(", ")", ";", "bottomText", ".", "setText", "(", "bottomTextStr", ")", ";", "}", "static", "int", "getSmlImageWidth", "(", "Bitmap", "bm", ",", "int", "width", ",", "int", "height", ")", "{", "float", "s_x", "=", "Math", ".", "max", "(", "1.0f", ",", "(", "float", ")", "bm", ".", "getWidth", "(", ")", "*", "1.5f", "/", "(", "float", ")", "width", ")", ";", "float", "s_y", "=", "Math", ".", "max", "(", "1.0f", ",", "(", "float", ")", "bm", ".", "getHeight", "(", ")", "*", "2.0f", "/", "(", "float", ")", "height", ")", ";", "float", "scale", "=", "Math", ".", "max", "(", "s_x", ",", "s_y", ")", ";", "return", "(", "int", ")", "(", "bm", ".", "getWidth", "(", ")", "/", "scale", ")", ";", "}", "static", "int", "getSmlImageHeight", "(", "Bitmap", "bm", ",", "int", "width", ",", "int", "height", ")", "{", "float", "s_x", "=", "Math", ".", "max", "(", "1.0f", ",", "(", "float", ")", "bm", ".", "getWidth", "(", ")", "*", "1.5f", "/", "(", "float", ")", "width", ")", ";", "float", "s_y", "=", "Math", ".", "max", "(", "1.0f", ",", "(", "float", ")", "bm", ".", "getHeight", "(", ")", "*", "2.0f", "/", "(", "float", ")", "height", ")", ";", "float", "scale", "=", "Math", ".", "max", "(", "s_x", ",", "s_y", ")", ";", "return", "(", "int", ")", "(", "bm", ".", "getHeight", "(", ")", "/", "scale", ")", ";", "}", "class", "ImageGetTask", "extends", "AsyncTask", "<", "String", ",", "Void", ",", "Bitmap", ">", "{", "private", "ImageView", "image", ";", "private", "Button", "saveButton", ";", "private", "String", "tag", ";", "public", "ImageGetTask", "(", "View", "view", ")", "{", "image", "=", "(", "ImageView", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "image", ")", ";", "saveButton", "=", "(", "Button", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "savebutton", ")", ";", "if", "(", "image", "==", "null", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "}", "tag", "=", "image", ".", "getTag", "(", ")", ".", "toString", "(", ")", ";", "}", "@", "Override", "protected", "Bitmap", "doInBackground", "(", "String", "...", "urls", ")", "{", "Bitmap", "bm", "=", "ImageCache", ".", "getImage", "(", "urls", "[", "0", "]", ")", ";", "FLog", ".", "d", "(", "\"\"", ")", ";", "if", "(", "bm", "==", "null", ")", "{", "try", "{", "ImageCache", ".", "setImage", "(", "urls", "[", "0", "]", ")", ";", "bm", "=", "ImageCache", ".", "getImage", "(", "urls", "[", "0", "]", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "FLog", ".", "d", "(", "\"fail", "with", "\"", "+", "urls", "[", "0", "]", ")", ";", "try", "{", "Thread", ".", "sleep", "(", "1", "*", "1000", ")", ";", "}", "catch", "(", "Exception", "e2", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e2", ")", ";", "}", "}", "finally", "{", "}", "}", "return", "bm", ";", "}", "@", "Override", "protected", "void", "onPostExecute", "(", "Bitmap", "result", ")", "{", "try", "{", "if", "(", "image", "!=", "null", "&&", "tag", ".", "equals", "(", "image", ".", "getTag", "(", ")", ")", ")", "{", "if", "(", "result", "==", "null", ")", "{", "TextView", "screenName", "=", "(", "TextView", ")", "image", ".", "findViewById", "(", "R", ".", "id", ".", "title", ")", ";", "if", "(", "screenName", "!=", "null", ")", "{", "screenName", ".", "setText", "(", "\"(-UNK-)\"", ")", ";", "}", "return", ";", "}", "image", ".", "setImageBitmap", "(", "result", ")", ";", "image", ".", "setOnClickListener", "(", "new", "View", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "View", "v", ")", "{", "try", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "Intent", "intent", "=", "new", "Intent", "(", ")", ";", "FutabaThread", "activity", "=", "(", "FutabaThread", ")", "getContext", "(", ")", ";", "intent", ".", "putExtra", "(", "\"imgURLs\"", ",", "activity", ".", "getImageURLs", "(", ")", ")", ";", "intent", ".", "putExtra", "(", "\"thumbURLs\"", ",", "activity", ".", "getThumbURLs", "(", ")", ")", ";", "intent", ".", "putExtra", "(", "\"myImgURL\"", ",", "tag", ")", ";", "intent", ".", "setClassName", "(", "activity", ".", "getPackageName", "(", ")", ",", "activity", ".", "getClass", "(", ")", ".", "getPackage", "(", ")", ".", "getName", "(", ")", "+", "\"\"", ")", ";", "activity", ".", "startActivityForResult", "(", "intent", ",", "activity", ".", "TO_IMAGECATALOG", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", ")", ";", "saveButton", ".", "setOnClickListener", "(", "new", "View", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "View", "v", ")", "{", "try", "{", "FutabaThread", "fthread", "=", "(", "FutabaThread", ")", "v", ".", "getContext", "(", ")", ";", "fthread", ".", "saveImage", "(", "tag", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", "public", "String", "addHighlight", "(", "String", "title", ")", "{", "if", "(", "searchQueries", "!=", "null", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "searchQueries", ".", "length", ";", "++", "i", ")", "{", "String", "searchQuery", "=", "searchQueries", "[", "i", "]", ";", "title", "=", "title", ".", "replaceAll", "(", "searchQuery", ",", "\"\"", "+", "searchQuery", "+", "\"</font>\"", ")", ";", "FLog", ".", "d", "(", "\"searchrep\"", "+", "searchQuery", ")", ";", "FLog", ".", "d", "(", "\"replaced\"", "+", "title", ")", ";", "}", "}", "return", "title", ";", "}", "}", "</s>" ]
8,243
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "android", ".", "app", ".", "AlertDialog", ";", "import", "android", ".", "app", ".", "LocalActivityManager", ";", "import", "android", ".", "app", ".", "ProgressDialog", ";", "import", "android", ".", "app", ".", "TabActivity", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "DialogInterface", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "content", ".", "SharedPreferences", ";", "import", "android", ".", "graphics", ".", "Color", ";", "import", "android", ".", "net", ".", "Uri", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "os", ".", "Environment", ";", "import", "android", ".", "os", ".", "Handler", ";", "import", "android", ".", "os", ".", "Message", ";", "import", "android", ".", "preference", ".", "PreferenceManager", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "view", ".", "LayoutInflater", ";", "import", "android", ".", "view", ".", "Menu", ";", "import", "android", ".", "view", ".", "MenuInflater", ";", "import", "android", ".", "view", ".", "MenuItem", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "view", ".", "Window", ";", "import", "android", ".", "view", ".", "WindowManager", ";", "import", "android", ".", "widget", ".", "FrameLayout", ";", "import", "android", ".", "widget", ".", "ImageView", ";", "import", "android", ".", "widget", ".", "TabHost", ";", "import", "android", ".", "widget", ".", "TextView", ";", "import", "android", ".", "widget", ".", "Toast", ";", "import", "android", ".", "widget", ".", "TabHost", ".", "TabSpec", ";", "import", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ".", "R", ".", "id", ";", "public", "class", "ftbt", "extends", "TabActivity", "implements", "Runnable", "{", "public", "ArrayList", "<", "FutabaBBSContent", ">", "favoriteBBSs", "=", "new", "ArrayList", "<", "FutabaBBSContent", ">", "(", ")", ";", "private", "boolean", "doCacheCheck", "=", "false", ";", "ProgressDialog", "waitDialog", ";", "Thread", "thread", ";", "TabHost", "tabs", ";", "final", "int", "ON_SETTING", "=", "10000", ";", "public", "void", "myStart", "(", ")", "{", "tabs", "=", "getTabHost", "(", ")", ";", "TabSpec", "tab00", "=", "tabs", ".", "newTabSpec", "(", "\"TabSheet0\"", ")", ";", "View", "v1", "=", "new", "MyView", "(", "this", ",", "\"-UNK-\"", ")", ";", "tab00", ".", "setIndicator", "(", "v1", ")", ";", "Intent", "intent", "=", "new", "Intent", "(", ")", ".", "setClassName", "(", "getPackageName", "(", ")", ",", "getClass", "(", ")", ".", "getPackage", "(", ")", ".", "getName", "(", ")", "+", "\".DummyTab\"", ")", ";", "tab00", ".", "setContent", "(", "intent", ")", ";", "tabs", ".", "addTab", "(", "tab00", ")", ";", "}", "@", "Override", "public", "void", "onCreate", "(", "Bundle", "savedInstanceState", ")", "{", "super", ".", "onCreate", "(", "savedInstanceState", ")", ";", "if", "(", "getResources", "(", ")", ".", "getBoolean", "(", "R", ".", "bool", ".", "avoidsleep", ")", ")", "{", "Window", "window", "=", "getWindow", "(", ")", ";", "window", ".", "addFlags", "(", "WindowManager", ".", "LayoutParams", ".", "FLAG_KEEP_SCREEN_ON", ")", ";", "}", "myStart", "(", ")", ";", "setWait", "(", ")", ";", "}", "public", "void", "setWait", "(", ")", "{", "SharedPreferences", "preferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "this", ")", ";", "Boolean", "checkCache", "=", "preferences", ".", "getBoolean", "(", "\"checkCache\"", ",", "false", ")", ";", "if", "(", "checkCache", ")", "{", "AlertDialog", ".", "Builder", "builder", "=", "new", "AlertDialog", ".", "Builder", "(", "this", ")", ";", "builder", ".", "setMessage", "(", "\"\"", ")", ".", "setCancelable", "(", "true", ")", ".", "setPositiveButton", "(", "\"-UNK-\"", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "id", ")", "{", "doCacheCheck", "=", "true", ";", "setWait2", "(", ")", ";", "}", "}", ")", ".", "setNegativeButton", "(", "\"-UNK-\"", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "id", ")", "{", "doCacheCheck", "=", "false", ";", "setWait2", "(", ")", ";", "}", "}", ")", ";", "builder", ".", "create", "(", ")", ".", "show", "(", ")", ";", "}", "else", "{", "doCacheCheck", "=", "true", ";", "setWait2", "(", ")", ";", "}", "}", "public", "void", "setWait2", "(", ")", "{", "if", "(", "doCacheCheck", ")", "{", "waitDialog", "=", "new", "ProgressDialog", "(", "this", ")", ";", "waitDialog", ".", "setMessage", "(", "\"\"", ")", ";", "waitDialog", ".", "setProgressStyle", "(", "ProgressDialog", ".", "STYLE_SPINNER", ")", ";", "waitDialog", ".", "show", "(", ")", ";", "}", "thread", "=", "new", "Thread", "(", "this", ")", ";", "thread", ".", "start", "(", ")", ";", "}", "public", "void", "run", "(", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "100", ")", ";", "if", "(", "doCacheCheck", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "checkCache", "(", ")", ";", "}", "else", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "}", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "handler", ".", "sendEmptyMessage", "(", "0", ")", ";", "}", "private", "Handler", "handler", "=", "new", "Handler", "(", ")", "{", "public", "void", "handleMessage", "(", "Message", "msg", ")", "{", "FLog", ".", "d", "(", "\"handle", "msg\"", "+", "msg", ")", ";", "try", "{", "if", "(", "doCacheCheck", ")", "{", "try", "{", "waitDialog", ".", "dismiss", "(", ")", ";", "Thread", ".", "sleep", "(", "100", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "loading", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", ";", "public", "void", "checkCache", "(", ")", "{", "try", "{", "SharedPreferences", "preferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "this", ")", ";", "int", "cacheSize", "=", "Integer", ".", "parseInt", "(", "preferences", ".", "getString", "(", "getString", "(", "R", ".", "string", ".", "cachesize", ")", ",", "\"5\"", ")", ")", ";", "FLog", ".", "d", "(", "\"cachesize=\"", "+", "cacheSize", ")", ";", "SDCard", ".", "limitCache", "(", "cacheSize", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "FLog", ".", "d", "(", "\"\"", ")", ";", "}", "public", "void", "loading", "(", ")", "{", "try", "{", "SDCard", ".", "setCacheDir", "(", "this", ")", ";", "SDCard", ".", "setSaveDir", "(", "this", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "if", "(", "!", "SDCard", ".", "isSDCardMounted", "(", ")", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "\"\"", ",", "Toast", ".", "LENGTH_LONG", ")", ".", "show", "(", ")", ";", "}", "try", "{", "String", "saveDir", "=", "SDCard", ".", "getSaveDir", "(", ")", ";", "if", "(", "saveDir", "==", "null", ")", "{", "throw", "new", "Exception", "(", "\"bad", "userdir\"", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "if", "(", "waitDialog", "!=", "null", ")", "{", "waitDialog", ".", "dismiss", "(", ")", ";", "}", "Toast", ".", "makeText", "(", "this", ",", "\"-UNK-\\\"\"", "+", "SDCard", ".", "saveDir", "+", "\"\"", "+", "\"-UNK-\"", "+", "Environment", ".", "getExternalStorageDirectory", "(", ")", "+", "\"-UNK-\"", ",", "Toast", ".", "LENGTH_LONG", ")", ".", "show", "(", ")", ";", "return", ";", "}", "Intent", "intent", ";", "try", "{", "tabs", ".", "getTabWidget", "(", ")", ".", "getChildAt", "(", "0", ")", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "int", "tabNum", "=", "tabs", ".", "getTabWidget", "(", ")", ".", "getChildCount", "(", ")", ";", "favoriteBBSs", "=", "new", "ArrayList", "<", "FutabaBBSContent", ">", "(", ")", ";", "FLog", ".", "d", "(", "\"favbbs=\"", "+", "favoriteBBSs", ")", ";", "favoriteBBSs", "=", "FavoriteSettings", ".", "getFavorites", "(", "this", ")", ";", "intent", "=", "new", "Intent", "(", ")", ".", "setClassName", "(", "getPackageName", "(", ")", ",", "getClass", "(", ")", ".", "getPackage", "(", ")", ".", "getName", "(", ")", "+", "\"\"", ")", ";", "intent", ".", "putExtra", "(", "\"mode\"", ",", "\"all\"", ")", ";", "TabSpec", "tab01", "=", "tabs", ".", "newTabSpec", "(", "\"TabSheet1\"", ")", ";", "View", "v1", "=", "new", "MyView", "(", "this", ",", "\"-UNK-\"", ")", ";", "tab01", ".", "setIndicator", "(", "v1", ")", ";", "tab01", ".", "setContent", "(", "intent", ")", ";", "tabs", ".", "addTab", "(", "tab01", ")", ";", "intent", "=", "new", "Intent", "(", ")", ".", "setClassName", "(", "getPackageName", "(", ")", ",", "getClass", "(", ")", ".", "getPackage", "(", ")", ".", "getName", "(", ")", "+", "\"\"", ")", ";", "intent", ".", "putExtra", "(", "\"mode\"", ",", "\"fav\"", ")", ";", "TabSpec", "tab02", "=", "tabs", ".", "newTabSpec", "(", "\"TabSheet2\"", ")", ";", "View", "v2", "=", "new", "MyView", "(", "this", ",", "\"-UNK-\"", ")", ";", "tab02", ".", "setIndicator", "(", "v2", ")", ";", "tab02", ".", "setContent", "(", "intent", ")", ";", "tabs", ".", "addTab", "(", "tab02", ")", ";", "if", "(", "favoriteBBSs", ".", "size", "(", ")", ">", "0", ")", "{", "tabs", ".", "setCurrentTab", "(", "2", ")", ";", "}", "else", "{", "tabs", ".", "setCurrentTab", "(", "1", ")", ";", "}", "setTitle", "(", "\"BBS-UNK-", "-", "\"", "+", "getString", "(", "R", ".", "string", ".", "app_name", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "FLog", ".", "d", "(", "\"ftbt", "start\"", ")", ";", "}", "public", "void", "addFavoriteBBSs", "(", "FutabaBBSContent", "bbs", ")", "{", "FLog", ".", "d", "(", "\"\"", "+", "favoriteBBSs", ".", "toString", "(", ")", ")", ";", "try", "{", "if", "(", "favoriteBBSs", ".", "indexOf", "(", "bbs", ")", "==", "-", "1", ")", "{", "FLog", ".", "d", "(", "\"add", "\"", "+", "bbs", ".", "toString", "(", ")", ")", ";", "favoriteBBSs", ".", "add", "(", "bbs", ")", ";", "FavoriteSettings", ".", "setFavorites", "(", "this", ",", "favoriteBBSs", ")", ";", "}", "else", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "public", "void", "removeFavoriteBBSs", "(", "FutabaBBSContent", "bbs", ")", "{", "try", "{", "favoriteBBSs", ".", "remove", "(", "bbs", ")", ";", "FavoriteSettings", ".", "setFavorites", "(", "this", ",", "favoriteBBSs", ")", ";", "FLog", ".", "d", "(", "\"remove", "\"", "+", "bbs", ".", "toString", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "@", "Override", "public", "boolean", "onCreateOptionsMenu", "(", "Menu", "menu", ")", "{", "super", ".", "onCreateOptionsMenu", "(", "menu", ")", ";", "MenuInflater", "inflater", "=", "getMenuInflater", "(", ")", ";", "inflater", ".", "inflate", "(", "R", ".", "menu", ".", "menu_bbsmenu", ",", "menu", ")", ";", "return", "true", ";", "}", "@", "Override", "public", "boolean", "onOptionsItemSelected", "(", "MenuItem", "item", ")", "{", "Intent", "intent", ";", "switch", "(", "item", ".", "getItemId", "(", ")", ")", "{", "case", "R", ".", "id", ".", "settings", ":", "intent", "=", "new", "Intent", "(", ")", ";", "intent", ".", "setClassName", "(", "getPackageName", "(", ")", ",", "getClass", "(", ")", ".", "getPackage", "(", ")", ".", "getName", "(", ")", "+", "\".PrefSetting\"", ")", ";", "startActivityForResult", "(", "intent", ",", "ON_SETTING", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "about", ":", "Uri", "uri", "=", "Uri", ".", "parse", "(", "getString", "(", "R", ".", "string", ".", "helpurl", ")", ")", ";", "intent", "=", "new", "Intent", "(", "Intent", ".", "ACTION_VIEW", ",", "uri", ")", ";", "intent", ".", "setClassName", "(", "\"\"", ",", "\"\"", ")", ";", "try", "{", "startActivity", "(", "intent", ")", ";", "}", "catch", "(", "android", ".", "content", ".", "ActivityNotFoundException", "ex", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "\"-UNK-\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}", "private", "class", "MyView", "extends", "FrameLayout", "{", "private", "LayoutInflater", "inflater", ";", "public", "MyView", "(", "Context", "context", ")", "{", "super", "(", "context", ")", ";", "inflater", "=", "LayoutInflater", ".", "from", "(", "context", ")", ";", "}", "public", "MyView", "(", "Context", "context", ",", "String", "title", ")", "{", "this", "(", "context", ")", ";", "try", "{", "View", "v", "=", "inflater", ".", "inflate", "(", "R", ".", "layout", ".", "tabwidget", ",", "null", ")", ";", "TextView", "tv", "=", "(", "TextView", ")", "v", ".", "findViewById", "(", "R", ".", "id", ".", "text", ")", ";", "tv", ".", "setText", "(", "title", ")", ";", "addView", "(", "v", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", "protected", "void", "onActivityResult", "(", "int", "requestCode", ",", "int", "resultCode", ",", "Intent", "data", ")", "{", "FLog", ".", "d", "(", "\"onhoge\"", ")", ";", "if", "(", "requestCode", "==", "ON_SETTING", ")", "{", "}", "}", "@", "Override", "public", "void", "onResume", "(", ")", "{", "super", ".", "onResume", "(", ")", ";", "FLog", ".", "d", "(", "\"\"", ")", ";", "}", "}", "</s>" ]
8,244
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "public", "class", "ImageUpdateGallery", "{", "}", "</s>" ]
8,245
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Calendar", ";", "import", "java", ".", "util", ".", "TreeSet", ";", "import", "android", ".", "app", ".", "Activity", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "content", ".", "SharedPreferences", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "widget", ".", "TextView", ";", "import", "android", ".", "graphics", ".", "Typeface", ";", "import", "android", ".", "view", ".", "ViewGroup", ";", "import", "android", ".", "widget", ".", "ArrayAdapter", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "view", ".", "LayoutInflater", ";", "import", "android", ".", "text", ".", "Html", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "os", ".", "AsyncTask", ";", "import", "android", ".", "preference", ".", "PreferenceManager", ";", "import", "android", ".", "view", ".", "View", ".", "OnClickListener", ";", "import", "android", ".", "widget", ".", "AdapterView", ";", "import", "android", ".", "widget", ".", "CheckBox", ";", "import", "android", ".", "widget", ".", "CompoundButton", ";", "import", "android", ".", "widget", ".", "CompoundButton", ".", "OnCheckedChangeListener", ";", "import", "android", ".", "widget", ".", "ListView", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ".", "R", ".", "id", ";", "import", "android", ".", "graphics", ".", "Bitmap", ";", "import", "android", ".", "graphics", ".", "BitmapFactory", ";", "import", "android", ".", "graphics", ".", "Color", ";", "import", "android", ".", "widget", ".", "ImageView", ";", "import", "android", ".", "view", ".", "WindowManager", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "view", ".", "Display", ";", "public", "class", "CatalogAdapter", "extends", "ArrayAdapter", "{", "public", "ArrayList", "<", "FutabaThreadContent", ">", "items", ";", "private", "LayoutInflater", "inflater", ";", "private", "Context", "context", ";", "private", "TreeSet", "<", "Integer", ">", "checkedSet", "=", "new", "TreeSet", "<", "Integer", ">", "(", ")", ";", "private", "int", "width", ";", "private", "int", "height", ";", "public", "CatalogAdapter", "(", "Context", "context", ",", "int", "textViewResourceId", ",", "ArrayList", "items", ")", "{", "super", "(", "context", ",", "textViewResourceId", ",", "items", ")", ";", "this", ".", "items", "=", "(", "ArrayList", "<", "FutabaThreadContent", ">", ")", "items", ";", "this", ".", "context", "=", "context", ";", "this", ".", "inflater", "=", "(", "LayoutInflater", ")", "context", ".", "getSystemService", "(", "Context", ".", "LAYOUT_INFLATER_SERVICE", ")", ";", "WindowManager", "wm", "=", "(", "(", "WindowManager", ")", "context", ".", "getSystemService", "(", "Context", ".", "WINDOW_SERVICE", ")", ")", ";", "Display", "display", "=", "wm", ".", "getDefaultDisplay", "(", ")", ";", "width", "=", "display", ".", "getWidth", "(", ")", ";", "height", "=", "display", ".", "getHeight", "(", ")", ";", "}", "@", "Override", "public", "View", "getView", "(", "int", "position", ",", "View", "convertView", ",", "ViewGroup", "parent", ")", "{", "View", "view", "=", "convertView", ";", "if", "(", "view", "==", "null", ")", "{", "view", "=", "inflater", ".", "inflate", "(", "R", ".", "layout", ".", "futaba_catalog_row", ",", "null", ")", ";", "}", "try", "{", "final", "FutabaThreadContent", "item", "=", "(", "FutabaThreadContent", ")", "items", ".", "get", "(", "position", ")", ";", "final", "String", "threadNum", "=", "\"\"", "+", "item", ".", "threadNum", ";", "TextView", "text", "=", "(", "TextView", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "bottomtext", ")", ";", "CheckBox", "checkbox", "=", "(", "CheckBox", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "checkbox", ")", ";", "TextView", "nonclickableblank", "=", "(", "TextView", ")", "view", ".", "findViewById", "(", "id", ".", "nonclickableblank", ")", ";", "TextView", "resNum", "=", "(", "TextView", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "resnum", ")", ";", "TextView", "BBSName", "=", "(", "TextView", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "bbsname", ")", ";", "ImageView", "iv", "=", "(", "ImageView", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "image", ")", ";", "Bitmap", "bm", "=", "null", ";", "iv", ".", "setImageBitmap", "(", "bm", ")", ";", "iv", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "if", "(", "FutabaThreadContent", ".", "isMenu1", "(", "item", ")", ")", "{", "text", ".", "setTextSize", "(", "StateMan", ".", "getDescFontSize", "(", "getContext", "(", ")", ")", ")", ";", "text", ".", "setTextColor", "(", "Color", ".", "parseColor", "(", "\"#FFFFFF\"", ")", ")", ";", "text", ".", "setText", "(", "\"\"", ")", ";", "view", ".", "setBackgroundColor", "(", "Color", ".", "parseColor", "(", "\"#996666\"", ")", ")", ";", "checkbox", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "nonclickableblank", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "resNum", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "BBSName", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "iv", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "view", ".", "setOnClickListener", "(", "new", "View", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "View", "v", ")", "{", "}", "}", ")", ";", "return", "view", ";", "}", "else", "if", "(", "FutabaThreadContent", ".", "isMenu2", "(", "item", ")", ")", "{", "text", ".", "setTextSize", "(", "StateMan", ".", "getDescFontSize", "(", "getContext", "(", ")", ")", ")", ";", "text", ".", "setTextColor", "(", "Color", ".", "parseColor", "(", "\"#FFFFFF\"", ")", ")", ";", "text", ".", "setText", "(", "\"-UNK-\"", ")", ";", "view", ".", "setBackgroundColor", "(", "Color", ".", "parseColor", "(", "\"#996666\"", ")", ")", ";", "checkbox", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "nonclickableblank", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "resNum", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "BBSName", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "iv", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "view", ".", "setOnClickListener", "(", "new", "View", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "View", "v", ")", "{", "}", "}", ")", ";", "return", "view", ";", "}", "text", ".", "setTextColor", "(", "Color", ".", "parseColor", "(", "\"#800000\"", ")", ")", ";", "resNum", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "if", "(", "true", ")", "{", "view", ".", "setOnClickListener", "(", "new", "View", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "View", "v", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "Intent", "intent", "=", "new", "Intent", "(", ")", ";", "Catalog", "activity", "=", "(", "Catalog", ")", "getContext", "(", ")", ";", "try", "{", "FutabaThreadContent", "thread", "=", "item", ";", "if", "(", "!", "activity", ".", "mode", ".", "equals", "(", "\"history\"", ")", ")", "{", "thread", ".", "baseUrl", "=", "activity", ".", "baseUrl", ";", "}", "Calendar", "calendar", "=", "Calendar", ".", "getInstance", "(", ")", ";", "thread", ".", "lastAccessed", "=", "calendar", ".", "getTimeInMillis", "(", ")", ";", "HistoryManager", "man", "=", "new", "HistoryManager", "(", ")", ";", "man", ".", "Load", "(", ")", ";", "int", "maxHistoryNum", "=", "20", ";", "try", "{", "SharedPreferences", "preferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "activity", ")", ";", "maxHistoryNum", "=", "Integer", ".", "parseInt", "(", "preferences", ".", "getString", "(", "activity", ".", "getString", "(", "R", ".", "string", ".", "historynum", ")", ",", "\"20\"", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "FLog", ".", "d", "(", "\"\"", "+", "maxHistoryNum", ")", ";", "FLog", ".", "d", "(", "\"add", "thread", "\"", "+", "thread", ".", "toString", "(", ")", ")", ";", "man", ".", "addThread", "(", "thread", ",", "maxHistoryNum", ")", ";", "man", ".", "Save", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "if", "(", "!", "activity", ".", "mode", ".", "equals", "(", "\"history\"", ")", ")", "{", "String", "baseUrl", "=", "activity", ".", "baseUrl", ";", "intent", ".", "putExtra", "(", "\"baseUrl\"", ",", "baseUrl", ")", ";", "intent", ".", "putExtra", "(", "\"BBSName\"", ",", "activity", ".", "BBSName", ")", ";", "FLog", ".", "d", "(", "\"\"", ")", ";", "}", "else", "{", "String", "baseUrl", "=", "item", ".", "baseUrl", ";", "intent", ".", "putExtra", "(", "\"baseUrl\"", ",", "baseUrl", ")", ";", "intent", ".", "putExtra", "(", "\"BBSName\"", ",", "item", ".", "BBSName", ")", ";", "FLog", ".", "d", "(", "\"\"", ")", ";", "}", "intent", ".", "putExtra", "(", "\"threadNum\"", ",", "threadNum", ")", ";", "intent", ".", "setClassName", "(", "activity", ".", "getPackageName", "(", ")", ",", "activity", ".", "getClass", "(", ")", ".", "getPackage", "(", ")", ".", "getName", "(", ")", "+", "\"\"", ")", ";", "activity", ".", "startActivity", "(", "intent", ")", ";", "}", "}", ")", ";", "}", "Catalog", "activity", "=", "(", "Catalog", ")", "getContext", "(", ")", ";", "final", "int", "pos", "=", "position", ";", "if", "(", "item", "!=", "null", ")", "{", "text", ".", "setTextSize", "(", "StateMan", ".", "getMainFontSize", "(", "getContext", "(", ")", ")", ")", ";", "String", "mainText", "=", "item", ".", "text", ";", "if", "(", "!", "activity", ".", "mode", ".", "equals", "(", "\"history\"", ")", ")", "{", "mainText", "=", "StringUtil", ".", "highlightFocusWordMatched", "(", "mainText", ",", "activity", ".", "focusWords", ")", ";", "try", "{", "FutabaThreadContent", "prevThread", "=", "activity", ".", "man", ".", "get", "(", "item", ".", "threadNum", ")", ";", "int", "diffResNum", "=", "Integer", ".", "parseInt", "(", "item", ".", "resNum", ")", "-", "Integer", ".", "parseInt", "(", "prevThread", ".", "resNum", ")", ";", "resNum", ".", "setText", "(", "Html", ".", "fromHtml", "(", "item", ".", "resNum", "+", "\"-UNK-\"", "+", "\"\"", "+", "Math", ".", "max", "(", "0", ",", "diffResNum", ")", "+", "\"-UNK-)</font>\"", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"thread", "\"", "+", "item", ".", "threadNum", "+", "\"", "not", "found\"", ")", ";", "resNum", ".", "setText", "(", "item", ".", "resNum", "+", "\"-UNK-\"", ")", ";", "}", "}", "else", "{", "resNum", ".", "setText", "(", "item", ".", "resNum", "+", "\"-UNK-\"", ")", ";", "}", "if", "(", "item", ".", "text", "!=", "null", ")", "{", "CharSequence", "cs", "=", "Html", ".", "fromHtml", "(", "mainText", ")", ";", "text", ".", "setText", "(", "cs", ")", ";", "}", "resNum", ".", "setTextSize", "(", "StateMan", ".", "getDescFontSize", "(", "getContext", "(", ")", ")", ")", ";", "BBSName", ".", "setTextSize", "(", "StateMan", ".", "getDescFontSize", "(", "getContext", "(", ")", ")", ")", ";", "nonclickableblank", ".", "setTextSize", "(", "StateMan", ".", "getDescFontSize", "(", "getContext", "(", ")", ")", ")", ";", "if", "(", "activity", ".", "mode", ".", "equals", "(", "\"history\"", ")", ")", "{", "BBSName", ".", "setText", "(", "\"(\"", "+", "item", ".", "BBSName", "+", "\")\"", ")", ";", "view", ".", "setBackgroundColor", "(", "Color", ".", "parseColor", "(", "\"#F0E0D6\"", ")", ")", ";", "checkbox", ".", "setChecked", "(", "item", ".", "isChecked", ")", ";", "checkbox", ".", "setOnCheckedChangeListener", "(", "new", "OnCheckedChangeListener", "(", ")", "{", "public", "void", "onCheckedChanged", "(", "CompoundButton", "buttonView", ",", "boolean", "isChecked", ")", "{", "FLog", ".", "d", "(", "\"\"", "+", "buttonView", ".", "isShown", "(", ")", ")", ";", "FLog", ".", "d", "(", "\"\"", "+", "pos", "+", "\"", "with\"", "+", "isChecked", ")", ";", "if", "(", "buttonView", ".", "isShown", "(", ")", ")", "{", "items", ".", "get", "(", "pos", ")", ".", "isChecked", "=", "isChecked", ";", "}", "}", "}", ")", ";", "}", "else", "{", "view", ".", "setBackgroundColor", "(", "Color", ".", "parseColor", "(", "\"#FFFFEE\"", ")", ")", ";", "checkbox", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "nonclickableblank", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "}", "bm", "=", "Bitmap", ".", "createBitmap", "(", "50", ",", "50", ",", "Bitmap", ".", "Config", ".", "ALPHA_8", ")", ";", "iv", ".", "setImageBitmap", "(", "bm", ")", ";", "try", "{", "if", "(", "item", ".", "imgURL", "!=", "null", ")", "{", "iv", ".", "setTag", "(", "item", ".", "imgURL", ")", ";", "ImageGetTask", "task", "=", "new", "ImageGetTask", "(", "iv", ")", ";", "task", ".", "execute", "(", "item", ".", "imgURL", ")", ";", "}", "else", "{", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "return", "view", ";", "}", "static", "Object", "lock_id", "=", "new", "Object", "(", ")", ";", "static", "int", "LastTaskID", "=", "-", "1", ";", "class", "ImageGetTask", "extends", "AsyncTask", "<", "String", ",", "Void", ",", "Bitmap", ">", "{", "private", "ImageView", "image", ";", "private", "String", "tag", ";", "private", "int", "id", ";", "public", "ImageGetTask", "(", "ImageView", "_image", ")", "{", "image", "=", "_image", ";", "tag", "=", "_image", ".", "getTag", "(", ")", ".", "toString", "(", ")", ";", "synchronized", "(", "CatalogAdapter", ".", "lock_id", ")", "{", "CatalogAdapter", ".", "LastTaskID", "+=", "1", ";", "id", "=", "CatalogAdapter", ".", "LastTaskID", ";", "}", "}", "@", "Override", "protected", "Bitmap", "doInBackground", "(", "String", "...", "urls", ")", "{", "Bitmap", "bm", "=", "null", ";", "try", "{", "bm", "=", "ImageCache", ".", "getImage", "(", "urls", "[", "0", "]", ")", ";", "if", "(", "bm", "==", "null", ")", "{", "ImageCache", ".", "setImage", "(", "urls", "[", "0", "]", ")", ";", "bm", "=", "ImageCache", ".", "getImage", "(", "urls", "[", "0", "]", ")", ";", "}", "bm", "=", "ImageResizer", ".", "ResizeWideToSquare", "(", "bm", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "e", ".", "toString", "(", ")", ")", ";", "}", "return", "bm", ";", "}", "@", "Override", "protected", "void", "onPostExecute", "(", "Bitmap", "result", ")", "{", "if", "(", "result", "!=", "null", "&&", "image", "!=", "null", "&&", "tag", ".", "equals", "(", "image", ".", "getTag", "(", ")", ".", "toString", "(", ")", ")", ")", "{", "image", ".", "setImageBitmap", "(", "result", ")", ";", "}", "}", "}", "}", "</s>" ]
8,246
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "io", ".", "ByteArrayOutputStream", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "nio", ".", "charset", ".", "Charset", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "http", ".", "HttpResponse", ";", "import", "org", ".", "apache", ".", "http", ".", "NameValuePair", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "entity", ".", "UrlEncodedFormEntity", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "methods", ".", "HttpGet", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "methods", ".", "HttpPost", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "params", ".", "ClientPNames", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "params", ".", "CookiePolicy", ";", "import", "org", ".", "apache", ".", "http", ".", "cookie", ".", "Cookie", ";", "import", "org", ".", "apache", ".", "http", ".", "entity", ".", "mime", ".", "HttpMultipartMode", ";", "import", "org", ".", "apache", ".", "http", ".", "entity", ".", "mime", ".", "MultipartEntity", ";", "import", "org", ".", "apache", ".", "http", ".", "entity", ".", "mime", ".", "content", ".", "FileBody", ";", "import", "org", ".", "apache", ".", "http", ".", "entity", ".", "mime", ".", "content", ".", "StringBody", ";", "import", "org", ".", "apache", ".", "http", ".", "impl", ".", "client", ".", "DefaultHttpClient", ";", "import", "org", ".", "apache", ".", "http", ".", "message", ".", "BasicNameValuePair", ";", "import", "android", ".", "app", ".", "AlertDialog", ";", "import", "android", ".", "content", ".", "DialogInterface", ";", "import", "android", ".", "content", ".", "DialogInterface", ".", "OnClickListener", ";", "import", "android", ".", "content", ".", "DialogInterface", ".", "OnMultiChoiceClickListener", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "database", ".", "Cursor", ";", "import", "android", ".", "provider", ".", "MediaStore", ";", "import", "android", ".", "text", ".", "InputType", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "widget", ".", "AdapterView", ";", "import", "android", ".", "widget", ".", "EditText", ";", "import", "android", ".", "widget", ".", "TextView", ";", "import", "android", ".", "widget", ".", "Toast", ";", "public", "class", "FutabaThreadOnLongClickListener", "implements", "AdapterView", ".", "OnItemLongClickListener", ",", "OnClickListener", "{", "public", "int", "chosen", "=", "0", ";", "public", "int", "currentPosition", "=", "0", ";", "FutabaThread", "fthread", "=", "null", ";", "public", "boolean", "onItemLongClick", "(", "AdapterView", "<", "?", ">", "arg0", ",", "View", "view", ",", "int", "arg2", ",", "long", "arg3", ")", "{", "if", "(", "view", "==", "null", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "return", "false", ";", "}", "fthread", "=", "(", "FutabaThread", ")", "view", ".", "getContext", "(", ")", ";", "FLog", ".", "d", "(", "\"\"", "+", "arg2", "+", "\"", "arg3=\"", "+", "arg3", ")", ";", "AlertDialog", ".", "Builder", "dlg", ";", "dlg", "=", "new", "AlertDialog", ".", "Builder", "(", "fthread", ")", ";", "dlg", ".", "setTitle", "(", "\"-UNK-\"", ")", ";", "String", "[", "]", "strs_temp", "=", "null", ";", "FutabaStatus", "item", "=", "(", "FutabaStatus", ")", "fthread", ".", "adapter", ".", "items", ".", "get", "(", "arg2", ")", ";", "if", "(", "arg2", "==", "0", ")", "{", "String", "[", "]", "temp", "=", "{", "\"-UNK-\"", ",", "\"-UNK-\"", ",", "\"-UNK-\"", "}", ";", "strs_temp", "=", "temp", ";", "}", "else", "if", "(", "item", "!=", "null", "&&", "item", ".", "id", "!=", "fthread", ".", "adapter", ".", "shioriPosition", ")", "{", "String", "[", "]", "temp", "=", "{", "\"-UNK-\"", ",", "\"-UNK-\"", ",", "\"-UNK-\"", ",", "\"-UNK-\"", "}", ";", "strs_temp", "=", "temp", ";", "}", "else", "{", "String", "[", "]", "temp", "=", "{", "\"-UNK-\"", ",", "\"-UNK-\"", ",", "\"-UNK-\"", ",", "\"-UNK-\"", "}", ";", "strs_temp", "=", "temp", ";", "}", "if", "(", "arg2", "<", "0", "||", "arg2", ">=", "fthread", ".", "adapter", ".", "items", ".", "size", "(", ")", "||", "FutabaStatus", ".", "isBlank", "(", "(", "FutabaStatus", ")", "(", "fthread", ".", "adapter", ".", "items", ".", "get", "(", "arg2", ")", ")", ")", ")", "{", "return", "false", ";", "}", "currentPosition", "=", "arg2", ";", "final", "String", "[", "]", "strs", "=", "strs_temp", ";", "final", "View", "view_f", "=", "view", ";", "dlg", ".", "setSingleChoiceItems", "(", "strs", ",", "0", ",", "this", ")", ";", "dlg", ".", "setPositiveButton", "(", "\"OK\"", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "id", ")", "{", "FLog", ".", "d", "(", "\"onclick", "id=\"", "+", "id", "+", "\"", "chosen=\"", "+", "chosen", ")", ";", "if", "(", "chosen", "==", "0", ")", "{", "processDeleteDialog", "(", "view_f", ")", ";", "}", "else", "if", "(", "chosen", "==", "1", ")", "{", "processQuoteDialog", "(", "view_f", ")", ";", "}", "else", "if", "(", "chosen", "==", "2", ")", "{", "processShareDialog", "(", "view_f", ")", ";", "}", "else", "if", "(", "chosen", "==", "3", ")", "{", "modifyShiori", "(", "view_f", ")", ";", "}", "}", "}", ")", ";", "dlg", ".", "setNegativeButton", "(", "\"-UNK-\"", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "id", ")", "{", "}", "}", ")", ";", "dlg", ".", "show", "(", ")", ";", "return", "false", ";", "}", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "which", ")", "{", "chosen", "=", "which", ";", "}", "public", "void", "processQuoteDialog", "(", "View", "view", ")", "{", "chosen", "=", "0", ";", "TextView", "text", "=", "(", "TextView", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "maintext", ")", ";", "if", "(", "text", "!=", "null", ")", "{", "String", "[", "]", "addition", "=", "{", "}", ";", "final", "String", "strs_all", "=", "text", ".", "getText", "(", ")", ".", "toString", "(", ")", ";", "final", "String", "[", "]", "strs", "=", "StringUtil", ".", "nonBlankSplit", "(", "strs_all", ",", "addition", ")", ";", "final", "boolean", "[", "]", "quoteFlags", "=", "new", "boolean", "[", "strs", ".", "length", "]", ";", "AlertDialog", ".", "Builder", "dlg", ";", "dlg", "=", "new", "AlertDialog", ".", "Builder", "(", "fthread", ")", ";", "dlg", ".", "setTitle", "(", "\"-UNK-\"", ")", ";", "dlg", ".", "setCancelable", "(", "true", ")", ";", "dlg", ".", "setMultiChoiceItems", "(", "strs", ",", "quoteFlags", ",", "new", "DialogInterface", ".", "OnMultiChoiceClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "which", ",", "boolean", "isChecked", ")", "{", "quoteFlags", "[", "which", "]", "=", "isChecked", ";", "}", "}", ")", ".", "setPositiveButton", "(", "\"OK\"", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "whichButton", ")", "{", "String", "text", "=", "\"\"", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "quoteFlags", ".", "length", ";", "++", "i", ")", "{", "if", "(", "quoteFlags", "[", "i", "]", ")", "{", "text", "+=", "strs", "[", "i", "]", "+", "\"n\"", ";", "}", "}", "{", "Intent", "intent", "=", "new", "Intent", "(", ")", ";", "intent", ".", "putExtra", "(", "\"baseURL\"", ",", "fthread", ".", "baseURL", ")", ";", "intent", ".", "putExtra", "(", "\"threadNum\"", ",", "fthread", ".", "threadNum", ")", ";", "intent", ".", "setClassName", "(", "fthread", ".", "getPackageName", "(", ")", ",", "getClass", "(", ")", ".", "getPackage", "(", ")", ".", "getName", "(", ")", "+", "\".Post\"", ")", ";", "intent", ".", "putExtra", "(", "\"postText\"", ",", "StringUtil", ".", "quote", "(", "text", ")", ")", ";", "try", "{", "fthread", ".", "startActivity", "(", "intent", ")", ";", "}", "catch", "(", "android", ".", "content", ".", "ActivityNotFoundException", "ex", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "}", "}", "}", "}", ")", ".", "setNegativeButton", "(", "\"Cancel\"", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "whichButton", ")", "{", "}", "}", ")", ".", "show", "(", ")", ";", "}", "}", "public", "void", "processShareDialog", "(", "View", "view", ")", "{", "chosen", "=", "0", ";", "TextView", "text", "=", "(", "TextView", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "maintext", ")", ";", "if", "(", "text", "!=", "null", ")", "{", "String", "[", "]", "addition", "=", "{", "}", ";", "final", "String", "strs_all", "=", "text", ".", "getText", "(", ")", ".", "toString", "(", ")", ";", "final", "String", "[", "]", "strs", "=", "StringUtil", ".", "nonBlankSplit", "(", "strs_all", ",", "addition", ")", ";", "final", "boolean", "[", "]", "quoteFlags", "=", "new", "boolean", "[", "strs", ".", "length", "]", ";", "AlertDialog", ".", "Builder", "dlg", ";", "dlg", "=", "new", "AlertDialog", ".", "Builder", "(", "fthread", ")", ";", "dlg", ".", "setTitle", "(", "\"\"", ")", ";", "dlg", ".", "setCancelable", "(", "true", ")", ";", "dlg", ".", "setMultiChoiceItems", "(", "strs", ",", "quoteFlags", ",", "new", "DialogInterface", ".", "OnMultiChoiceClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "which", ",", "boolean", "isChecked", ")", "{", "quoteFlags", "[", "which", "]", "=", "isChecked", ";", "}", "}", ")", ".", "setPositiveButton", "(", "\"OK\"", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "whichButton", ")", "{", "String", "text", "=", "\"\"", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "quoteFlags", ".", "length", ";", "++", "i", ")", "{", "if", "(", "quoteFlags", "[", "i", "]", ")", "{", "text", "+=", "strs", "[", "i", "]", "+", "\"n\"", ";", "}", "}", "{", "Intent", "intent", "=", "new", "Intent", "(", "Intent", ".", "ACTION_SEND", ")", ";", "intent", ".", "setType", "(", "\"text/plain\"", ")", ";", "intent", ".", "putExtra", "(", "Intent", ".", "EXTRA_TEXT", ",", "StringUtil", ".", "quote", "(", "text", ")", ")", ";", "try", "{", "fthread", ".", "startActivity", "(", "intent", ")", ";", "}", "catch", "(", "android", ".", "content", ".", "ActivityNotFoundException", "ex", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "}", "}", "}", "}", ")", ".", "setNegativeButton", "(", "\"Cancel\"", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "whichButton", ")", "{", "}", "}", ")", ".", "show", "(", ")", ";", "}", "}", "public", "void", "processDeleteDialog", "(", "View", "view", ")", "{", "AlertDialog", ".", "Builder", "dlg", ";", "dlg", "=", "new", "AlertDialog", ".", "Builder", "(", "fthread", ")", ";", "dlg", ".", "setTitle", "(", "\"\"", ")", ";", "EditText", "editText", "=", "new", "EditText", "(", "fthread", ")", ";", "editText", ".", "setInputType", "(", "InputType", ".", "TYPE_CLASS_NUMBER", ")", ";", "TextView", "bottomtext", "=", "(", "TextView", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "bottomtext", ")", ";", "String", "[", "]", "splits", "=", "bottomtext", ".", "getText", "(", ")", ".", "toString", "(", ")", ".", "split", "(", "\"No.\"", ")", ";", "final", "String", "resNum", "=", "splits", "[", "splits", ".", "length", "-", "1", "]", ";", "final", "EditText", "editText_f", "=", "editText", ";", "dlg", ".", "setView", "(", "editText", ")", ";", "dlg", ".", "setPositiveButton", "(", "\"OK\"", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "id", ")", "{", "FLog", ".", "d", "(", "\"\"", "+", "editText_f", ".", "getText", "(", ")", ")", ";", "deletePost", "(", "resNum", ",", "editText_f", ".", "getText", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "}", ")", ";", "dlg", ".", "setNegativeButton", "(", "\"-UNK-\"", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "id", ")", "{", "}", "}", ")", ";", "dlg", ".", "show", "(", ")", ";", "}", "public", "void", "deletePost", "(", "String", "resNum", ",", "String", "deletekey", ")", "{", "try", "{", "FLog", ".", "d", "(", "\"start", "post!\"", ")", ";", "DefaultHttpClient", "httpClient", ";", "httpClient", "=", "new", "DefaultHttpClient", "(", ")", ";", "FutabaCookieManager", ".", "loadCookie", "(", "httpClient", ")", ";", "httpClient", ".", "getParams", "(", ")", ".", "setParameter", "(", "ClientPNames", ".", "COOKIE_POLICY", ",", "CookiePolicy", ".", "BROWSER_COMPATIBILITY", ")", ";", "httpClient", ".", "getParams", "(", ")", ".", "setParameter", "(", "\"\"", ",", "5000", ")", ";", "httpClient", ".", "getParams", "(", ")", ".", "setParameter", "(", "\"\"", ",", "3000", ")", ";", "try", "{", "{", "List", "<", "Cookie", ">", "cookies", "=", "httpClient", ".", "getCookieStore", "(", ")", ".", "getCookies", "(", ")", ";", "if", "(", "cookies", ".", "isEmpty", "(", ")", ")", "{", "FLog", ".", "d", "(", "\"Cookie", "None\"", ")", ";", "}", "else", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "cookies", ".", "size", "(", ")", ";", "i", "++", ")", "{", "FLog", ".", "d", "(", "\"\"", "+", "cookies", ".", "get", "(", "i", ")", ".", "toString", "(", ")", ")", ";", "}", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "FLog", ".", "d", "(", "\"deletekey=\"", "+", "deletekey", ")", ";", "FLog", ".", "d", "(", "\"resNum=\"", "+", "resNum", ")", ";", "String", "urlStr", "=", "fthread", ".", "baseURL", "+", "\"futaba.php\"", ";", "HttpPost", "httppost", "=", "new", "HttpPost", "(", "urlStr", ")", ";", "List", "<", "NameValuePair", ">", "nameValuePair", "=", "new", "ArrayList", "<", "NameValuePair", ">", "(", "3", ")", ";", "nameValuePair", ".", "add", "(", "new", "BasicNameValuePair", "(", "\"mode\"", ",", "\"usrdel\"", ")", ")", ";", "nameValuePair", ".", "add", "(", "new", "BasicNameValuePair", "(", "resNum", ",", "\"delete\"", ")", ")", ";", "nameValuePair", ".", "add", "(", "new", "BasicNameValuePair", "(", "\"pwd\"", ",", "deletekey", ")", ")", ";", "httppost", ".", "setEntity", "(", "new", "UrlEncodedFormEntity", "(", "nameValuePair", ")", ")", ";", "httppost", ".", "addHeader", "(", "\"referer\"", ",", "fthread", ".", "threadURL", ")", ";", "HttpResponse", "response", "=", "httpClient", ".", "execute", "(", "httppost", ")", ";", "ByteArrayOutputStream", "byteArrayOutputStream", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "response", ".", "getEntity", "(", ")", ".", "writeTo", "(", "byteArrayOutputStream", ")", ";", "String", "retData", "=", "byteArrayOutputStream", ".", "toString", "(", "\"Shift-JIS\"", ")", ";", "FLog", ".", "v", "(", "\"data2=\"", "+", "retData", ")", ";", "FLog", ".", "d", "(", "\"\"", ")", ";", "DelpostParser", "parser", "=", "new", "DelpostParser", "(", ")", ";", "String", "contents", "=", "parser", ".", "parse", "(", "fthread", ",", "retData", ")", ";", "if", "(", "!", "contents", ".", "equals", "(", "\"\"", ")", ")", "{", "Toast", ".", "makeText", "(", "fthread", ",", "contents", ",", "Toast", ".", "LENGTH_LONG", ")", ".", "show", "(", ")", ";", "}", "else", "{", "Toast", ".", "makeText", "(", "fthread", ",", "\"-UNK-\"", ",", "Toast", ".", "LENGTH_LONG", ")", ".", "show", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "public", "void", "modifyShiori", "(", "View", "view", ")", "{", "FutabaStatus", "item", "=", "(", "FutabaStatus", ")", "fthread", ".", "adapter", ".", "items", ".", "get", "(", "currentPosition", ")", ";", "if", "(", "item", ".", "id", "==", "fthread", ".", "adapter", ".", "shioriPosition", ")", "{", "fthread", ".", "removeShiori", "(", "currentPosition", ")", ";", "}", "else", "{", "fthread", ".", "registerShiori", "(", "currentPosition", ")", ";", "}", "}", "}", "</s>" ]
8,247
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "android", ".", "app", ".", "Activity", ";", "import", "android", ".", "app", ".", "AlertDialog", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "DialogInterface", ";", "public", "class", "DirectorySelectDialog", "extends", "Activity", "implements", "DialogInterface", ".", "OnClickListener", "{", "private", "Context", "mContext", ";", "private", "ArrayList", "<", "File", ">", "mDirectoryList", ";", "private", "onDirectoryListDialogListener", "mListenner", ";", "public", "DirectorySelectDialog", "(", "Context", "context", ")", "{", "mContext", "=", "context", ";", "mDirectoryList", "=", "new", "ArrayList", "<", "File", ">", "(", ")", ";", "}", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "which", ")", "{", "if", "(", "(", "null", "!=", "mDirectoryList", ")", "&&", "(", "null", "!=", "mListenner", ")", ")", "{", "File", "file", "=", "mDirectoryList", ".", "get", "(", "which", ")", ";", "show", "(", "file", ".", "getAbsolutePath", "(", ")", ",", "file", ".", "getPath", "(", ")", ")", ";", "}", "}", "public", "void", "show", "(", "final", "String", "path", ",", "String", "title", ")", "{", "try", "{", "File", "[", "]", "mDirectories", "=", "new", "File", "(", "path", ")", ".", "listFiles", "(", ")", ";", "if", "(", "null", "==", "mDirectories", "&&", "null", "!=", "mListenner", ")", "{", "mListenner", ".", "onClickFileList", "(", "null", ")", ";", "}", "else", "{", "mDirectoryList", ".", "clear", "(", ")", ";", "ArrayList", "<", "String", ">", "viewList", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "File", "file", ":", "mDirectories", ")", "{", "if", "(", "file", ".", "isDirectory", "(", ")", ")", "{", "viewList", ".", "add", "(", "file", ".", "getName", "(", ")", "+", "\"/\"", ")", ";", "mDirectoryList", ".", "add", "(", "file", ")", ";", "}", "}", "AlertDialog", ".", "Builder", "alertDialogBuilder", "=", "new", "AlertDialog", ".", "Builder", "(", "mContext", ")", ";", "alertDialogBuilder", ".", "setTitle", "(", "title", ")", ";", "alertDialogBuilder", ".", "setItems", "(", "viewList", ".", "toArray", "(", "new", "String", "[", "0", "]", ")", ",", "this", ")", ";", "alertDialogBuilder", ".", "setPositiveButton", "(", "mContext", ".", "getString", "(", "R", ".", "string", ".", "ok", ")", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "which", ")", "{", "mListenner", ".", "onClickFileList", "(", "path", ")", ";", "}", "}", ")", ";", "alertDialogBuilder", ".", "setNegativeButton", "(", "mContext", ".", "getString", "(", "R", ".", "string", ".", "cancel", ")", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "which", ")", "{", "mListenner", ".", "onClickFileList", "(", "null", ")", ";", "}", "}", ")", ";", "alertDialogBuilder", ".", "show", "(", ")", ";", "}", "}", "catch", "(", "SecurityException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "public", "void", "setOnFileListDialogListener", "(", "onDirectoryListDialogListener", "listener", ")", "{", "mListenner", "=", "listener", ";", "}", "public", "interface", "onDirectoryListDialogListener", "{", "public", "void", "onClickFileList", "(", "String", "path", ")", ";", "}", "}", "</s>" ]
8,248
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ".", "R", ".", "id", ";", "import", "android", ".", "app", ".", "Activity", ";", "import", "android", ".", "content", ".", "ContentResolver", ";", "import", "android", ".", "content", ".", "ContentValues", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "graphics", ".", "Color", ";", "import", "android", ".", "media", ".", "MediaScannerConnection", ";", "import", "android", ".", "net", ".", "Uri", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "provider", ".", "MediaStore", ".", "Images", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "view", ".", "Menu", ";", "import", "android", ".", "view", ".", "MenuInflater", ";", "import", "android", ".", "view", ".", "MenuItem", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "view", ".", "ViewGroup", ";", "import", "android", ".", "view", ".", "Window", ";", "import", "android", ".", "view", ".", "WindowManager", ";", "import", "android", ".", "widget", ".", "ArrayAdapter", ";", "import", "android", ".", "widget", ".", "Button", ";", "import", "android", ".", "widget", ".", "Gallery", ";", "import", "android", ".", "widget", ".", "LinearLayout", ";", "import", "android", ".", "widget", ".", "ListView", ";", "import", "android", ".", "widget", ".", "TextView", ";", "import", "android", ".", "widget", ".", "Toast", ";", "public", "class", "ImageCatalog", "extends", "Activity", "{", "Toast", "toast", "=", "null", ";", "String", "myImageURL", "=", "null", ";", "ArrayList", "<", "String", ">", "imgURLs", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "ArrayList", "<", "String", ">", "thumbURLs", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "@", "Override", "public", "void", "onCreate", "(", "Bundle", "savedInstanceState", ")", "{", "super", ".", "onCreate", "(", "savedInstanceState", ")", ";", "if", "(", "getResources", "(", ")", ".", "getBoolean", "(", "R", ".", "bool", ".", "avoidsleep", ")", ")", "{", "Window", "window", "=", "getWindow", "(", ")", ";", "window", ".", "addFlags", "(", "WindowManager", ".", "LayoutParams", ".", "FLAG_KEEP_SCREEN_ON", ")", ";", "}", "try", "{", "setTitle", "(", "\"-UNK-", "-", "\"", "+", "getString", "(", "R", ".", "string", ".", "app_name", ")", ")", ";", "FLog", ".", "d", "(", "\"\"", ")", ";", "Intent", "intent", "=", "getIntent", "(", ")", ";", "FLog", ".", "d", "(", "\"hoge\"", ")", ";", "imgURLs", "=", "(", "ArrayList", "<", "String", ">", ")", "intent", ".", "getSerializableExtra", "(", "\"imgURLs\"", ")", ";", "thumbURLs", "=", "(", "ArrayList", "<", "String", ">", ")", "intent", ".", "getSerializableExtra", "(", "\"thumbURLs\"", ")", ";", "FLog", ".", "d", "(", "\"hoge-\"", "+", "imgURLs", ".", "size", "(", ")", ")", ";", "myImageURL", "=", "(", "String", ")", "intent", ".", "getSerializableExtra", "(", "\"myImgURL\"", ")", ";", "FLog", ".", "d", "(", "myImageURL", ")", ";", "CircleList", ".", "clear", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "imgURLs", ".", "size", "(", ")", ";", "i", "++", ")", "{", "String", "imgURL", "=", "imgURLs", ".", "get", "(", "i", ")", ";", "CircleList", ".", "add", "(", "imgURL", ")", ";", "if", "(", "imgURL", ".", "equals", "(", "myImageURL", ")", ")", "{", "CircleList", ".", "moveToLast", "(", ")", ";", "}", "}", "setContentView", "(", "R", ".", "layout", ".", "imagegallery", ")", ";", "Button", "download", "=", "(", "Button", ")", "findViewById", "(", "id", ".", "down_btn", ")", ";", "download", ".", "setOnClickListener", "(", "new", "View", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "View", "v", ")", "{", "try", "{", "String", "imgFile", "=", "CircleList", ".", "get", "(", ")", ";", "File", "file", "=", "new", "File", "(", "imgFile", ")", ";", "File", "saved_file", "=", "ImageCache", ".", "saveImage", "(", "imgFile", ")", ";", "if", "(", "saved_file", "!=", "null", ")", "{", "if", "(", "toast", "!=", "null", ")", "{", "toast", ".", "cancel", "(", ")", ";", "}", "toast", "=", "Toast", ".", "makeText", "(", "v", ".", "getContext", "(", ")", ",", "saved_file", ".", "getAbsolutePath", "(", ")", "+", "\"-UNK-\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ";", "toast", ".", "show", "(", ")", ";", "String", "mimeType", "=", "StringUtil", ".", "getMIMEType", "(", "saved_file", ".", "getName", "(", ")", ")", ";", "FLog", ".", "d", "(", "\"name=\"", "+", "saved_file", ".", "getName", "(", ")", ")", ";", "FLog", ".", "d", "(", "\"mime=\"", "+", "mimeType", ")", ";", "ContentResolver", "contentResolver", "=", "getContentResolver", "(", ")", ";", "ContentValues", "values", "=", "new", "ContentValues", "(", "7", ")", ";", "values", ".", "put", "(", "Images", ".", "Media", ".", "TITLE", ",", "saved_file", ".", "getName", "(", ")", ")", ";", "values", ".", "put", "(", "Images", ".", "Media", ".", "DISPLAY_NAME", ",", "saved_file", ".", "getName", "(", ")", ")", ";", "values", ".", "put", "(", "Images", ".", "Media", ".", "DATE_TAKEN", ",", "System", ".", "currentTimeMillis", "(", ")", ")", ";", "values", ".", "put", "(", "Images", ".", "Media", ".", "MIME_TYPE", ",", "mimeType", ")", ";", "values", ".", "put", "(", "Images", ".", "Media", ".", "ORIENTATION", ",", "0", ")", ";", "values", ".", "put", "(", "Images", ".", "Media", ".", "DATA", ",", "saved_file", ".", "getPath", "(", ")", ")", ";", "values", ".", "put", "(", "Images", ".", "Media", ".", "SIZE", ",", "saved_file", ".", "length", "(", ")", ")", ";", "contentResolver", ".", "insert", "(", "Images", ".", "Media", ".", "EXTERNAL_CONTENT_URI", ",", "values", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", ")", ";", "Button", "prev", "=", "(", "Button", ")", "findViewById", "(", "id", ".", "prev_btn", ")", ";", "prev", ".", "setOnClickListener", "(", "new", "View", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "View", "v", ")", "{", "try", "{", "ImageCatalogSingleView", "imageview", "=", "(", "ImageCatalogSingleView", ")", "findViewById", "(", "id", ".", "image", ")", ";", "imageview", ".", "clearImage", "(", ")", ";", "moveImage", "(", "-", "1", ")", ";", "imageview", ".", "setImage", "(", ")", ";", "setReturnImage", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", ")", ";", "Button", "next", "=", "(", "Button", ")", "findViewById", "(", "id", ".", "next_btn", ")", ";", "next", ".", "setOnClickListener", "(", "new", "View", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "View", "v", ")", "{", "try", "{", "ImageCatalogSingleView", "imageview", "=", "(", "ImageCatalogSingleView", ")", "findViewById", "(", "id", ".", "image", ")", ";", "imageview", ".", "clearImage", "(", ")", ";", "moveImage", "(", "+", "1", ")", ";", "imageview", ".", "setImage", "(", ")", ";", "setReturnImage", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", ")", ";", "Button", "rotate", "=", "(", "Button", ")", "findViewById", "(", "id", ".", "rotate_btn", ")", ";", "rotate", ".", "setOnClickListener", "(", "new", "View", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "View", "v", ")", "{", "try", "{", "ImageCatalogSingleView", "imageview", "=", "(", "ImageCatalogSingleView", ")", "findViewById", "(", "id", ".", "image", ")", ";", "imageview", ".", "rotateImage", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", ")", ";", "Button", "gridview", "=", "(", "Button", ")", "findViewById", "(", "id", ".", "gridview_btn", ")", ";", "gridview", ".", "setOnClickListener", "(", "new", "View", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "View", "v", ")", "{", "try", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "Intent", "intent", "=", "new", "Intent", "(", ")", ";", "intent", ".", "putExtra", "(", "\"position\"", ",", "CircleList", ".", "pos", "(", ")", ")", ";", "intent", ".", "putExtra", "(", "\"imgURLs\"", ",", "imgURLs", ")", ";", "intent", ".", "putExtra", "(", "\"thumbURLs\"", ",", "thumbURLs", ")", ";", "intent", ".", "setClassName", "(", "getPackageName", "(", ")", ",", "getClass", "(", ")", ".", "getPackage", "(", ")", ".", "getName", "(", ")", "+", "\".ThumbGrid\"", ")", ";", "startActivity", "(", "intent", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", ")", ";", "gridview", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "try", "{", "String", "className", "=", "getCallingActivity", "(", ")", ".", "getClassName", "(", ")", ";", "FLog", ".", "d", "(", "\"className=\"", "+", "className", ")", ";", "if", "(", "className", ".", "equals", "(", "\"\"", ")", ")", "{", "gridview", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "moveImage", "(", "0", ")", ";", "setReturnImage", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "public", "void", "moveImage", "(", "int", "num", ")", "{", "CircleList", ".", "move", "(", "num", ")", ";", "TextView", "imagenum", "=", "(", "TextView", ")", "findViewById", "(", "id", ".", "imagenum", ")", ";", "imagenum", ".", "setText", "(", "\"-UNK-:\"", "+", "(", "1", "+", "CircleList", ".", "pos", "(", ")", ")", "+", "\"/\"", "+", "CircleList", ".", "size", "(", ")", ")", ";", "}", "public", "void", "setReturnImage", "(", ")", "{", "Intent", "ret_i", "=", "new", "Intent", "(", ")", ";", "ret_i", ".", "putExtra", "(", "\"imgURL\"", ",", "CircleList", ".", "get", "(", ")", ")", ";", "setResult", "(", "RESULT_OK", ",", "ret_i", ")", ";", "}", "private", "LinearLayout", ".", "LayoutParams", "createParam", "(", "int", "w", ",", "int", "h", ")", "{", "return", "new", "LinearLayout", ".", "LayoutParams", "(", "w", ",", "h", ")", ";", "}", "@", "Override", "public", "void", "onDestroy", "(", ")", "{", "ImageCatalogSingleView", "imageview", "=", "(", "ImageCatalogSingleView", ")", "findViewById", "(", "id", ".", "image", ")", ";", "imageview", ".", "clearImage", "(", ")", ";", "FLog", ".", "d", "(", "\"\"", ")", ";", "super", ".", "onDestroy", "(", ")", ";", "}", "@", "Override", "public", "boolean", "onCreateOptionsMenu", "(", "Menu", "menu", ")", "{", "super", ".", "onCreateOptionsMenu", "(", "menu", ")", ";", "MenuInflater", "inflater", "=", "getMenuInflater", "(", ")", ";", "inflater", ".", "inflate", "(", "R", ".", "menu", ".", "menu_imagecatalog", ",", "menu", ")", ";", "return", "true", ";", "}", "@", "Override", "public", "boolean", "onOptionsItemSelected", "(", "MenuItem", "item", ")", "{", "Intent", "intent", ";", "switch", "(", "item", ".", "getItemId", "(", ")", ")", "{", "case", "R", ".", "id", ".", "share", ":", "intent", "=", "new", "Intent", "(", "Intent", ".", "ACTION_SEND", ")", ";", "intent", ".", "setType", "(", "\"text/plain\"", ")", ";", "intent", ".", "putExtra", "(", "Intent", ".", "EXTRA_TEXT", ",", "CircleList", ".", "get", "(", ")", ")", ";", "try", "{", "startActivityForResult", "(", "intent", ",", "0", ")", ";", "}", "catch", "(", "android", ".", "content", ".", "ActivityNotFoundException", "ex", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "\"\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "return", "true", ";", "case", "R", ".", "id", ".", "view", ":", "intent", "=", "new", "Intent", "(", "Intent", ".", "ACTION_VIEW", ",", "Uri", ".", "parse", "(", "CircleList", ".", "get", "(", ")", ")", ")", ";", "try", "{", "startActivityForResult", "(", "intent", ",", "0", ")", ";", "}", "catch", "(", "android", ".", "content", ".", "ActivityNotFoundException", "ex", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "\"\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "return", "true", ";", "case", "R", ".", "id", ".", "settings", ":", "intent", "=", "new", "Intent", "(", ")", ";", "intent", ".", "setClassName", "(", "getPackageName", "(", ")", ",", "getClass", "(", ")", ".", "getPackage", "(", ")", ".", "getName", "(", ")", "+", "\".PrefSetting\"", ")", ";", "startActivity", "(", "intent", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "about", ":", "Uri", "uri", "=", "Uri", ".", "parse", "(", "getString", "(", "R", ".", "string", ".", "helpurl", ")", ")", ";", "intent", "=", "new", "Intent", "(", "Intent", ".", "ACTION_VIEW", ",", "uri", ")", ";", "intent", ".", "setClassName", "(", "\"\"", ",", "\"\"", ")", ";", "try", "{", "startActivity", "(", "intent", ")", ";", "}", "catch", "(", "android", ".", "content", ".", "ActivityNotFoundException", "ex", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "\"-UNK-\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}", "}", "</s>" ]
8,249
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "android", ".", "graphics", ".", "Bitmap", ";", "import", "java", ".", "lang", ".", "Math", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "graphics", ".", "Matrix", ";", "public", "class", "ImageResizer", "{", "public", "static", "Bitmap", "ResizeWideToSquare", "(", "Bitmap", "bmp", ")", "{", "int", "width", "=", "bmp", ".", "getWidth", "(", ")", ";", "int", "height", "=", "bmp", ".", "getHeight", "(", ")", ";", "int", "size", "=", "Math", ".", "max", "(", "width", ",", "height", ")", ";", "int", "pixels", "[", "]", "=", "new", "int", "[", "width", "*", "height", "]", ";", "bmp", ".", "getPixels", "(", "pixels", ",", "0", ",", "width", ",", "0", ",", "0", ",", "width", ",", "height", ")", ";", "Bitmap", "ret", "=", "Bitmap", ".", "createBitmap", "(", "size", ",", "size", ",", "Bitmap", ".", "Config", ".", "ARGB_8888", ")", ";", "if", "(", "width", ">", "height", ")", "{", "ret", ".", "setPixels", "(", "pixels", ",", "0", ",", "width", ",", "0", ",", "(", "width", "-", "height", ")", "/", "2", ",", "width", ",", "height", ")", ";", "}", "else", "{", "ret", ".", "setPixels", "(", "pixels", ",", "0", ",", "width", ",", "(", "height", "-", "width", ")", "/", "2", ",", "0", ",", "width", ",", "height", ")", ";", "}", "return", "ret", ";", "}", "public", "static", "Bitmap", "ResizeCutToSquare", "(", "Bitmap", "bmp", ")", "{", "int", "width", "=", "bmp", ".", "getWidth", "(", ")", ";", "int", "height", "=", "bmp", ".", "getHeight", "(", ")", ";", "int", "size", "=", "Math", ".", "min", "(", "width", ",", "height", ")", ";", "int", "pixels", "[", "]", "=", "new", "int", "[", "size", "*", "size", "]", ";", "int", "stride", "=", "Math", ".", "max", "(", "width", ",", "height", ")", ";", "bmp", ".", "getPixels", "(", "pixels", ",", "0", ",", "size", ",", "Math", ".", "max", "(", "0", ",", "(", "width", "-", "height", ")", "/", "2", ")", ",", "Math", ".", "max", "(", "0", ",", "(", "height", "-", "width", ")", "/", "2", ")", ",", "size", ",", "size", ")", ";", "Bitmap", "ret", "=", "Bitmap", ".", "createBitmap", "(", "size", ",", "size", ",", "Bitmap", ".", "Config", ".", "ARGB_8888", ")", ";", "ret", ".", "setPixels", "(", "pixels", ",", "0", ",", "size", ",", "0", ",", "0", ",", "size", ",", "size", ")", ";", "return", "ret", ";", "}", "public", "static", "Bitmap", "ResizeCenter", "(", "Bitmap", "bmp", ",", "int", "size", ")", "{", "Bitmap", "temp", "=", "ResizeCutToSquare", "(", "bmp", ")", ";", "return", "Bitmap", ".", "createScaledBitmap", "(", "temp", ",", "size", ",", "size", ",", "true", ")", ";", "}", "}", "</s>" ]
8,250
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "android", ".", "app", ".", "Activity", ";", "import", "android", ".", "app", ".", "AlertDialog", ";", "import", "android", ".", "app", ".", "ListActivity", ";", "import", "android", ".", "net", ".", "Uri", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "view", ".", "Display", ";", "import", "android", ".", "view", ".", "KeyEvent", ";", "import", "android", ".", "view", ".", "Menu", ";", "import", "android", ".", "view", ".", "MenuInflater", ";", "import", "android", ".", "view", ".", "MenuItem", ";", "import", "android", ".", "view", ".", "Window", ";", "import", "android", ".", "view", ".", "WindowManager", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "DialogInterface", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "content", ".", "SharedPreferences", ";", "import", "android", ".", "webkit", ".", "CookieSyncManager", ";", "import", "android", ".", "widget", ".", "AdapterView", ";", "import", "android", ".", "widget", ".", "CheckBox", ";", "import", "android", ".", "widget", ".", "EditText", ";", "import", "android", ".", "widget", ".", "ImageButton", ";", "import", "android", ".", "widget", ".", "LinearLayout", ";", "import", "android", ".", "widget", ".", "ListView", ";", "import", "android", ".", "widget", ".", "TextView", ";", "import", "android", ".", "widget", ".", "Toast", ";", "import", "android", ".", "view", ".", "View", ".", "OnClickListener", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "view", ".", "inputmethod", ".", "InputMethodManager", ";", "import", "java", ".", "io", ".", "BufferedReader", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "InputStreamReader", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "TreeSet", ";", "import", "org", ".", "apache", ".", "http", ".", "HttpEntity", ";", "import", "org", ".", "apache", ".", "http", ".", "HttpResponse", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "HttpClient", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "methods", ".", "HttpGet", ";", "import", "org", ".", "apache", ".", "http", ".", "impl", ".", "client", ".", "DefaultHttpClient", ";", "import", "org", ".", "apache", ".", "http", ".", "params", ".", "HttpConnectionParams", ";", "import", "org", ".", "apache", ".", "http", ".", "params", ".", "HttpParams", ";", "import", "org", ".", "apache", ".", "http", ".", "protocol", ".", "BasicHttpContext", ";", "import", "org", ".", "apache", ".", "http", ".", "protocol", ".", "DefaultedHttpContext", ";", "import", "org", ".", "apache", ".", "http", ".", "protocol", ".", "HttpContext", ";", "import", "android", ".", "app", ".", "ProgressDialog", ";", "import", "java", ".", "lang", ".", "Thread", ";", "import", "java", ".", "net", ".", "UnknownHostException", ";", "import", "android", ".", "os", ".", "Handler", ";", "import", "android", ".", "os", ".", "Message", ";", "import", "android", ".", "preference", ".", "PreferenceManager", ";", "import", "android", ".", "widget", ".", "Button", ";", "import", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ".", "R", ".", "id", ";", "public", "class", "Catalog", "extends", "Activity", "implements", "OnClickListener", ",", "Runnable", "{", "private", "ArrayList", "<", "FutabaThreadContent", ">", "fthreads", "=", "new", "ArrayList", "<", "FutabaThreadContent", ">", "(", ")", ";", "private", "CatalogParser", "parser", ";", "private", "CatalogAdapter", "adapter", "=", "null", ";", "public", "String", "baseUrl", "=", "\"\"", ";", "private", "String", "catalogURL", ";", "private", "ProgressDialog", "waitDialog", ";", "private", "Thread", "thread", ";", "private", "int", "sortType", "=", "0", ";", "public", "String", "BBSName", "=", "\"\"", ";", "private", "ListView", "listView", ";", "public", "ArrayList", "<", "String", ">", "focusWords", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "public", "String", "mode", ";", "int", "position", "=", "0", ";", "boolean", "onCreateEnd", "=", "false", ";", "HistoryManager", "man", "=", "new", "HistoryManager", "(", ")", ";", "@", "Override", "public", "void", "onCreate", "(", "Bundle", "savedInstanceState", ")", "{", "super", ".", "onCreate", "(", "savedInstanceState", ")", ";", "FLog", ".", "d", "(", "\"\"", ")", ";", "CookieSyncManager", ".", "createInstance", "(", "this", ")", ";", "CookieSyncManager", ".", "getInstance", "(", ")", ".", "startSync", "(", ")", ";", "if", "(", "getResources", "(", ")", ".", "getBoolean", "(", "R", ".", "bool", ".", "avoidsleep", ")", ")", "{", "Window", "window", "=", "getWindow", "(", ")", ";", "window", ".", "addFlags", "(", "WindowManager", ".", "LayoutParams", ".", "FLAG_KEEP_SCREEN_ON", ")", ";", "}", "setWait", "(", ")", ";", "}", "@", "Override", "protected", "void", "onResume", "(", ")", "{", "super", ".", "onResume", "(", ")", ";", "CookieSyncManager", ".", "getInstance", "(", ")", ".", "stopSync", "(", ")", ";", "try", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "if", "(", "adapter", "!=", "null", ")", "{", "adapter", ".", "notifyDataSetChanged", "(", ")", ";", "}", "if", "(", "onCreateEnd", "&&", "mode", ".", "equals", "(", "\"history\"", ")", ")", "{", "if", "(", "adapter", "!=", "null", ")", "{", "setWait", "(", ")", ";", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "@", "Override", "protected", "void", "onPause", "(", ")", "{", "super", ".", "onPause", "(", ")", ";", "System", ".", "gc", "(", ")", ";", "CookieSyncManager", ".", "getInstance", "(", ")", ".", "sync", "(", ")", ";", "}", "public", "void", "setWait", "(", ")", "{", "if", "(", "waitDialog", "!=", "null", ")", "{", "waitDialog", ".", "dismiss", "(", ")", ";", "}", "waitDialog", "=", "new", "ProgressDialog", "(", "this", ")", ";", "waitDialog", ".", "setMessage", "(", "this", ".", "getString", "(", "R", ".", "string", ".", "loading", ")", ")", ";", "waitDialog", ".", "setProgressStyle", "(", "ProgressDialog", ".", "STYLE_SPINNER", ")", ";", "waitDialog", ".", "show", "(", ")", ";", "try", "{", "sortType", "=", "StateMan", ".", "getSortParam", "(", "this", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "thread", "=", "new", "Thread", "(", "this", ")", ";", "thread", ".", "start", "(", ")", ";", "}", "public", "void", "run", "(", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "100", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "handler", ".", "sendEmptyMessage", "(", "0", ")", ";", "}", "private", "Handler", "handler", "=", "new", "Handler", "(", ")", "{", "public", "void", "handleMessage", "(", "Message", "msg", ")", "{", "try", "{", "loading", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", ";", "final", "Handler", "handler2", "=", "new", "Handler", "(", ")", ";", "private", "void", "loading", "(", ")", "{", "Intent", "intent", "=", "getIntent", "(", ")", ";", "baseUrl", "=", "(", "String", ")", "intent", ".", "getSerializableExtra", "(", "\"baseUrl\"", ")", ";", "BBSName", "=", "(", "String", ")", "intent", ".", "getSerializableExtra", "(", "\"BBSName\"", ")", ";", "mode", "=", "(", "String", ")", "intent", ".", "getSerializableExtra", "(", "\"mode\"", ")", ";", "catalogURL", "=", "baseUrl", "+", "\"futaba.php\"", ";", "setContentView", "(", "R", ".", "layout", ".", "futaba_catalog", ")", ";", "listView", "=", "(", "ListView", ")", "findViewById", "(", "id", ".", "cataloglistview", ")", ";", "try", "{", "SharedPreferences", "preferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "this", ")", ";", "boolean", "fastScrollEnabled", "=", "preferences", ".", "getBoolean", "(", "\"\"", ",", "false", ")", ";", "listView", ".", "setFastScrollEnabled", "(", "fastScrollEnabled", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "adapter", "=", "new", "CatalogAdapter", "(", "this", ",", "R", ".", "layout", ".", "futaba_catalog_row", ",", "(", "ArrayList", "<", "FutabaThreadContent", ">", ")", "fthreads", ".", "clone", "(", ")", ")", ";", "if", "(", "!", "mode", ".", "equals", "(", "\"history\"", ")", ")", "{", "Button", "historyDeleteButton", "=", "(", "Button", ")", "findViewById", "(", "id", ".", "delete_btn", ")", ";", "historyDeleteButton", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "}", "else", "{", "Button", "reloadButton", "=", "(", "Button", ")", "findViewById", "(", "id", ".", "reload_btn", ")", ";", "reloadButton", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "Button", "historyButton", "=", "(", "Button", ")", "findViewById", "(", "id", ".", "history_btn", ")", ";", "historyButton", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "Button", "sortTypeButton", "=", "(", "Button", ")", "findViewById", "(", "id", ".", "sorttype_btn", ")", ";", "sortTypeButton", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "}", "EditText", "searchWord", "=", "(", "EditText", ")", "findViewById", "(", "R", ".", "id", ".", "searchinput", ")", ";", "searchWord", ".", "setOnKeyListener", "(", "new", "View", ".", "OnKeyListener", "(", ")", "{", "public", "boolean", "onKey", "(", "View", "v", ",", "int", "keyCode", ",", "KeyEvent", "event", ")", "{", "FLog", ".", "d", "(", "\"onKey\"", "+", "event", ")", ";", "if", "(", "event", ".", "getAction", "(", ")", "==", "KeyEvent", ".", "ACTION_DOWN", "&&", "keyCode", "==", "KeyEvent", ".", "KEYCODE_ENTER", ")", "{", "return", "true", ";", "}", "if", "(", "event", ".", "getAction", "(", ")", "==", "KeyEvent", ".", "ACTION_UP", "&&", "keyCode", "==", "KeyEvent", ".", "KEYCODE_ENTER", ")", "{", "EditText", "word", "=", "(", "EditText", ")", "findViewById", "(", "R", ".", "id", ".", "searchinput", ")", ";", "Catalog", "activity", "=", "(", "Catalog", ")", "v", ".", "getContext", "(", ")", ";", "activity", ".", "onClickSearchButton", "(", "v", ")", ";", "return", "false", ";", "}", "return", "false", ";", "}", "}", ")", ";", "Button", "btn", "=", "new", "Button", "(", "this", ")", ";", "btn", ".", "setText", "(", "\"hoge", "uga\"", ")", ";", "btn", ".", "setVisibility", "(", "View", ".", "INVISIBLE", ")", ";", "listView", ".", "setAdapter", "(", "adapter", ")", ";", "LinearLayout", "searchBar", "=", "(", "LinearLayout", ")", "findViewById", "(", "id", ".", "search_bar", ")", ";", "searchBar", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "new", "Thread", "(", "new", "FutabaCatalogContentGetter", "(", ")", ")", ".", "start", "(", ")", ";", "}", "private", "LinearLayout", ".", "LayoutParams", "createParam", "(", "int", "w", ",", "int", "h", ")", "{", "return", "new", "LinearLayout", ".", "LayoutParams", "(", "w", ",", "h", ")", ";", "}", "private", "class", "FutabaCatalogContentGetter", "extends", "Thread", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "try", "{", "fthreads", "=", "new", "ArrayList", "<", "FutabaThreadContent", ">", "(", ")", ";", "parser", "=", "new", "CatalogParser", "(", ")", ";", "String", "title_text", "=", "\"\"", ";", "String", "toast_text", "=", "\"\"", ";", "if", "(", "!", "mode", ".", "equals", "(", "\"history\"", ")", ")", "{", "String", "catalogHtml", "=", "\"\"", ";", "Boolean", "network_ok", "=", "true", ";", "Boolean", "cache_ok", "=", "true", ";", "try", "{", "catalogHtml", "=", "CatalogHtmlReader", ".", "Read", "(", "catalogURL", ",", "adapter", ".", "getContext", "(", ")", ",", "sortType", ")", ";", "network_ok", "=", "true", ";", "}", "catch", "(", "UnknownHostException", "e", ")", "{", "FLog", ".", "d", "(", "\"hoge\"", ")", ";", "network_ok", "=", "false", ";", "if", "(", "SDCard", ".", "cacheExist", "(", "FutabaCrypt", ".", "createDigest", "(", "catalogURL", ")", ")", ")", "{", "FLog", ".", "d", "(", "\"\"", "+", "FutabaCrypt", ".", "createDigest", "(", "catalogURL", ")", ")", ";", "catalogHtml", "=", "SDCard", ".", "loadTextCache", "(", "FutabaCrypt", ".", "createDigest", "(", "catalogURL", ")", ")", ";", "}", "else", "{", "FLog", ".", "d", "(", "\"cache", "\"", "+", "FutabaCrypt", ".", "createDigest", "(", "catalogURL", ")", "+", "\"not", "found\"", ")", ";", "cache_ok", "=", "false", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "network_ok", "=", "false", ";", "if", "(", "SDCard", ".", "cacheExist", "(", "FutabaCrypt", ".", "createDigest", "(", "catalogURL", ")", ")", ")", "{", "FLog", ".", "d", "(", "\"\"", "+", "FutabaCrypt", ".", "createDigest", "(", "catalogURL", ")", ")", ";", "catalogHtml", "=", "SDCard", ".", "loadTextCache", "(", "FutabaCrypt", ".", "createDigest", "(", "catalogURL", ")", ")", ";", "}", "else", "{", "FLog", ".", "d", "(", "\"cache", "\"", "+", "FutabaCrypt", ".", "createDigest", "(", "catalogURL", ")", "+", "\"not", "found\"", ")", ";", "cache_ok", "=", "false", ";", "}", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "if", "(", "!", "network_ok", ")", "{", "if", "(", "cache_ok", ")", "{", "toast_text", "=", "\"\"", ";", "}", "else", "{", "toast_text", "=", "\"\"", ";", "}", "}", "if", "(", "network_ok", "||", "cache_ok", ")", "{", "FLog", ".", "d", "(", "\"network=\"", "+", "network_ok", "+", "\"", "cache=\"", "+", "cache_ok", "+", "\"", "length=\"", "+", "catalogHtml", ".", "length", "(", ")", ")", ";", "if", "(", "catalogHtml", ".", "length", "(", ")", ">", "50", ")", "{", "parser", ".", "parse", "(", "catalogHtml", ")", ";", "fthreads", "=", "parser", ".", "getThreads", "(", ")", ";", "}", "else", "{", "toast_text", "=", "\"\"", ";", "}", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "fthreads", ".", "size", "(", ")", ";", "++", "i", ")", "{", "fthreads", ".", "get", "(", "i", ")", ".", "BBSName", "=", "BBSName", ";", "}", "man", ".", "Load", "(", ")", ";", "title_text", "=", "BBSName", "+", "\"(-UNK-)", "-", "\"", "+", "getString", "(", "R", ".", "string", ".", "app_name", ")", ";", "}", "else", "{", "man", ".", "Load", "(", ")", ";", "fthreads", "=", "man", ".", "getThreadsArray", "(", ")", ";", "title_text", "=", "\"-UNK-", "-", "\"", "+", "getString", "(", "R", ".", "string", ".", "app_name", ")", ";", "}", "focusWords", "=", "FocusedSettings", ".", "get", "(", "adapter", ".", "getContext", "(", ")", ")", ";", "adapter", ".", "items", ".", "clear", "(", ")", ";", "if", "(", "!", "mode", ".", "equals", "(", "\"history\"", ")", "&&", "focusWords", ".", "size", "(", ")", ">", "0", ")", "{", "adapter", ".", "items", ".", "add", "(", "FutabaThreadContent", ".", "createMenu1", "(", ")", ")", ";", "Iterator", "<", "FutabaThreadContent", ">", "iterator", "=", "fthreads", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "FutabaThreadContent", "athread", "=", "iterator", ".", "next", "(", ")", ";", "if", "(", "StringUtil", ".", "focusWordMatched", "(", "athread", ".", "text", ",", "focusWords", ")", ")", "{", "adapter", ".", "items", ".", "add", "(", "athread", ")", ";", "}", "}", "adapter", ".", "items", ".", "add", "(", "FutabaThreadContent", ".", "createMenu2", "(", ")", ")", ";", "iterator", "=", "fthreads", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "FutabaThreadContent", "athread", "=", "iterator", ".", "next", "(", ")", ";", "if", "(", "!", "StringUtil", ".", "focusWordMatched", "(", "athread", ".", "text", ",", "focusWords", ")", ")", "{", "adapter", ".", "items", ".", "add", "(", "athread", ")", ";", "}", "}", "}", "else", "{", "Iterator", "<", "FutabaThreadContent", ">", "iterator", "=", "fthreads", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "FutabaThreadContent", "athread", "=", "iterator", ".", "next", "(", ")", ";", "adapter", ".", "items", ".", "add", "(", "athread", ")", ";", "}", "}", "final", "String", "title_text_f", "=", "title_text", ";", "final", "String", "toast_text_f", "=", "toast_text", ";", "handler2", ".", "post", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "if", "(", "!", "toast_text_f", ".", "equals", "(", "\"\"", ")", ")", "{", "Toast", ".", "makeText", "(", "adapter", ".", "getContext", "(", ")", ",", "toast_text_f", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "setTitle", "(", "title_text_f", ")", ";", "waitDialog", ".", "dismiss", "(", ")", ";", "adapter", ".", "notifyDataSetChanged", "(", ")", ";", "listView", ".", "invalidateViews", "(", ")", ";", "}", "}", ")", ";", "onCreateEnd", "=", "true", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "i", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", "public", "void", "onClickReloadBtn", "(", "View", "v", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "ListView", "listView", "=", "(", "ListView", ")", "findViewById", "(", "id", ".", "cataloglistview", ")", ";", "position", "=", "listView", ".", "getFirstVisiblePosition", "(", ")", ";", "setWait", "(", ")", ";", "}", "public", "void", "onClickHistoryBtn", "(", "View", "v", ")", "{", "Intent", "intent", "=", "new", "Intent", "(", ")", ";", "intent", ".", "putExtra", "(", "\"baseUrl\"", ",", "baseUrl", ")", ";", "intent", ".", "putExtra", "(", "\"BBSName\"", ",", "BBSName", ")", ";", "intent", ".", "putExtra", "(", "\"mode\"", ",", "\"history\"", ")", ";", "intent", ".", "setClassName", "(", "getPackageName", "(", ")", ",", "getClass", "(", ")", ".", "getPackage", "(", ")", ".", "getName", "(", ")", "+", "\".Catalog\"", ")", ";", "startActivity", "(", "intent", ")", ";", "}", "private", "int", "delete_option", "=", "0", ";", "final", "int", "DELETE_CHECKED", "=", "0", ";", "final", "int", "DELETE_NONCHECKED", "=", "1", ";", "final", "int", "DELETE_ALL", "=", "2", ";", "public", "void", "onClickDeleteBtn", "(", "View", "v", ")", "{", "if", "(", "adapter", ".", "items", ".", "size", "(", ")", "!=", "fthreads", ".", "size", "(", ")", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "\"\"", ",", "Toast", ".", "LENGTH_LONG", ")", ".", "show", "(", ")", ";", "return", ";", "}", "delete_option", "=", "0", ";", "final", "CharSequence", "[", "]", "items", "=", "{", "\"-UNK-\"", ",", "\"-UNK-\"", ",", "\"-UNK-\"", "}", ";", "AlertDialog", ".", "Builder", "dlg", ";", "dlg", "=", "new", "AlertDialog", ".", "Builder", "(", "Catalog", ".", "this", ")", ";", "dlg", ".", "setTitle", "(", "\"-UNK-\"", ")", ";", "dlg", ".", "setCancelable", "(", "true", ")", ";", "dlg", ".", "setSingleChoiceItems", "(", "items", ",", "0", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "item", ")", "{", "Catalog", ".", "this", ".", "delete_option", "=", "item", ";", "}", "}", ")", ";", "dlg", ".", "setPositiveButton", "(", "\"-UNK-\"", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "id", ")", "{", "Catalog", ".", "this", ".", "deleteThreads", "(", ")", ";", "}", "}", ")", ";", "dlg", ".", "setNegativeButton", "(", "\"-UNK-\"", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "id", ")", "{", "}", "}", ")", ";", "dlg", ".", "show", "(", ")", ";", "}", "public", "void", "deleteThreads", "(", ")", "{", "try", "{", "ListView", "listView", "=", "(", "ListView", ")", "findViewById", "(", "id", ".", "cataloglistview", ")", ";", "if", "(", "delete_option", "==", "DELETE_ALL", ")", "{", "adapter", ".", "items", ".", "clear", "(", ")", ";", "}", "else", "{", "if", "(", "delete_option", "==", "DELETE_CHECKED", ")", "{", "for", "(", "int", "i", "=", "adapter", ".", "items", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "--", "i", ")", "{", "if", "(", "adapter", ".", "items", ".", "get", "(", "i", ")", ".", "isChecked", ")", "{", "adapter", ".", "items", ".", "remove", "(", "i", ")", ";", "}", "else", "{", "adapter", ".", "items", ".", "get", "(", "i", ")", ".", "isChecked", "=", "false", ";", "}", "}", "}", "else", "{", "for", "(", "int", "i", "=", "adapter", ".", "items", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "--", "i", ")", "{", "if", "(", "!", "adapter", ".", "items", ".", "get", "(", "i", ")", ".", "isChecked", ")", "{", "adapter", ".", "items", ".", "remove", "(", "i", ")", ";", "}", "else", "{", "adapter", ".", "items", ".", "get", "(", "i", ")", ".", "isChecked", "=", "false", ";", "}", "}", "}", "}", "HistoryManager", "man", "=", "new", "HistoryManager", "(", ")", ";", "man", ".", "set", "(", "adapter", ".", "items", ")", ";", "man", ".", "Save", "(", ")", ";", "fthreads", "=", "(", "ArrayList", "<", "FutabaThreadContent", ">", ")", "adapter", ".", "items", ".", "clone", "(", ")", ";", "adapter", ".", "notifyDataSetChanged", "(", ")", ";", "listView", ".", "invalidateViews", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "i", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "public", "void", "onClick", "(", "View", "v", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "void", "onDestroy", "(", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "System", ".", "gc", "(", ")", ";", "super", ".", "onDestroy", "(", ")", ";", "}", "@", "Override", "public", "boolean", "onCreateOptionsMenu", "(", "Menu", "menu", ")", "{", "super", ".", "onCreateOptionsMenu", "(", "menu", ")", ";", "MenuInflater", "inflater", "=", "getMenuInflater", "(", ")", ";", "inflater", ".", "inflate", "(", "R", ".", "menu", ".", "menu_catalog", ",", "menu", ")", ";", "return", "true", ";", "}", "public", "void", "onClickPostBtn", "(", "View", "v", ")", "{", "Intent", "intent", "=", "new", "Intent", "(", ")", ";", "intent", ".", "putExtra", "(", "\"baseURL\"", ",", "baseUrl", ")", ";", "intent", ".", "putExtra", "(", "\"threadNum\"", ",", "0", ")", ";", "intent", ".", "setClassName", "(", "getPackageName", "(", ")", ",", "getClass", "(", ")", ".", "getPackage", "(", ")", ".", "getName", "(", ")", "+", "\".Post\"", ")", ";", "startActivity", "(", "intent", ")", ";", "}", "public", "void", "onClickSortTypeBtn", "(", "View", "v", ")", "{", "final", "String", "[", "]", "strs", "=", "{", "\"-UNK-\"", ",", "\"-UNK-\"", ",", "\"-UNK-\"", ",", "\"-UNK-\"", ",", "\"-UNK-\"", "}", ";", "AlertDialog", ".", "Builder", "dlg", ";", "final", "Catalog", "catalog", "=", "this", ";", "dlg", "=", "new", "AlertDialog", ".", "Builder", "(", "this", ")", ";", "dlg", ".", "setTitle", "(", "\"-UNK-\"", ")", ";", "dlg", ".", "setCancelable", "(", "true", ")", ";", "dlg", ".", "setSingleChoiceItems", "(", "strs", ",", "sortType", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "item", ")", "{", "sortType", "=", "item", ";", "}", "}", ")", ";", "dlg", ".", "setPositiveButton", "(", "\"OK\"", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "id", ")", "{", "FLog", ".", "d", "(", "\"sortType=\"", "+", "sortType", ")", ";", "if", "(", "sortType", ">=", "0", "&&", "sortType", "<", "strs", ".", "length", ")", "{", "StateMan", ".", "setSortParam", "(", "catalog", ",", "sortType", ")", ";", "catalog", ".", "onClickReloadBtn", "(", "null", ")", ";", "}", "}", "}", ")", ";", "dlg", ".", "setNegativeButton", "(", "\"-UNK-\"", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "id", ")", "{", "}", "}", ")", ";", "dlg", ".", "show", "(", ")", ";", "}", "@", "Override", "public", "boolean", "onOptionsItemSelected", "(", "MenuItem", "item", ")", "{", "Intent", "intent", ";", "switch", "(", "item", ".", "getItemId", "(", ")", ")", "{", "case", "R", ".", "id", ".", "post", ":", "onClickPostBtn", "(", "null", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "share", ":", "intent", "=", "new", "Intent", "(", "Intent", ".", "ACTION_SEND", ")", ";", "intent", ".", "setType", "(", "\"text/plain\"", ")", ";", "intent", ".", "putExtra", "(", "Intent", ".", "EXTRA_TEXT", ",", "baseUrl", ")", ";", "try", "{", "startActivityForResult", "(", "intent", ",", "0", ")", ";", "}", "catch", "(", "android", ".", "content", ".", "ActivityNotFoundException", "ex", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "\"\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "return", "true", ";", "case", "R", ".", "id", ".", "search", ":", "LinearLayout", "searchBar", "=", "(", "LinearLayout", ")", "findViewById", "(", "id", ".", "search_bar", ")", ";", "if", "(", "searchBar", ".", "getVisibility", "(", ")", "==", "View", ".", "GONE", ")", "{", "searchBar", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "}", "else", "{", "searchBar", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "}", "return", "true", ";", "case", "R", ".", "id", ".", "settings", ":", "intent", "=", "new", "Intent", "(", ")", ";", "intent", ".", "setClassName", "(", "getPackageName", "(", ")", ",", "getClass", "(", ")", ".", "getPackage", "(", ")", ".", "getName", "(", ")", "+", "\".PrefSetting\"", ")", ";", "startActivity", "(", "intent", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "about", ":", "Uri", "uri", "=", "Uri", ".", "parse", "(", "getString", "(", "R", ".", "string", ".", "helpurl", ")", ")", ";", "intent", "=", "new", "Intent", "(", "Intent", ".", "ACTION_VIEW", ",", "uri", ")", ";", "intent", ".", "setClassName", "(", "\"\"", ",", "\"\"", ")", ";", "try", "{", "startActivity", "(", "intent", ")", ";", "}", "catch", "(", "android", ".", "content", ".", "ActivityNotFoundException", "ex", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "\"-UNK-\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "return", "true", ";", "case", "R", ".", "id", ".", "focusword", ":", "intent", "=", "new", "Intent", "(", ")", ";", "intent", ".", "setClassName", "(", "getPackageName", "(", ")", ",", "getClass", "(", ")", ".", "getPackage", "(", ")", ".", "getName", "(", ")", "+", "\".FocusEdit\"", ")", ";", "startActivity", "(", "intent", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}", "public", "void", "onClickSearchButton", "(", "View", "v", ")", "{", "FLog", ".", "d", "(", "\"\"", "+", "fthreads", ".", "size", "(", ")", ")", ";", "if", "(", "true", ")", "{", "EditText", "searchEdit", "=", "(", "EditText", ")", "findViewById", "(", "id", ".", "searchinput", ")", ";", "String", "searchText", "=", "searchEdit", ".", "getText", "(", ")", ".", "toString", "(", ")", ";", "String", "[", "]", "query", "=", "StringUtil", ".", "queryNormalize", "(", "searchText", ")", ";", "adapter", ".", "items", ".", "clear", "(", ")", ";", "try", "{", "ArrayList", "<", "String", ">", "focusWords", "=", "FocusedSettings", ".", "get", "(", "this", ")", ";", "adapter", ".", "items", ".", "clear", "(", ")", ";", "if", "(", "!", "mode", ".", "equals", "(", "\"history\"", ")", "&&", "focusWords", ".", "size", "(", ")", ">", "0", ")", "{", "adapter", ".", "items", ".", "add", "(", "FutabaThreadContent", ".", "createMenu1", "(", ")", ")", ";", "Iterator", "<", "FutabaThreadContent", ">", "iterator", "=", "fthreads", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "FutabaThreadContent", "athread", "=", "iterator", ".", "next", "(", ")", ";", "if", "(", "StringUtil", ".", "isQueryMatch", "(", "athread", ".", "text", ",", "query", ")", "&&", "StringUtil", ".", "focusWordMatched", "(", "athread", ".", "text", ",", "focusWords", ")", ")", "{", "adapter", ".", "items", ".", "add", "(", "athread", ")", ";", "}", "}", "adapter", ".", "items", ".", "add", "(", "FutabaThreadContent", ".", "createMenu2", "(", ")", ")", ";", "iterator", "=", "fthreads", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "FutabaThreadContent", "athread", "=", "iterator", ".", "next", "(", ")", ";", "if", "(", "StringUtil", ".", "isQueryMatch", "(", "athread", ".", "text", ",", "query", ")", "&&", "!", "StringUtil", ".", "focusWordMatched", "(", "athread", ".", "text", ",", "focusWords", ")", ")", "{", "adapter", ".", "items", ".", "add", "(", "athread", ")", ";", "}", "}", "}", "else", "{", "Iterator", "<", "FutabaThreadContent", ">", "iterator", "=", "fthreads", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "FutabaThreadContent", "athread", "=", "iterator", ".", "next", "(", ")", ";", "if", "(", "StringUtil", ".", "isQueryMatch", "(", "athread", ".", "text", ",", "query", ")", ")", "{", "adapter", ".", "items", ".", "add", "(", "athread", ")", ";", "}", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "int", "itemnum", "=", "adapter", ".", "items", ".", "size", "(", ")", ";", "if", "(", "!", "mode", ".", "equals", "(", "\"history\"", ")", "&&", "focusWords", ".", "size", "(", ")", ">", "0", ")", "{", "itemnum", "-=", "2", ";", "}", "adapter", ".", "notifyDataSetChanged", "(", ")", ";", "LinearLayout", "searchBar", "=", "(", "LinearLayout", ")", "findViewById", "(", "id", ".", "search_bar", ")", ";", "String", "toastText", "=", "\"-UNK-\"", "+", "fthreads", ".", "size", "(", ")", "+", "\"-UNK-\"", "+", "itemnum", "+", "\"-UNK-\"", ";", "if", "(", "fthreads", ".", "size", "(", ")", "==", "itemnum", ")", "{", "toastText", "=", "\"\"", ";", "}", "else", "if", "(", "itemnum", "==", "0", ")", "{", "toastText", "=", "\"\"", ";", "}", "Toast", ".", "makeText", "(", "this", ",", "toastText", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "InputMethodManager", "imm", "=", "(", "InputMethodManager", ")", "getSystemService", "(", "INPUT_METHOD_SERVICE", ")", ";", "imm", ".", "hideSoftInputFromWindow", "(", "v", ".", "getWindowToken", "(", ")", ",", "0", ")", ";", "}", "}", "public", "void", "onClickSearchHideButton", "(", "View", "v", ")", "{", "LinearLayout", "searchBar", "=", "(", "LinearLayout", ")", "findViewById", "(", "id", ".", "search_bar", ")", ";", "searchBar", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "InputMethodManager", "imm", "=", "(", "InputMethodManager", ")", "getSystemService", "(", "INPUT_METHOD_SERVICE", ")", ";", "imm", ".", "hideSoftInputFromWindow", "(", "v", ".", "getWindowToken", "(", ")", ",", "0", ")", ";", "}", "public", "boolean", "onSearchRequested", "(", ")", "{", "LinearLayout", "searchBar", "=", "(", "LinearLayout", ")", "findViewById", "(", "id", ".", "search_bar", ")", ";", "if", "(", "searchBar", ".", "getVisibility", "(", ")", "==", "View", ".", "GONE", ")", "{", "searchBar", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "}", "else", "{", "searchBar", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "InputMethodManager", "imm", "=", "(", "InputMethodManager", ")", "getSystemService", "(", "INPUT_METHOD_SERVICE", ")", ";", "imm", ".", "hideSoftInputFromWindow", "(", "getCurrentFocus", "(", ")", ".", "getWindowToken", "(", ")", ",", "0", ")", ";", "}", "return", "false", ";", "}", "public", "boolean", "dispatchKeyEvent", "(", "KeyEvent", "event", ")", "{", "FLog", ".", "d", "(", "\"\"", "+", "event", ".", "getAction", "(", ")", ")", ";", "int", "action", "=", "event", ".", "getAction", "(", ")", ";", "int", "keyCode", "=", "event", ".", "getKeyCode", "(", ")", ";", "if", "(", "keyCode", "==", "KeyEvent", ".", "KEYCODE_VOLUME_DOWN", ")", "{", "if", "(", "action", "==", "KeyEvent", ".", "ACTION_UP", ")", "{", "FLog", ".", "d", "(", "\"vdown\"", "+", "listView", ".", "getFirstVisiblePosition", "(", ")", ")", ";", "int", "topPositionY", "=", "listView", ".", "getChildAt", "(", "0", ")", ".", "getTop", "(", ")", ";", "WindowManager", "wm", "=", "(", "WindowManager", ")", "getSystemService", "(", "Context", ".", "WINDOW_SERVICE", ")", ";", "Display", "disp", "=", "wm", ".", "getDefaultDisplay", "(", ")", ";", "int", "height", "=", "disp", ".", "getHeight", "(", ")", ";", "listView", ".", "setSelectionFromTop", "(", "listView", ".", "getFirstVisiblePosition", "(", ")", ",", "topPositionY", "-", "(", "height", "-", "200", ")", ")", ";", "}", "return", "true", ";", "}", "else", "if", "(", "keyCode", "==", "KeyEvent", ".", "KEYCODE_VOLUME_UP", ")", "{", "if", "(", "action", "==", "KeyEvent", ".", "ACTION_UP", ")", "{", "int", "topPositionY", "=", "listView", ".", "getChildAt", "(", "0", ")", ".", "getTop", "(", ")", ";", "WindowManager", "wm", "=", "(", "WindowManager", ")", "getSystemService", "(", "Context", ".", "WINDOW_SERVICE", ")", ";", "Display", "disp", "=", "wm", ".", "getDefaultDisplay", "(", ")", ";", "int", "height", "=", "disp", ".", "getHeight", "(", ")", ";", "listView", ".", "setSelectionFromTop", "(", "listView", ".", "getFirstVisiblePosition", "(", ")", ",", "topPositionY", "+", "(", "height", "-", "200", ")", ")", ";", "}", "return", "true", ";", "}", "return", "super", ".", "dispatchKeyEvent", "(", "event", ")", ";", "}", "@", "Override", "public", "void", "onStop", "(", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "super", ".", "onStop", "(", ")", ";", "System", ".", "gc", "(", ")", ";", "}", "}", "</s>" ]
8,251
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "io", ".", "Serializable", ";", "import", "android", ".", "util", ".", "Log", ";", "public", "class", "FutabaBBSContent", "implements", "Serializable", "{", "private", "static", "final", "long", "serialVersionUID", "=", "1L", ";", "public", "String", "url", ";", "public", "String", "name", ";", "public", "boolean", "faved", ";", "public", "FutabaBBSContent", "(", ")", "{", "}", "public", "FutabaBBSContent", "(", "String", "s", ")", "{", "String", "[", "]", "elems", "=", "s", ".", "split", "(", "\":::\"", ")", ";", "url", "=", "elems", "[", "0", "]", ";", "name", "=", "elems", "[", "1", "]", ";", "faved", "=", "false", ";", "}", "public", "String", "toString", "(", ")", "{", "return", "url", "+", "\":::\"", "+", "name", ";", "}", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "FutabaBBSContent", "rhs", "=", "(", "FutabaBBSContent", ")", "obj", ";", "return", "(", "url", ".", "equals", "(", "rhs", ".", "url", ")", ")", "&&", "(", "name", ".", "equals", "(", "rhs", ".", "name", ")", ")", ";", "}", "}", "</s>" ]
8,252
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "SharedPreferences", ";", "import", "android", ".", "content", ".", "SharedPreferences", ".", "Editor", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "preference", ".", "PreferenceActivity", ";", "import", "android", ".", "preference", ".", "PreferenceManager", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "android", ".", "util", ".", "Log", ";", "public", "class", "FavoriteSettings", "{", "private", "static", "final", "String", "OPT_FAVORITES", "=", "\"favorites\"", ";", "public", "static", "ArrayList", "<", "FutabaBBSContent", ">", "getFavorites", "(", "Context", "context", ")", "throws", "IOException", "{", "ArrayList", "<", "FutabaBBSContent", ">", "bbss", "=", "new", "ArrayList", "<", "FutabaBBSContent", ">", "(", ")", ";", "try", "{", "if", "(", "SDCard", ".", "existSeriarized", "(", "OPT_FAVORITES", ")", ")", "{", "bbss", "=", "(", "ArrayList", "<", "FutabaBBSContent", ">", ")", "SDCard", ".", "getSerialized", "(", "OPT_FAVORITES", ")", ".", "readObject", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "return", "bbss", ";", "}", "public", "static", "void", "setFavorites", "(", "Context", "context", ",", "ArrayList", "<", "FutabaBBSContent", ">", "futabaBBSs", ")", "throws", "IOException", "{", "SDCard", ".", "setSerialized", "(", "OPT_FAVORITES", ",", "futabaBBSs", ")", ";", "}", "}", "</s>" ]
8,253
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "android", ".", "util", ".", "Log", ";", "public", "class", "FLog", "{", "static", "final", "boolean", "use_log", "=", "false", ";", "static", "public", "int", "d", "(", "String", "msg", ")", "{", "if", "(", "use_log", ")", "{", "return", "Log", ".", "d", "(", "\"ftbt\"", ",", "msg", ")", ";", "}", "else", "{", "return", "-", "1", ";", "}", "}", "static", "public", "int", "d", "(", "String", "msg", ",", "Throwable", "tr", ")", "{", "if", "(", "use_log", ")", "{", "return", "Log", ".", "d", "(", "\"ftbt\"", ",", "msg", ",", "tr", ")", ";", "}", "else", "{", "return", "-", "1", ";", "}", "}", "static", "public", "int", "e", "(", "String", "msg", ")", "{", "if", "(", "use_log", ")", "{", "return", "Log", ".", "e", "(", "\"ftbt\"", ",", "msg", ")", ";", "}", "else", "{", "return", "-", "1", ";", "}", "}", "static", "public", "int", "e", "(", "String", "msg", ",", "Throwable", "tr", ")", "{", "if", "(", "use_log", ")", "{", "return", "Log", ".", "e", "(", "\"ftbt\"", ",", "msg", ",", "tr", ")", ";", "}", "else", "{", "return", "-", "1", ";", "}", "}", "static", "public", "int", "i", "(", "String", "msg", ")", "{", "if", "(", "use_log", ")", "{", "return", "Log", ".", "i", "(", "\"ftbt\"", ",", "msg", ")", ";", "}", "else", "{", "return", "-", "1", ";", "}", "}", "static", "public", "int", "i", "(", "String", "msg", ",", "Throwable", "tr", ")", "{", "if", "(", "use_log", ")", "{", "return", "Log", ".", "i", "(", "\"ftbt\"", ",", "msg", ",", "tr", ")", ";", "}", "else", "{", "return", "-", "1", ";", "}", "}", "static", "public", "int", "w", "(", "String", "msg", ")", "{", "if", "(", "use_log", ")", "{", "return", "Log", ".", "w", "(", "\"ftbt\"", ",", "msg", ")", ";", "}", "else", "{", "return", "-", "1", ";", "}", "}", "static", "public", "int", "w", "(", "String", "msg", ",", "Throwable", "tr", ")", "{", "if", "(", "use_log", ")", "{", "return", "Log", ".", "w", "(", "\"ftbt\"", ",", "msg", ",", "tr", ")", ";", "}", "else", "{", "return", "-", "1", ";", "}", "}", "static", "public", "int", "v", "(", "String", "msg", ")", "{", "if", "(", "use_log", ")", "{", "return", "Log", ".", "v", "(", "\"ftbt\"", ",", "msg", ")", ";", "}", "else", "{", "return", "-", "1", ";", "}", "}", "static", "public", "int", "v", "(", "String", "msg", ",", "Throwable", "tr", ")", "{", "if", "(", "use_log", ")", "{", "return", "Log", ".", "v", "(", "\"ftbt\"", ",", "msg", ",", "tr", ")", ";", "}", "else", "{", "return", "-", "1", ";", "}", "}", "}", "</s>" ]
8,254
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "class", "CircleList", "{", "private", "static", "ArrayList", "<", "String", ">", "list", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "private", "static", "int", "pointer", "=", "-", "1", ";", "public", "static", "void", "add", "(", "String", "str", ")", "{", "list", ".", "add", "(", "str", ")", ";", "if", "(", "pointer", "==", "-", "1", ")", "{", "pointer", "=", "0", ";", "}", "}", "public", "static", "String", "get", "(", ")", "{", "return", "list", ".", "get", "(", "pointer", ")", ";", "}", "public", "static", "void", "set", "(", "int", "i", ")", "{", "pointer", "=", "i", ";", "}", "public", "static", "void", "move", "(", "int", "i", ")", "{", "pointer", "+=", "i", ";", "pointer", "=", "(", "pointer", "+", "list", ".", "size", "(", ")", ")", "%", "list", ".", "size", "(", ")", ";", "}", "public", "static", "void", "moveToZero", "(", ")", "{", "pointer", "=", "0", ";", "}", "public", "static", "void", "moveToLast", "(", ")", "{", "pointer", "=", "list", ".", "size", "(", ")", "-", "1", ";", "}", "public", "static", "int", "pos", "(", ")", "{", "return", "pointer", ";", "}", "public", "static", "int", "size", "(", ")", "{", "return", "list", ".", "size", "(", ")", ";", "}", "public", "static", "void", "clear", "(", ")", "{", "list", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "pointer", "=", "-", "1", ";", "}", "}", "</s>" ]
8,255
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "StringReader", ";", "import", "java", ".", "io", ".", "ByteArrayOutputStream", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "webkit", ".", "CookieManager", ";", "import", "android", ".", "webkit", ".", "CookieSyncManager", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "import", "org", ".", "apache", ".", "http", ".", "impl", ".", "client", ".", "DefaultHttpClient", ";", "import", "org", ".", "apache", ".", "http", ".", "HttpStatus", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "methods", ".", "HttpGet", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "methods", ".", "HttpPost", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "params", ".", "ClientPNames", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "params", ".", "CookiePolicy", ";", "import", "org", ".", "apache", ".", "http", ".", "NameValuePair", ";", "import", "org", ".", "apache", ".", "http", ".", "HttpResponse", ";", "import", "org", ".", "apache", ".", "http", ".", "message", ".", "BasicNameValuePair", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "entity", ".", "UrlEncodedFormEntity", ";", "public", "class", "CatalogParser", "{", "private", "ArrayList", "<", "FutabaThreadContent", ">", "fthreads", ";", "public", "CatalogParser", "(", ")", "{", "fthreads", "=", "new", "ArrayList", "<", "FutabaThreadContent", ">", "(", ")", ";", "}", "public", "void", "parse", "(", "String", "catalogHtml", ")", "{", "try", "{", "Pattern", "honbunPattern", "=", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "DOTALL", ")", ";", "Pattern", "resPattern", "=", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "DOTALL", ")", ";", "Pattern", "textPattern", "=", "Pattern", ".", "compile", "(", "\"\"", "+", "\"\"", ",", "Pattern", ".", "DOTALL", ")", ";", "Pattern", "imgPattern", "=", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "DOTALL", ")", ";", "Pattern", "threadNumPattern", "=", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "DOTALL", ")", ";", "Pattern", "tagPattern", "=", "Pattern", ".", "compile", "(", "\"<.+?>\"", ",", "Pattern", ".", "DOTALL", ")", ";", "Matcher", "mc", "=", "honbunPattern", ".", "matcher", "(", "catalogHtml", ")", ";", "mc", ".", "find", "(", ")", ";", "mc", ".", "find", "(", ")", ";", "String", "honbun", "=", "mc", ".", "group", "(", "0", ")", ";", "Matcher", "mcRes", "=", "resPattern", ".", "matcher", "(", "honbun", ")", ";", "while", "(", "mcRes", ".", "find", "(", ")", ")", "{", "Matcher", "mcText", "=", "textPattern", ".", "matcher", "(", "mcRes", ".", "group", "(", "1", ")", ")", ";", "mcText", ".", "find", "(", ")", ";", "FutabaThreadContent", "thread", "=", "new", "FutabaThreadContent", "(", ")", ";", "String", "text", "=", "mcText", ".", "group", "(", "1", ")", ";", "String", "resNum", "=", "mcText", ".", "group", "(", "2", ")", ";", "thread", ".", "text", "=", "text", ";", "thread", ".", "resNum", "=", "resNum", ";", "Matcher", "mcThreadNum", "=", "threadNumPattern", ".", "matcher", "(", "mcRes", ".", "group", "(", "1", ")", ")", ";", "mcThreadNum", ".", "find", "(", ")", ";", "String", "threadNum", "=", "mcThreadNum", ".", "group", "(", "1", ")", ";", "thread", ".", "threadNum", "=", "Integer", ".", "parseInt", "(", "threadNum", ")", ";", "Matcher", "mcImg", "=", "imgPattern", ".", "matcher", "(", "mcRes", ".", "group", "(", "1", ")", ")", ";", "if", "(", "mcImg", ".", "find", "(", ")", ")", "{", "thread", ".", "imgURL", "=", "mcImg", ".", "group", "(", "1", ")", ";", "}", "fthreads", ".", "add", "(", "thread", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"parser", "error\"", ",", "e", ")", ";", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "public", "ArrayList", "<", "FutabaThreadContent", ">", "getThreads", "(", ")", "{", "return", "fthreads", ";", "}", "}", "</s>" ]
8,256
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "StringReader", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "util", ".", "Xml", ";", "import", "org", ".", "xmlpull", ".", "v1", ".", "XmlPullParser", ";", "import", "org", ".", "xmlpull", ".", "v1", ".", "XmlPullParserException", ";", "import", "org", ".", "xmlpull", ".", "v1", ".", "XmlPullParserFactory", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "public", "class", "FutabaThreadParser", "{", "private", "static", "final", "String", "FORMTAG", "=", "\"form\"", ";", "private", "static", "final", "String", "BLOCKQUOTETAG", "=", "\"qlockquote\"", ";", "private", "static", "final", "String", "TABLETAG", "=", "\"table\"", ";", "private", "static", "final", "String", "IMGTAG", "=", "\"img\"", ";", "private", "static", "final", "String", "SRCTAG", "=", "\"src\"", ";", "private", "String", "urlStr", ";", "private", "String", "title", ";", "private", "String", "titleImgURL", ";", "private", "ArrayList", "<", "FutabaStatus", ">", "statuses", ";", "private", "static", "Pattern", "tagPattern", "=", "Pattern", ".", "compile", "(", "\"<.+?>\"", ",", "Pattern", ".", "DOTALL", ")", ";", "public", "FutabaThreadParser", "(", ")", "{", "title", "=", "\"(title)\"", ";", "statuses", "=", "new", "ArrayList", "<", "FutabaStatus", ">", "(", ")", ";", "}", "private", "Pattern", "mailToPattern", "=", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "DOTALL", ")", ";", "public", "void", "parse", "(", "String", "allData", ",", "boolean", "anonymous", ",", "boolean", "showdeleted", ")", "{", "try", "{", "Pattern", "honbunPattern", "=", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "DOTALL", ")", ";", "Pattern", "resPattern", "=", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "DOTALL", ")", ";", "Pattern", "textAttrPattern", "=", "Pattern", ".", "compile", "(", "\"\"", "+", "\"\"", "+", "\"\"", ",", "Pattern", ".", "DOTALL", ")", ";", "Pattern", "imgTextAttrPattern", "=", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "DOTALL", ")", ";", "Pattern", "textPattern", "=", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "DOTALL", ")", ";", "Pattern", "imgPattern", "=", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "DOTALL", ")", ";", "Pattern", "thumbPattern", "=", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "DOTALL", ")", ";", "Pattern", "endTimePattern", "=", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "DOTALL", ")", ";", "Matcher", "mc", "=", "honbunPattern", ".", "matcher", "(", "allData", ")", ";", "mc", ".", "find", "(", ")", ";", "mc", ".", "find", "(", ")", ";", "String", "honbun", "=", "mc", ".", "group", "(", "0", ")", ";", "FutabaStatus", "statusTop", "=", "new", "FutabaStatus", "(", ")", ";", "Matcher", "mcImg", "=", "thumbPattern", ".", "matcher", "(", "honbun", ")", ";", "if", "(", "mcImg", ".", "find", "(", ")", ")", "{", "statusTop", ".", "imgURL", "=", "mcImg", ".", "group", "(", "1", ")", ";", "statusTop", ".", "width", "=", "Integer", ".", "parseInt", "(", "mcImg", ".", "group", "(", "2", ")", ")", ";", "statusTop", ".", "height", "=", "Integer", ".", "parseInt", "(", "mcImg", ".", "group", "(", "3", ")", ")", ";", "}", "Matcher", "mcBigImg", "=", "imgPattern", ".", "matcher", "(", "honbun", ")", ";", "if", "(", "mcBigImg", ".", "find", "(", ")", ")", "{", "statusTop", ".", "bigImgURL", "=", "mcBigImg", ".", "group", "(", "1", ")", ";", "}", "Matcher", "mcText", "=", "textPattern", ".", "matcher", "(", "honbun", ")", ";", "mcText", ".", "find", "(", ")", ";", "if", "(", "!", "anonymous", ")", "{", "Matcher", "mcTextAttr", "=", "textAttrPattern", ".", "matcher", "(", "honbun", ")", ";", "if", "(", "mcTextAttr", ".", "find", "(", ")", ")", "{", "statusTop", ".", "title", "=", "mcTextAttr", ".", "group", "(", "1", ")", ";", "statusTop", ".", "name", "=", "normalize", "(", "mcTextAttr", ".", "group", "(", "2", ")", ")", ";", "statusTop", ".", "datestr", "=", "mcTextAttr", ".", "group", "(", "3", ")", ";", "statusTop", ".", "id", "=", "Integer", ".", "parseInt", "(", "mcTextAttr", ".", "group", "(", "4", ")", ")", ";", "}", "}", "else", "{", "Matcher", "mcTextAttr", "=", "imgTextAttrPattern", ".", "matcher", "(", "honbun", ")", ";", "if", "(", "mcTextAttr", ".", "find", "(", ")", ")", "{", "statusTop", ".", "datestr", "=", "normalize", "(", "mcTextAttr", ".", "group", "(", "1", ")", ")", ";", "statusTop", ".", "mailTo", "=", "extractMailTo", "(", "mcTextAttr", ".", "group", "(", "1", ")", ")", ";", "statusTop", ".", "id", "=", "Integer", ".", "parseInt", "(", "mcTextAttr", ".", "group", "(", "2", ")", ")", ";", "}", "}", "String", "text", "=", "mcText", ".", "group", "(", "1", ")", ";", "statusTop", ".", "text", "=", "text", ";", "Matcher", "mcEndTime", "=", "endTimePattern", ".", "matcher", "(", "honbun", ")", ";", "if", "(", "mcEndTime", ".", "find", "(", ")", ")", "{", "statusTop", ".", "endTime", "=", "mcEndTime", ".", "group", "(", "1", ")", ";", "}", "else", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "}", "statuses", ".", "add", "(", "statusTop", ")", ";", "Matcher", "mcRes", "=", "resPattern", ".", "matcher", "(", "honbun", ")", ";", "while", "(", "mcRes", ".", "find", "(", ")", ")", "{", "FutabaStatus", "status", "=", "new", "FutabaStatus", "(", ")", ";", "mcText", "=", "textPattern", ".", "matcher", "(", "mcRes", ".", "group", "(", "2", ")", ")", ";", "mcText", ".", "find", "(", ")", ";", "if", "(", "!", "anonymous", ")", "{", "Matcher", "mcTextAttr", "=", "textAttrPattern", ".", "matcher", "(", "mcRes", ".", "group", "(", "2", ")", ")", ";", "if", "(", "mcTextAttr", ".", "find", "(", ")", ")", "{", "status", ".", "title", "=", "mcTextAttr", ".", "group", "(", "1", ")", ";", "status", ".", "name", "=", "normalize", "(", "mcTextAttr", ".", "group", "(", "2", ")", ")", ";", "status", ".", "mailTo", "=", "extractMailTo", "(", "mcTextAttr", ".", "group", "(", "2", ")", ")", ";", "status", ".", "datestr", "=", "mcTextAttr", ".", "group", "(", "3", ")", ";", "status", ".", "id", "=", "Integer", ".", "parseInt", "(", "mcTextAttr", ".", "group", "(", "4", ")", ")", ";", "}", "}", "else", "{", "Matcher", "mcTextAttr", "=", "imgTextAttrPattern", ".", "matcher", "(", "mcRes", ".", "group", "(", "2", ")", ")", ";", "if", "(", "mcTextAttr", ".", "find", "(", ")", ")", "{", "status", ".", "datestr", "=", "normalize", "(", "mcTextAttr", ".", "group", "(", "1", ")", ")", ";", "status", ".", "mailTo", "=", "extractMailTo", "(", "mcTextAttr", ".", "group", "(", "1", ")", ")", ";", "if", "(", "!", "status", ".", "mailTo", ".", "equals", "(", "\"\"", ")", ")", "{", "FLog", ".", "d", "(", "\"mailto=\"", "+", "status", ".", "mailTo", ")", ";", "}", "status", ".", "id", "=", "Integer", ".", "parseInt", "(", "mcTextAttr", ".", "group", "(", "2", ")", ")", ";", "}", "}", "text", "=", "mcText", ".", "group", "(", "1", ")", ";", "status", ".", "text", "=", "text", ";", "mcImg", "=", "thumbPattern", ".", "matcher", "(", "mcRes", ".", "group", "(", "2", ")", ")", ";", "if", "(", "mcImg", ".", "find", "(", ")", ")", "{", "status", ".", "imgURL", "=", "mcImg", ".", "group", "(", "1", ")", ";", "status", ".", "width", "=", "Integer", ".", "parseInt", "(", "mcImg", ".", "group", "(", "2", ")", ")", ";", "status", ".", "height", "=", "Integer", ".", "parseInt", "(", "mcImg", ".", "group", "(", "3", ")", ")", ";", "}", "mcBigImg", "=", "imgPattern", ".", "matcher", "(", "mcRes", ".", "group", "(", "2", ")", ")", ";", "if", "(", "mcBigImg", ".", "find", "(", ")", ")", "{", "status", ".", "bigImgURL", "=", "mcBigImg", ".", "group", "(", "1", ")", ";", "}", "status", ".", "deleted", "=", "mcRes", ".", "group", "(", "1", ")", ".", "indexOf", "(", "\"\"", ")", "!=", "-", "1", ";", "statuses", ".", "add", "(", "status", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"\"", ",", "e", ")", ";", "}", "}", "private", "String", "normalize", "(", "String", "text", ")", "{", "text", "=", "text", ".", "replaceAll", "(", "\"<br>\"", ",", "\"n\"", ")", ";", "text", "=", "tagPattern", ".", "matcher", "(", "text", ")", ".", "replaceAll", "(", "\"\"", ")", ";", "text", "=", "text", ".", "replaceAll", "(", "\"&gt;\"", ",", "\">\"", ")", ";", "return", "text", ";", "}", "private", "String", "extractMailTo", "(", "String", "name", ")", "{", "Matcher", "mailTo", "=", "mailToPattern", ".", "matcher", "(", "name", ")", ";", "if", "(", "mailTo", ".", "find", "(", ")", ")", "{", "return", "mailTo", ".", "group", "(", "1", ")", ";", "}", "return", "\"\"", ";", "}", "public", "void", "addStatus", "(", "XmlPullParser", "parser", ")", "{", "String", "text", "=", "\"\"", ";", "String", "imgURL", "=", "\"\"", ";", "try", "{", "int", "eventType", "=", "parser", ".", "next", "(", ")", ";", "while", "(", "eventType", "!=", "XmlPullParser", ".", "END_DOCUMENT", ")", "{", "String", "name", "=", "null", ";", "switch", "(", "eventType", ")", "{", "case", "XmlPullParser", ".", "START_TAG", ":", "name", "=", "parser", ".", "getName", "(", ")", ";", "if", "(", "name", ".", "equalsIgnoreCase", "(", "BLOCKQUOTETAG", ")", ")", "{", "text", "=", "parser", ".", "getText", "(", ")", ";", "}", "else", "if", "(", "name", ".", "equalsIgnoreCase", "(", "IMGTAG", ")", ")", "{", "imgURL", "=", "getAttributeByName", "(", "parser", ",", "SRCTAG", ")", ";", "}", "break", ";", "case", "XmlPullParser", ".", "END_TAG", ":", "name", "=", "parser", ".", "getName", "(", ")", ";", "if", "(", "name", ".", "equalsIgnoreCase", "(", "TABLETAG", ")", ")", "{", "FutabaStatus", "status", "=", "new", "FutabaStatus", "(", ")", ";", "status", ".", "text", "=", "text", ";", "status", ".", "imgURL", "=", "imgURL", ";", "statuses", ".", "add", "(", "status", ")", ";", "return", ";", "}", "break", ";", "}", "eventType", "=", "parser", ".", "next", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "public", "String", "getAttributeByName", "(", "XmlPullParser", "parser", ",", "String", "nameArg", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "parser", ".", "getAttributeCount", "(", ")", ";", "++", "i", ")", "{", "String", "name", "=", "parser", ".", "getAttributeName", "(", "i", ")", ";", "if", "(", "nameArg", ".", "equalsIgnoreCase", "(", "name", ")", ")", "{", "return", "parser", ".", "getAttributeValue", "(", "i", ")", ";", "}", "}", "return", "\"\"", ";", "}", "public", "ArrayList", "<", "FutabaStatus", ">", "getStatuses", "(", ")", "{", "return", "statuses", ";", "}", "public", "String", "getTitle", "(", "int", "num", ")", "{", "if", "(", "statuses", ".", "size", "(", ")", ">", "0", ")", "{", "String", "text", "=", "statuses", ".", "get", "(", "0", ")", ".", "text", ";", "text", "=", "tagPattern", ".", "matcher", "(", "text", ")", ".", "replaceAll", "(", "\"\"", ")", ";", "if", "(", "text", ".", "length", "(", ")", ">", "num", ")", "{", "return", "text", ".", "substring", "(", "0", ",", "Math", ".", "min", "(", "text", ".", "length", "(", ")", ",", "num", ")", ")", "+", "\"...\"", ";", "}", "else", "{", "return", "text", ".", "substring", "(", "0", ",", "Math", ".", "min", "(", "text", ".", "length", "(", ")", ",", "num", ")", ")", ";", "}", "}", "return", "\"(no", "title)\"", ";", "}", "public", "static", "String", "removeTag", "(", "String", "str", ")", "{", "return", "tagPattern", ".", "matcher", "(", "str", ")", ".", "replaceAll", "(", "\"\"", ")", ";", "}", "}", "</s>" ]
8,257
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "android", ".", "app", ".", "Activity", ";", "import", "android", ".", "app", ".", "ProgressDialog", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "content", ".", "SharedPreferences", ";", "import", "android", ".", "content", ".", "res", ".", "Configuration", ";", "import", "android", ".", "graphics", ".", "Color", ";", "import", "android", ".", "net", ".", "Uri", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "os", ".", "Handler", ";", "import", "android", ".", "os", ".", "Message", ";", "import", "android", ".", "preference", ".", "PreferenceManager", ";", "import", "android", ".", "view", ".", "Display", ";", "import", "android", ".", "view", ".", "KeyEvent", ";", "import", "android", ".", "view", ".", "Menu", ";", "import", "android", ".", "view", ".", "MenuInflater", ";", "import", "android", ".", "view", ".", "MenuItem", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "view", ".", "Window", ";", "import", "android", ".", "view", ".", "WindowManager", ";", "import", "android", ".", "view", ".", "View", ".", "OnClickListener", ";", "import", "android", ".", "view", ".", "ViewGroup", ";", "import", "android", ".", "widget", ".", "ArrayAdapter", ";", "import", "android", ".", "widget", ".", "Button", ";", "import", "android", ".", "widget", ".", "GridView", ";", "import", "android", ".", "widget", ".", "LinearLayout", ";", "import", "android", ".", "widget", ".", "ListView", ";", "import", "android", ".", "widget", ".", "TextView", ";", "import", "android", ".", "widget", ".", "Toast", ";", "import", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ".", "R", ".", "id", ";", "public", "class", "ThumbGrid", "extends", "Activity", "implements", "Runnable", "{", "private", "ProgressDialog", "waitDialog", ";", "private", "Thread", "thread", ";", "public", "ArrayList", "<", "String", ">", "thumbURLs", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "public", "ArrayList", "<", "String", ">", "imgURLs", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "public", "int", "startPos", "=", "0", ";", "private", "int", "width", ";", "private", "int", "height", ";", "public", "String", "baseUrl", "=", "\"\"", ";", "private", "String", "catalogURL", ";", "private", "String", "BBSName", "=", "\"\"", ";", "private", "GridView", "grid", ";", "@", "Override", "public", "void", "onCreate", "(", "Bundle", "savedInstanceState", ")", "{", "super", ".", "onCreate", "(", "savedInstanceState", ")", ";", "if", "(", "getResources", "(", ")", ".", "getBoolean", "(", "R", ".", "bool", ".", "avoidsleep", ")", ")", "{", "Window", "window", "=", "getWindow", "(", ")", ";", "window", ".", "addFlags", "(", "WindowManager", ".", "LayoutParams", ".", "FLAG_KEEP_SCREEN_ON", ")", ";", "}", "try", "{", "setTitle", "(", "\"-UNK-", "-", "\"", "+", "getString", "(", "R", ".", "string", ".", "app_name", ")", ")", ";", "Toast", ".", "makeText", "(", "this", ",", "\"\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "System", ".", "gc", "(", ")", ";", "FLog", ".", "d", "(", "\"\"", ")", ";", "Intent", "intent", "=", "getIntent", "(", ")", ";", "thumbURLs", "=", "(", "ArrayList", "<", "String", ">", ")", "intent", ".", "getSerializableExtra", "(", "\"thumbURLs\"", ")", ";", "imgURLs", "=", "(", "ArrayList", "<", "String", ">", ")", "intent", ".", "getSerializableExtra", "(", "\"imgURLs\"", ")", ";", "startPos", "=", "(", "Integer", ")", "intent", ".", "getSerializableExtra", "(", "\"position\"", ")", ";", "WindowManager", "wm", "=", "(", "WindowManager", ")", "getSystemService", "(", "Context", ".", "WINDOW_SERVICE", ")", ";", "Display", "display", "=", "wm", ".", "getDefaultDisplay", "(", ")", ";", "width", "=", "display", ".", "getWidth", "(", ")", ";", "height", "=", "display", ".", "getHeight", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "setWait", "(", ")", ";", "}", "public", "void", "setWait", "(", ")", "{", "waitDialog", "=", "new", "ProgressDialog", "(", "this", ")", ";", "waitDialog", ".", "setMessage", "(", "this", ".", "getString", "(", "R", ".", "string", ".", "loading", ")", ")", ";", "waitDialog", ".", "setProgressStyle", "(", "ProgressDialog", ".", "STYLE_SPINNER", ")", ";", "waitDialog", ".", "show", "(", ")", ";", "thread", "=", "new", "Thread", "(", "this", ")", ";", "thread", ".", "start", "(", ")", ";", "}", "public", "void", "run", "(", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "100", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "handler", ".", "sendEmptyMessage", "(", "0", ")", ";", "}", "private", "Handler", "handler", "=", "new", "Handler", "(", ")", "{", "public", "void", "handleMessage", "(", "Message", "msg", ")", "{", "try", "{", "loading", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", ";", "final", "Handler", "handler2", "=", "new", "Handler", "(", ")", ";", "private", "final", "int", "FP", "=", "ViewGroup", ".", "LayoutParams", ".", "FILL_PARENT", ";", "private", "final", "int", "WC", "=", "ViewGroup", ".", "LayoutParams", ".", "WRAP_CONTENT", ";", "private", "void", "loading", "(", ")", "{", "setContentView", "(", "R", ".", "layout", ".", "thumbgrid", ")", ";", "TextView", "imagenum", "=", "(", "TextView", ")", "findViewById", "(", "id", ".", "imagenum", ")", ";", "imagenum", ".", "setText", "(", "\"-UNK-:\"", "+", "thumbURLs", ".", "size", "(", ")", "+", "\"-UNK-", "\"", ")", ";", "grid", "=", "(", "GridView", ")", "findViewById", "(", "id", ".", "gridview", ")", ";", "try", "{", "SharedPreferences", "preferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "this", ")", ";", "boolean", "fastScrollEnabled", "=", "preferences", ".", "getBoolean", "(", "\"\"", ",", "false", ")", ";", "grid", ".", "setFastScrollEnabled", "(", "fastScrollEnabled", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "if", "(", "width", "<", "height", ")", "{", "grid", ".", "setNumColumns", "(", "3", ")", ";", "}", "else", "{", "grid", ".", "setNumColumns", "(", "5", ")", ";", "}", "ThumbGridAdapter", "adapter", "=", "new", "ThumbGridAdapter", "(", "this", ",", "R", ".", "layout", ".", "thumbgridelement", ",", "thumbURLs", ")", ";", "grid", ".", "setAdapter", "(", "adapter", ")", ";", "grid", ".", "setSmoothScrollbarEnabled", "(", "true", ")", ";", "grid", ".", "setVerticalScrollBarEnabled", "(", "true", ")", ";", "grid", ".", "setSelection", "(", "startPos", ")", ";", "grid", ".", "setDrawingCacheEnabled", "(", "true", ")", ";", "waitDialog", ".", "dismiss", "(", ")", ";", "}", "public", "void", "onConfigurationChanged", "(", "Configuration", "newConfig", ")", "{", "super", ".", "onConfigurationChanged", "(", "newConfig", ")", ";", "WindowManager", "wm", "=", "(", "WindowManager", ")", "getSystemService", "(", "Context", ".", "WINDOW_SERVICE", ")", ";", "Display", "display", "=", "wm", ".", "getDefaultDisplay", "(", ")", ";", "width", "=", "display", ".", "getWidth", "(", ")", ";", "height", "=", "display", ".", "getHeight", "(", ")", ";", "if", "(", "width", "<", "height", ")", "{", "grid", ".", "setNumColumns", "(", "3", ")", ";", "}", "else", "{", "grid", ".", "setNumColumns", "(", "5", ")", ";", "}", "System", ".", "gc", "(", ")", ";", "}", "private", "LinearLayout", ".", "LayoutParams", "createParam", "(", "int", "w", ",", "int", "h", ")", "{", "return", "new", "LinearLayout", ".", "LayoutParams", "(", "w", ",", "h", ")", ";", "}", "@", "Override", "public", "boolean", "onCreateOptionsMenu", "(", "Menu", "menu", ")", "{", "super", ".", "onCreateOptionsMenu", "(", "menu", ")", ";", "MenuInflater", "inflater", "=", "getMenuInflater", "(", ")", ";", "inflater", ".", "inflate", "(", "R", ".", "menu", ".", "menu_gridview", ",", "menu", ")", ";", "return", "true", ";", "}", "@", "Override", "public", "boolean", "onOptionsItemSelected", "(", "MenuItem", "item", ")", "{", "Intent", "intent", ";", "switch", "(", "item", ".", "getItemId", "(", ")", ")", "{", "case", "R", ".", "id", ".", "post", ":", "return", "true", ";", "case", "R", ".", "id", ".", "settings", ":", "intent", "=", "new", "Intent", "(", ")", ";", "intent", ".", "setClassName", "(", "getPackageName", "(", ")", ",", "getClass", "(", ")", ".", "getPackage", "(", ")", ".", "getName", "(", ")", "+", "\".PrefSetting\"", ")", ";", "startActivity", "(", "intent", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "about", ":", "Uri", "uri", "=", "Uri", ".", "parse", "(", "getString", "(", "R", ".", "string", ".", "helpurl", ")", ")", ";", "intent", "=", "new", "Intent", "(", "Intent", ".", "ACTION_VIEW", ",", "uri", ")", ";", "intent", ".", "setClassName", "(", "\"\"", ",", "\"\"", ")", ";", "try", "{", "startActivity", "(", "intent", ")", ";", "}", "catch", "(", "android", ".", "content", ".", "ActivityNotFoundException", "ex", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "\"-UNK-\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}", "@", "Override", "public", "void", "onPause", "(", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "super", ".", "onPause", "(", ")", ";", "System", ".", "gc", "(", ")", ";", "}", "@", "Override", "public", "void", "onStop", "(", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "super", ".", "onStop", "(", ")", ";", "System", ".", "gc", "(", ")", ";", "}", "@", "Override", "public", "void", "onDestroy", "(", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "super", ".", "onDestroy", "(", ")", ";", "System", ".", "gc", "(", ")", ";", "}", "}", "</s>" ]
8,258
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "StringReader", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "android", ".", "content", ".", "SharedPreferences", ";", "import", "android", ".", "preference", ".", "PreferenceManager", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "widget", ".", "Toast", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "public", "class", "FutabaBBSMenuParser", "{", "private", "ArrayList", "<", "FutabaBBSContent", ">", "BBSs", ";", "private", "String", "urlStr", ";", "public", "boolean", "network_ok", ";", "public", "boolean", "cache_ok", ";", "public", "boolean", "display_censored", "=", "false", ";", "public", "FutabaBBSMenuParser", "(", "String", "urlStr", ")", "{", "this", ".", "urlStr", "=", "urlStr", ";", "BBSs", "=", "new", "ArrayList", "<", "FutabaBBSContent", ">", "(", ")", ";", "network_ok", "=", "true", ";", "cache_ok", "=", "true", ";", "}", "public", "void", "setDisplayCensored", "(", "boolean", "bool", ")", "{", "display_censored", "=", "bool", ";", "}", "public", "void", "parse", "(", ")", "{", "try", "{", "Pattern", "BBSPattern", "=", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "DOTALL", ")", ";", "String", "allData", "=", "\"\"", ";", "try", "{", "SDCard", ".", "saveFromURL", "(", "FutabaCrypt", ".", "createDigest", "(", "urlStr", ")", ",", "new", "URL", "(", "urlStr", ")", ",", "true", ")", ";", "allData", "=", "SDCard", ".", "loadTextCache", "(", "FutabaCrypt", ".", "createDigest", "(", "urlStr", ")", ")", ";", "network_ok", "=", "true", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "network_ok", "=", "false", ";", "if", "(", "SDCard", ".", "cacheExist", "(", "FutabaCrypt", ".", "createDigest", "(", "urlStr", ")", ")", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "allData", "=", "SDCard", ".", "loadTextCache", "(", "FutabaCrypt", ".", "createDigest", "(", "urlStr", ")", ")", ";", "}", "else", "{", "cache_ok", "=", "false", ";", "}", "}", "Matcher", "mcBBS", "=", "BBSPattern", ".", "matcher", "(", "allData", ")", ";", "while", "(", "mcBBS", ".", "find", "(", ")", ")", "{", "FutabaBBSContent", "bbs", "=", "new", "FutabaBBSContent", "(", ")", ";", "bbs", ".", "url", "=", "mcBBS", ".", "group", "(", "1", ")", ";", "bbs", ".", "name", "=", "mcBBS", ".", "group", "(", "2", ")", ";", "if", "(", "bbs", ".", "name", ".", "equals", "(", "\"-UNK-\"", ")", ")", "{", "if", "(", "bbs", ".", "url", ".", "contains", "(", "\"may\"", ")", ")", "{", "bbs", ".", "name", "=", "\"-UNK-(may)\"", ";", "FutabaBBSContent", "img_bbs", "=", "new", "FutabaBBSContent", "(", ")", ";", "img_bbs", ".", "name", "=", "\"-UNK-(img)\"", ";", "img_bbs", ".", "url", "=", "\"\"", ";", "BBSs", ".", "add", "(", "img_bbs", ")", ";", "}", "else", "if", "(", "bbs", ".", "url", ".", "contains", "(", "\"dec\"", ")", ")", "{", "bbs", ".", "name", "=", "\"-UNK-(dec)\"", ";", "FutabaBBSContent", "dat_bbs", "=", "new", "FutabaBBSContent", "(", ")", ";", "dat_bbs", ".", "name", "=", "\"-UNK-(dat)\"", ";", "dat_bbs", ".", "url", "=", "\"\"", ";", "BBSs", ".", "add", "(", "dat_bbs", ")", ";", "}", "else", "if", "(", "bbs", ".", "url", ".", "contains", "(", "\"jun\"", ")", ")", "{", "bbs", ".", "name", "=", "\"-UNK-(jun)\"", ";", "}", "}", "if", "(", "bbs", ".", "name", ".", "equals", "(", "\"-UNK-PC\"", ")", "&&", "display_censored", ")", "{", "FutabaBBSContent", "other_bbs", "=", "new", "FutabaBBSContent", "(", ")", ";", "other_bbs", ".", "name", "=", "\"-UNK-\"", ";", "other_bbs", ".", "url", "=", "\"\"", ";", "BBSs", ".", "add", "(", "other_bbs", ")", ";", "other_bbs", "=", "new", "FutabaBBSContent", "(", ")", ";", "other_bbs", ".", "name", "=", "\"-UNK-\"", ";", "other_bbs", ".", "url", "=", "\"\"", ";", "BBSs", ".", "add", "(", "other_bbs", ")", ";", "other_bbs", "=", "new", "FutabaBBSContent", "(", ")", ";", "other_bbs", ".", "name", "=", "\"-UNK-\"", ";", "other_bbs", ".", "url", "=", "\"\"", ";", "BBSs", ".", "add", "(", "other_bbs", ")", ";", "}", "if", "(", "bbs", ".", "name", ".", "equals", "(", "\"-UNK-ID\"", ")", ")", "{", "FutabaBBSContent", "dat_bbs", "=", "new", "FutabaBBSContent", "(", ")", ";", "dat_bbs", ".", "name", "=", "\"-UNK-jun\"", ";", "dat_bbs", ".", "url", "=", "\"\"", ";", "BBSs", ".", "add", "(", "dat_bbs", ")", ";", "}", "BBSs", ".", "add", "(", "bbs", ")", ";", "}", "FutabaBBSContent", "rayout_bbs", "=", "new", "FutabaBBSContent", "(", ")", ";", "rayout_bbs", ".", "name", "=", "\"-UNK-\"", ";", "rayout_bbs", ".", "url", "=", "\"\"", ";", "BBSs", ".", "add", "(", "rayout_bbs", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"\"", ",", "e", ")", ";", "}", "}", "public", "ArrayList", "<", "FutabaBBSContent", ">", "getBBSs", "(", ")", "{", "return", "BBSs", ";", "}", "}", "</s>" ]
8,259
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "android", ".", "app", ".", "ProgressDialog", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "graphics", ".", "Bitmap", ";", "import", "android", ".", "graphics", ".", "Matrix", ";", "import", "android", ".", "graphics", ".", "PointF", ";", "import", "android", ".", "graphics", ".", "Rect", ";", "import", "android", ".", "os", ".", "AsyncTask", ";", "import", "android", ".", "os", ".", "Handler", ";", "import", "android", ".", "os", ".", "Message", ";", "import", "android", ".", "util", ".", "AttributeSet", ";", "import", "android", ".", "util", ".", "FloatMath", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "view", ".", "Display", ";", "import", "android", ".", "view", ".", "GestureDetector", ".", "OnGestureListener", ";", "import", "android", ".", "view", ".", "GestureDetector", ".", "SimpleOnGestureListener", ";", "import", "android", ".", "view", ".", "MotionEvent", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "view", ".", "WindowManager", ";", "import", "android", ".", "view", ".", "View", ".", "OnTouchListener", ";", "import", "android", ".", "widget", ".", "ImageView", ";", "import", "android", ".", "widget", ".", "Toast", ";", "import", "java", ".", "lang", ".", "Math", ";", "import", "android", ".", "view", ".", "GestureDetector", ";", "class", "ImageCatalogSingleView", "extends", "ImageView", "implements", "Runnable", "{", "private", "static", "final", "int", "NONE", "=", "0", ";", "private", "static", "final", "int", "DRAG", "=", "1", ";", "private", "static", "final", "int", "ZOOM", "=", "2", ";", "private", "Matrix", "matrix", "=", "new", "Matrix", "(", ")", ";", "private", "int", "mode", "=", "NONE", ";", "private", "PointF", "middle", "=", "new", "PointF", "(", ")", ";", "private", "Matrix", "moveMatrix", "=", "new", "Matrix", "(", ")", ";", "private", "float", "initLength", "=", "1", ";", "private", "MotionEvent", "prevEvent", ";", "private", "float", "mx", "=", "0f", ";", "private", "int", "width", "=", "100", ";", "private", "int", "height", "=", "100", ";", "private", "Bitmap", "bm", "=", "null", ";", "private", "float", "bx", ";", "private", "float", "by", ";", "public", "ProgressDialog", "waitDialog", ";", "private", "Thread", "thread", ";", "private", "PointF", "point", "=", "null", ";", "private", "PointF", "p1", "=", "new", "PointF", "(", ")", ";", "private", "PointF", "p2", "=", "new", "PointF", "(", ")", ";", "private", "int", "point_side", "=", "1", ";", "private", "boolean", "rotated", "=", "false", ";", "private", "GestureDetector", "gestureDetector", ";", "public", "ImageCatalogSingleView", "(", "Context", "context", ")", "{", "this", "(", "context", ",", "null", ",", "0", ")", ";", "}", "public", "ImageCatalogSingleView", "(", "Context", "context", ",", "AttributeSet", "attrs", ")", "{", "this", "(", "context", ",", "attrs", ",", "0", ")", ";", "}", "@", "Override", "protected", "void", "onSizeChanged", "(", "int", "w", ",", "int", "h", ",", "int", "oldw", ",", "int", "oldh", ")", "{", "width", "=", "w", ";", "height", "=", "h", ";", "clearImage", "(", ")", ";", "setImage", "(", ")", ";", "}", "public", "void", "clearImage", "(", ")", "{", "try", "{", "super", ".", "setImageBitmap", "(", "null", ")", ";", "if", "(", "bm", "!=", "null", ")", "{", "int", "size", "=", "bm", ".", "getWidth", "(", ")", "*", "bm", ".", "getHeight", "(", ")", ";", "bm", "=", "null", ";", "if", "(", "true", ")", "{", "FLog", ".", "d", "(", "\"calling", "GC\"", ")", ";", "System", ".", "gc", "(", ")", ";", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "public", "ImageCatalogSingleView", "(", "Context", "context", ",", "AttributeSet", "attrs", ",", "int", "defStyle", ")", "{", "super", "(", "context", ",", "attrs", ",", "defStyle", ")", ";", "try", "{", "matrix", "=", "new", "Matrix", "(", ")", ";", "matrix", ".", "setScale", "(", "1", ",", "1", ")", ";", "bx", "=", "by", "=", "0", ";", "setEnabled", "(", "true", ")", ";", "setClickable", "(", "true", ")", ";", "this", ".", "setScaleType", "(", "ScaleType", ".", "MATRIX", ")", ";", "setImage", "(", ")", ";", "this", ".", "gestureDetector", "=", "new", "GestureDetector", "(", "context", ",", "simpleOnGestureListener", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "@", "Override", "public", "boolean", "onTouchEvent", "(", "MotionEvent", "event", ")", "{", "onTouch", "(", "event", ")", ";", "gestureDetector", ".", "onTouchEvent", "(", "event", ")", ";", "return", "true", ";", "}", "public", "boolean", "onTouch", "(", "MotionEvent", "event", ")", "{", "try", "{", "ImageCatalog", "activity", "=", "(", "ImageCatalog", ")", "getContext", "(", ")", ";", "switch", "(", "event", ".", "getAction", "(", ")", ")", "{", "case", "MotionEvent", ".", "ACTION_DOWN", ":", "case", "MotionEvent", ".", "ACTION_POINTER_1_DOWN", ":", "mode", "=", "DRAG", ";", "p1", ".", "set", "(", "event", ".", "getX", "(", ")", ",", "event", ".", "getY", "(", ")", ")", ";", "moveMatrix", ".", "set", "(", "matrix", ")", ";", "break", ";", "case", "MotionEvent", ".", "ACTION_UP", ":", "case", "MotionEvent", ".", "ACTION_POINTER_2_UP", ":", "point", "=", "null", ";", "mode", "=", "NONE", ";", "break", ";", "case", "MotionEvent", ".", "ACTION_POINTER_2_DOWN", ":", "p2", ".", "set", "(", "event", ".", "getX", "(", ")", ",", "event", ".", "getY", "(", ")", ")", ";", "initLength", "=", "getLength", "(", "event", ")", ";", "if", "(", "true", ")", "{", "FLog", ".", "d", "(", "\"mode=ZOOM\"", ")", ";", "moveMatrix", ".", "set", "(", "matrix", ")", ";", "mode", "=", "ZOOM", ";", "}", "break", ";", "case", "MotionEvent", ".", "ACTION_MOVE", ":", "float", "ex", "=", "event", ".", "getX", "(", ")", ";", "float", "ey", "=", "event", ".", "getY", "(", ")", ";", "float", "d1_sq", "=", "(", "p1", ".", "x", "-", "ex", ")", "*", "(", "p1", ".", "x", "-", "ex", ")", "+", "(", "p1", ".", "y", "-", "ey", ")", "*", "(", "p1", ".", "y", "-", "ey", ")", ";", "float", "d2_sq", "=", "(", "p2", ".", "x", "-", "ex", ")", "*", "(", "p2", ".", "x", "-", "ex", ")", "+", "(", "p2", ".", "y", "-", "ey", ")", "*", "(", "p2", ".", "y", "-", "ey", ")", ";", "int", "near_side", ";", "if", "(", "d1_sq", "<", "d2_sq", ")", "{", "if", "(", "point", "==", "null", ")", "{", "point", "=", "new", "PointF", "(", "ex", ",", "ey", ")", ";", "point_side", "=", "1", ";", "}", "p1", "=", "new", "PointF", "(", "ex", ",", "ey", ")", ";", "near_side", "=", "1", ";", "}", "else", "{", "if", "(", "point", "==", "null", ")", "{", "point", "=", "new", "PointF", "(", "ex", ",", "ey", ")", ";", "point_side", "=", "2", ";", "}", "p2", "=", "new", "PointF", "(", "ex", ",", "ey", ")", ";", "near_side", "=", "2", ";", "}", "float", "d2", "=", "(", "ex", "-", "point", ".", "x", ")", "*", "(", "ex", "-", "point", ".", "x", ")", "+", "(", "ey", "-", "point", ".", "y", ")", "*", "(", "ey", "-", "point", ".", "y", ")", ";", "if", "(", "d2", ">", "50", "*", "50", "&&", "(", "point_side", "!=", "near_side", ")", ")", "{", "break", ";", "}", "if", "(", "d2", ">", "150", "*", "150", "&&", "mode", "==", "ZOOM", ")", "{", "break", ";", "}", "switch", "(", "mode", ")", "{", "case", "DRAG", ":", "matrix", ".", "set", "(", "moveMatrix", ")", ";", "move", "(", "1.0f", "*", "(", "ex", "-", "point", ".", "x", ")", ",", "1.3f", "*", "(", "ey", "-", "point", ".", "y", ")", ")", ";", "setImageMatrix", "(", "matrix", ")", ";", "break", ";", "case", "ZOOM", ":", "if", "(", "mode", "==", "ZOOM", ")", "{", "float", "currentLength", "=", "getLength", "(", "event", ")", ";", "middle", "=", "getMiddle", "(", "event", ",", "middle", ")", ";", "if", "(", "true", ")", "{", "matrix", ".", "set", "(", "moveMatrix", ")", ";", "float", "scale", "=", "filter", "(", "matrix", ",", "currentLength", "/", "initLength", ")", ";", "zoomImage", "(", "(", "float", ")", "Math", ".", "pow", "(", "scale", ",", "1.3f", ")", ",", "middle", ".", "x", ",", "middle", ".", "y", ")", ";", "setImageMatrix", "(", "matrix", ")", ";", "}", "break", ";", "}", "break", ";", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "return", "false", ";", "}", "private", "void", "move", "(", "float", "dx", ",", "float", "dy", ")", "{", "float", "[", "]", "values", "=", "new", "float", "[", "9", "]", ";", "matrix", ".", "getValues", "(", "values", ")", ";", "values", "[", "Matrix", ".", "MTRANS_X", "]", "+=", "dx", ";", "values", "[", "Matrix", ".", "MTRANS_Y", "]", "+=", "dy", ";", "matrix", ".", "setValues", "(", "values", ")", ";", "}", "public", "void", "rotateImage", "(", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "matrix", ".", "postRotate", "(", "90f", ",", "width", "/", "2", ",", "height", "/", "2", ")", ";", "setImageMatrix", "(", "matrix", ")", ";", "rotated", "=", "!", "rotated", ";", "zoomImage", "(", "1", ",", "width", "/", "2", ",", "height", "/", "2", ")", ";", "}", "public", "void", "zoomImage", "(", "float", "scale", ",", "float", "mx", ",", "float", "my", ")", "{", "float", "[", "]", "values", "=", "new", "float", "[", "9", "]", ";", "matrix", ".", "getValues", "(", "values", ")", ";", "float", "currentScale", "=", "1f", ";", "if", "(", "!", "rotated", ")", "{", "currentScale", "=", "Math", ".", "abs", "(", "values", "[", "Matrix", ".", "MSCALE_X", "]", ")", ";", "}", "else", "{", "currentScale", "=", "Math", ".", "abs", "(", "values", "[", "Matrix", ".", "MSKEW_X", "]", ")", ";", "}", "float", "postScale", "=", "currentScale", "*", "scale", ";", "FLog", ".", "d", "(", "\"current=\"", "+", "currentScale", "+", "\"", "scale=\"", "+", "scale", ")", ";", "float", "minScale", "=", "1f", ";", "if", "(", "!", "rotated", ")", "{", "minScale", "=", "Math", ".", "min", "(", "(", "float", ")", "width", "/", "(", "float", ")", "bm", ".", "getWidth", "(", ")", ",", "(", "float", ")", "height", "/", "(", "float", ")", "bm", ".", "getHeight", "(", ")", ")", ";", "}", "else", "{", "minScale", "=", "Math", ".", "min", "(", "(", "float", ")", "height", "/", "(", "float", ")", "bm", ".", "getWidth", "(", ")", ",", "(", "float", ")", "width", "/", "(", "float", ")", "bm", ".", "getHeight", "(", ")", ")", ";", "}", "minScale", "=", "Math", ".", "min", "(", "minScale", ",", "1f", ")", ";", "FLog", ".", "d", "(", "\"minscale=\"", "+", "minScale", ")", ";", "if", "(", "postScale", "<", "minScale", ")", "{", "scale", "=", "minScale", "/", "currentScale", ";", "}", "matrix", ".", "postScale", "(", "scale", ",", "scale", ",", "mx", ",", "my", ")", ";", "bx", "=", "bm", ".", "getWidth", "(", ")", "*", "postScale", ";", "by", "=", "bm", ".", "getHeight", "(", ")", "*", "postScale", ";", "setImageMatrix", "(", "matrix", ")", ";", "}", "public", "boolean", "onDoubleTap", "(", "MotionEvent", "e", ")", "{", "FLog", ".", "d", "(", "\"double", "tap\"", ")", ";", "return", "false", ";", "}", "public", "void", "zoomImageToWindow", "(", ")", "{", "if", "(", "bm", ".", "getWidth", "(", ")", "<", "width", "&&", "bm", ".", "getHeight", "(", ")", "<", "height", ")", "{", "matrix", ".", "setScale", "(", "1f", ",", "1f", ")", ";", "bx", "=", "bm", ".", "getWidth", "(", ")", ";", "by", "=", "bm", ".", "getHeight", "(", ")", ";", "}", "else", "{", "float", "scale", "=", "Math", ".", "min", "(", "(", "float", ")", "width", "/", "(", "float", ")", "bm", ".", "getWidth", "(", ")", ",", "(", "float", ")", "height", "/", "(", "float", ")", "bm", ".", "getHeight", "(", ")", ")", ";", "FLog", ".", "d", "(", "\"scale=\"", "+", "scale", ")", ";", "matrix", ".", "setScale", "(", "scale", ",", "scale", ")", ";", "bx", "=", "bm", ".", "getWidth", "(", ")", "*", "scale", ";", "by", "=", "bm", ".", "getHeight", "(", ")", "*", "scale", ";", "}", "float", "[", "]", "values", "=", "new", "float", "[", "9", "]", ";", "matrix", ".", "getValues", "(", "values", ")", ";", "values", "[", "Matrix", ".", "MTRANS_X", "]", "=", "(", "width", "-", "bx", ")", "/", "2", ";", "values", "[", "Matrix", ".", "MTRANS_Y", "]", "=", "(", "height", "-", "by", ")", "/", "2", ";", "matrix", ".", "setValues", "(", "values", ")", ";", "}", "public", "void", "setImageBitmap", "(", "Bitmap", "bm", ")", "{", "super", ".", "setImageBitmap", "(", "bm", ")", ";", "this", ".", "bm", "=", "bm", ";", "rotated", "=", "false", ";", "matrix", ".", "set", "(", "moveMatrix", ")", ";", "zoomImageToWindow", "(", ")", ";", "FLog", ".", "d", "(", "\"bx=\"", "+", "bx", "+", "\"", "by=\"", "+", "by", ")", ";", "setImageMatrix", "(", "matrix", ")", ";", "}", "private", "float", "filter", "(", "Matrix", "m", ",", "float", "s", ")", "{", "return", "(", "float", ")", "Math", ".", "max", "(", "s", ",", "0.5", ")", ";", "}", "private", "float", "getLength", "(", "MotionEvent", "e", ")", "{", "float", "xx", "=", "e", ".", "getX", "(", "1", ")", "-", "e", ".", "getX", "(", "0", ")", ";", "float", "yy", "=", "e", ".", "getY", "(", "1", ")", "-", "e", ".", "getY", "(", "0", ")", ";", "return", "FloatMath", ".", "sqrt", "(", "xx", "*", "xx", "+", "yy", "*", "yy", ")", ";", "}", "private", "PointF", "getMiddle", "(", "MotionEvent", "e", ",", "PointF", "p", ")", "{", "float", "x", "=", "e", ".", "getX", "(", "0", ")", "+", "e", ".", "getX", "(", "1", ")", ";", "float", "y", "=", "e", ".", "getY", "(", "0", ")", "+", "e", ".", "getY", "(", "1", ")", ";", "p", ".", "set", "(", "x", "/", "2", ",", "y", "/", "2", ")", ";", "return", "p", ";", "}", "public", "void", "setImage", "(", ")", "{", "if", "(", "waitDialog", "!=", "null", ")", "{", "dismissWaitDialog", "(", ")", ";", "}", "waitDialog", "=", "new", "ProgressDialog", "(", "getContext", "(", ")", ")", ";", "waitDialog", ".", "setMessage", "(", "\"-UNK-...\"", ")", ";", "waitDialog", ".", "setProgressStyle", "(", "ProgressDialog", ".", "STYLE_SPINNER", ")", ";", "waitDialog", ".", "show", "(", ")", ";", "thread", "=", "new", "Thread", "(", "this", ")", ";", "thread", ".", "start", "(", ")", ";", "}", "public", "void", "run", "(", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "100", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "handler", ".", "sendEmptyMessage", "(", "0", ")", ";", "}", "private", "Handler", "handler", "=", "new", "Handler", "(", ")", "{", "public", "void", "handleMessage", "(", "Message", "msg", ")", "{", "try", "{", "loading", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", ";", "private", "void", "loading", "(", ")", "{", "try", "{", "String", "imgFile", "=", "CircleList", ".", "get", "(", ")", ";", "setTag", "(", "imgFile", ")", ";", "Bitmap", "bmp", "=", "ImageCache", ".", "getImage", "(", "imgFile", ")", ";", "if", "(", "bmp", "==", "null", ")", "{", "ImageGetTask", "task", "=", "new", "ImageGetTask", "(", "this", ")", ";", "task", ".", "execute", "(", "imgFile", ")", ";", "}", "else", "{", "setImageBitmap", "(", "bmp", ")", ";", "dismissWaitDialog", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "void", "dismissWaitDialog", "(", ")", "{", "try", "{", "waitDialog", ".", "dismiss", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "static", "int", "LastTaskID", "=", "-", "1", ";", "static", "Object", "lock", "=", "new", "Object", "(", ")", ";", "class", "ImageGetTask", "extends", "AsyncTask", "<", "String", ",", "Void", ",", "String", ">", "{", "private", "ImageCatalogSingleView", "image", ";", "private", "String", "tag", ";", "private", "int", "id", ";", "public", "ImageGetTask", "(", "ImageCatalogSingleView", "_image", ")", "{", "image", "=", "_image", ";", "tag", "=", "image", ".", "getTag", "(", ")", ".", "toString", "(", ")", ";", "synchronized", "(", "ImageCatalogSingleView", ".", "lock", ")", "{", "ImageCatalogSingleView", ".", "LastTaskID", "+=", "1", ";", "id", "=", "ImageCatalogSingleView", ".", "LastTaskID", ";", "}", "FLog", ".", "d", "(", "\"thread", "id\"", "+", "id", "+", "\"", "created.\"", ")", ";", "}", "@", "Override", "protected", "String", "doInBackground", "(", "String", "...", "urls", ")", "{", "try", "{", "FLog", ".", "d", "(", "\"getting\"", "+", "urls", "[", "0", "]", ")", ";", "ImageCache", ".", "getImage", "(", "urls", "[", "0", "]", ")", ";", "if", "(", "ImageCache", ".", "getImage", "(", "urls", "[", "0", "]", ")", "==", "null", ")", "{", "boolean", "network_result", "=", "ImageCache", ".", "setImage", "(", "urls", "[", "0", "]", ")", ";", "if", "(", "!", "network_result", ")", "{", "return", "\"\"", ";", "}", "return", "urls", "[", "0", "]", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "return", "\"\"", ";", "}", "@", "Override", "protected", "void", "onPostExecute", "(", "String", "url", ")", "{", "try", "{", "if", "(", "image", "!=", "null", "&&", "!", "url", ".", "equals", "(", "\"\"", ")", "&&", "tag", "!=", "null", "&", "tag", ".", "equals", "(", "image", ".", "getTag", "(", ")", ")", ")", "{", "try", "{", "Bitmap", "bmp", "=", "ImageCache", ".", "getImage", "(", "url", ")", ";", "image", ".", "setImageBitmap", "(", "bmp", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "else", "{", "Toast", ".", "makeText", "(", "getContext", "(", ")", ",", "\"-UNK-\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "dismissWaitDialog", "(", ")", ";", "FLog", ".", "d", "(", "\"thread", "\"", "+", "id", "+", "\"end.\"", ")", ";", "}", "@", "Override", "protected", "void", "onCancelled", "(", ")", "{", "FLog", ".", "d", "(", "\"\"", "+", "id", ")", ";", "}", "}", "private", "final", "SimpleOnGestureListener", "simpleOnGestureListener", "=", "new", "SimpleOnGestureListener", "(", ")", "{", "@", "Override", "public", "boolean", "onDoubleTap", "(", "MotionEvent", "event", ")", "{", "FLog", ".", "d", "(", "\"onDoubleTap\"", ")", ";", "return", "super", ".", "onDoubleTap", "(", "event", ")", ";", "}", "@", "Override", "public", "boolean", "onDoubleTapEvent", "(", "MotionEvent", "event", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "switch", "(", "event", ".", "getAction", "(", ")", ")", "{", "case", "MotionEvent", ".", "ACTION_UP", ":", "case", "MotionEvent", ".", "ACTION_POINTER_2_UP", ":", "middle", "=", "getMiddle", "(", "event", ",", "middle", ")", ";", "if", "(", "true", ")", "{", "matrix", ".", "set", "(", "moveMatrix", ")", ";", "zoomImage", "(", "1.3f", ",", "middle", ".", "x", ",", "middle", ".", "y", ")", ";", "setImageMatrix", "(", "matrix", ")", ";", "}", "break", ";", "}", "return", "super", ".", "onDoubleTapEvent", "(", "event", ")", ";", "}", "@", "Override", "public", "boolean", "onDown", "(", "MotionEvent", "event", ")", "{", "FLog", ".", "d", "(", "\"onDown\"", ")", ";", "return", "super", ".", "onDown", "(", "event", ")", ";", "}", "@", "Override", "public", "boolean", "onFling", "(", "MotionEvent", "event1", ",", "MotionEvent", "event2", ",", "float", "velocityX", ",", "float", "velocityY", ")", "{", "FLog", ".", "d", "(", "\"onFling\"", ")", ";", "return", "super", ".", "onFling", "(", "event1", ",", "event2", ",", "velocityX", ",", "velocityY", ")", ";", "}", "@", "Override", "public", "void", "onLongPress", "(", "MotionEvent", "event", ")", "{", "FLog", ".", "d", "(", "\"onLongPress\"", ")", ";", "super", ".", "onLongPress", "(", "event", ")", ";", "}", "@", "Override", "public", "boolean", "onScroll", "(", "MotionEvent", "event1", ",", "MotionEvent", "event2", ",", "float", "distanceX", ",", "float", "distanceY", ")", "{", "FLog", ".", "d", "(", "\"onScroll\"", ")", ";", "return", "super", ".", "onScroll", "(", "event1", ",", "event2", ",", "distanceX", ",", "distanceY", ")", ";", "}", "@", "Override", "public", "void", "onShowPress", "(", "MotionEvent", "event", ")", "{", "FLog", ".", "d", "(", "\"onShowPress\"", ")", ";", "super", ".", "onShowPress", "(", "event", ")", ";", "}", "@", "Override", "public", "boolean", "onSingleTapConfirmed", "(", "MotionEvent", "event", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "return", "super", ".", "onSingleTapConfirmed", "(", "event", ")", ";", "}", "@", "Override", "public", "boolean", "onSingleTapUp", "(", "MotionEvent", "event", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "return", "super", ".", "onSingleTapUp", "(", "event", ")", ";", "}", "}", ";", "}", "</s>" ]
8,260
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ".", "R", ".", "id", ";", "import", "android", ".", "app", ".", "Activity", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "view", ".", "KeyEvent", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "view", ".", "Window", ";", "import", "android", ".", "view", ".", "WindowManager", ";", "import", "android", ".", "view", ".", "WindowManager", ".", "LayoutParams", ";", "import", "android", ".", "view", ".", "inputmethod", ".", "InputMethodManager", ";", "import", "android", ".", "widget", ".", "EditText", ";", "import", "android", ".", "widget", ".", "ListView", ";", "import", "android", ".", "widget", ".", "Toast", ";", "public", "class", "FocusEdit", "extends", "Activity", "{", "ArrayList", "<", "String", ">", "words", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "FocusEditAdapter", "adapter", ";", "@", "Override", "public", "void", "onCreate", "(", "Bundle", "savedInstanceState", ")", "{", "super", ".", "onCreate", "(", "savedInstanceState", ")", ";", "if", "(", "getResources", "(", ")", ".", "getBoolean", "(", "R", ".", "bool", ".", "avoidsleep", ")", ")", "{", "Window", "window", "=", "getWindow", "(", ")", ";", "window", ".", "addFlags", "(", "WindowManager", ".", "LayoutParams", ".", "FLAG_KEEP_SCREEN_ON", ")", ";", "}", "this", ".", "getWindow", "(", ")", ".", "setSoftInputMode", "(", "LayoutParams", ".", "SOFT_INPUT_STATE_ALWAYS_HIDDEN", ")", ";", "setContentView", "(", "R", ".", "layout", ".", "focuswords", ")", ";", "ListView", "listView", "=", "(", "ListView", ")", "findViewById", "(", "id", ".", "listview", ")", ";", "EditText", "text_e", "=", "(", "EditText", ")", "findViewById", "(", "id", ".", "newword", ")", ";", "text_e", ".", "setOnKeyListener", "(", "new", "View", ".", "OnKeyListener", "(", ")", "{", "public", "boolean", "onKey", "(", "View", "v", ",", "int", "keyCode", ",", "KeyEvent", "event", ")", "{", "if", "(", "event", ".", "getAction", "(", ")", "==", "KeyEvent", ".", "ACTION_DOWN", "&&", "keyCode", "==", "KeyEvent", ".", "KEYCODE_ENTER", ")", "{", "return", "true", ";", "}", "if", "(", "event", ".", "getAction", "(", ")", "==", "KeyEvent", ".", "ACTION_UP", "&&", "keyCode", "==", "KeyEvent", ".", "KEYCODE_ENTER", ")", "{", "FocusEdit", "activity", "=", "(", "FocusEdit", ")", "v", ".", "getContext", "(", ")", ";", "activity", ".", "onClickRegNewWordButton", "(", "v", ")", ";", "return", "false", ";", "}", "return", "false", ";", "}", "}", ")", ";", "try", "{", "words", "=", "FocusedSettings", ".", "get", "(", "this", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "adapter", "=", "new", "FocusEditAdapter", "(", "this", ",", "R", ".", "layout", ".", "focuswords_row", ",", "words", ")", ";", "listView", ".", "setAdapter", "(", "adapter", ")", ";", "setTitle", "(", "\"-UNK-\"", "+", "\"", "-", "\"", "+", "getString", "(", "R", ".", "string", ".", "app_name", ")", ")", ";", "}", "public", "void", "onClickRegNewWordButton", "(", "View", "v", ")", "{", "EditText", "text_e", "=", "(", "EditText", ")", "findViewById", "(", "id", ".", "newword", ")", ";", "String", "text", "=", "text_e", ".", "getText", "(", ")", ".", "toString", "(", ")", ";", "try", "{", "StringUtil", ".", "validateFocusWord", "(", "text", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "e", ".", "getMessage", "(", ")", ")", ";", "if", "(", "e", ".", "getMessage", "(", ")", ".", "equals", "(", "\"noword\"", ")", ")", "{", "}", "else", "if", "(", "e", ".", "getMessage", "(", ")", ".", "equals", "(", "\"toolongword\"", ")", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "\"\"", ",", "Toast", ".", "LENGTH_LONG", ")", ".", "show", "(", ")", ";", "}", "else", "if", "(", "e", ".", "getMessage", "(", ")", ".", "equals", "(", "\"spaces_exist\"", ")", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "\"\"", ",", "Toast", ".", "LENGTH_LONG", ")", ".", "show", "(", ")", ";", "}", "else", "if", "(", "e", ".", "getMessage", "(", ")", ".", "equals", "(", "\"\"", ")", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "\"\"", ",", "Toast", ".", "LENGTH_LONG", ")", ".", "show", "(", ")", ";", "}", "else", "{", "Toast", ".", "makeText", "(", "this", ",", "\"-UNK-\"", ",", "Toast", ".", "LENGTH_LONG", ")", ".", "show", "(", ")", ";", "}", "return", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "adapter", ".", "items", ".", "size", "(", ")", ";", "++", "i", ")", "{", "if", "(", "adapter", ".", "items", ".", "get", "(", "i", ")", ".", "equals", "(", "text", ")", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "\"\"", ",", "Toast", ".", "LENGTH_LONG", ")", ".", "show", "(", ")", ";", "return", ";", "}", "}", "adapter", ".", "addLast", "(", "text", ")", ";", "text_e", ".", "setText", "(", "\"\"", ")", ";", "Toast", ".", "makeText", "(", "this", ",", "\"-UNK-\"", "+", "text", "+", "\"\"", ",", "Toast", ".", "LENGTH_LONG", ")", ".", "show", "(", ")", ";", "}", "}", "</s>" ]
8,261
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Calendar", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "Comparator", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "SharedPreferences", ";", "import", "android", ".", "graphics", ".", "Bitmap", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "media", ".", "MediaScannerConnection", ";", "import", "android", ".", "os", ".", "Environment", ";", "import", "android", ".", "os", ".", "StatFs", ";", "import", "android", ".", "preference", ".", "PreferenceManager", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "BufferedOutputStream", ";", "import", "java", ".", "io", ".", "FileNotFoundException", ";", "import", "java", ".", "io", ".", "FileOutputStream", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "ObjectOutputStream", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "ObjectInputStream", ";", "import", "java", ".", "net", ".", "HttpURLConnection", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "android", ".", "graphics", ".", "BitmapFactory", ";", "public", "class", "SDCard", "{", "public", "static", "String", "cacheDir", "=", "null", ";", "public", "static", "String", "saveDir", "=", "null", ";", "public", "static", "boolean", "isSDCardMounted", "(", ")", "{", "FLog", ".", "d", "(", "\"mount=\"", "+", "Environment", ".", "getExternalStorageState", "(", ")", ")", ";", "return", "Environment", ".", "getExternalStorageState", "(", ")", ".", "equals", "(", "Environment", ".", "MEDIA_MOUNTED", ")", ";", "}", "public", "static", "boolean", "setAntiCacheDir", "(", "Context", "context", ")", "{", "try", "{", "SharedPreferences", "preferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "context", ")", ";", "Boolean", "innerCache", "=", "preferences", ".", "getBoolean", "(", "\"innerCache\"", ",", "false", ")", ";", "if", "(", "!", "innerCache", ")", "{", "cacheDir", "=", "context", ".", "getFilesDir", "(", ")", ".", "getPath", "(", ")", ";", "}", "else", "{", "cacheDir", "=", "null", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}", "public", "static", "boolean", "setCacheDir", "(", "Context", "context", ")", "{", "try", "{", "SharedPreferences", "preferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "context", ")", ";", "Boolean", "innerCache", "=", "preferences", ".", "getBoolean", "(", "\"innerCache\"", ",", "false", ")", ";", "if", "(", "innerCache", ")", "{", "cacheDir", "=", "context", ".", "getFilesDir", "(", ")", ".", "getPath", "(", ")", ";", "}", "else", "{", "cacheDir", "=", "null", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}", "public", "static", "void", "copyCacheSetting", "(", "Context", "context", ")", "{", "setAntiCacheDir", "(", "context", ")", ";", "File", "fbin", "=", "new", "File", "(", "getCacheDir", "(", ")", "+", "\"bin/\"", ")", ";", "fbin", ".", "mkdir", "(", ")", ";", "String", "newFile", "=", "getCacheDir", "(", ")", "+", "\"\"", ";", "setCacheDir", "(", "context", ")", ";", "fbin", "=", "new", "File", "(", "getCacheDir", "(", ")", "+", "\"bin/\"", ")", ";", "fbin", ".", "mkdir", "(", ")", ";", "String", "oldFile", "=", "getCacheDir", "(", ")", "+", "\"\"", ";", "FLog", ".", "d", "(", "\"copy", "file:\"", "+", "oldFile", "+", "\"", "->", "\"", "+", "newFile", ")", ";", "InputStream", "input", "=", "null", ";", "OutputStream", "output", "=", "null", ";", "File", "dstFile", "=", "new", "File", "(", "newFile", ")", ";", "try", "{", "input", "=", "new", "FileInputStream", "(", "new", "File", "(", "oldFile", ")", ")", ";", "output", "=", "new", "FileOutputStream", "(", "dstFile", ")", ";", "int", "DEFAULT_BUFFER_SIZE", "=", "1024", "*", "4", ";", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "DEFAULT_BUFFER_SIZE", "]", ";", "int", "n", "=", "0", ";", "while", "(", "-", "1", "!=", "(", "n", "=", "input", ".", "read", "(", "buffer", ")", ")", ")", "{", "output", ".", "write", "(", "buffer", ",", "0", ",", "n", ")", ";", "}", "input", ".", "close", "(", ")", ";", "output", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "public", "static", "boolean", "setSaveDir", "(", "Context", "context", ")", "{", "try", "{", "SharedPreferences", "preferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "context", ")", ";", "saveDir", "=", "preferences", ".", "getString", "(", "\"saveDir\"", ",", "null", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}", "public", "static", "String", "getBaseDir", "(", ")", "{", "String", "sdcard_dir", "=", "Environment", ".", "getExternalStorageDirectory", "(", ")", ".", "getPath", "(", ")", ";", "return", "sdcard_dir", ";", "}", "public", "static", "boolean", "isUsableDirectory", "(", "File", "file", ")", "{", "return", "file", ".", "exists", "(", ")", "&&", "file", ".", "isDirectory", "(", ")", "&&", "file", ".", "canWrite", "(", ")", ";", "}", "public", "static", "String", "getCacheDir", "(", ")", "{", "String", "base_dir", "=", "getBaseDir", "(", ")", "+", "\"/.ftbtcache/\"", ";", "if", "(", "cacheDir", "!=", "null", ")", "{", "base_dir", "=", "cacheDir", "+", "\"/\"", ";", "}", "String", "cacheDir", "=", "base_dir", ";", "File", "file", "=", "new", "File", "(", "cacheDir", ")", ";", "file", ".", "mkdir", "(", ")", ";", "if", "(", "!", "isUsableDirectory", "(", "file", ")", ")", "{", "return", "null", ";", "}", "return", "cacheDir", ";", "}", "public", "static", "String", "getSaveDir", "(", ")", "{", "String", "base_dir", "=", "getBaseDir", "(", ")", "+", "\"/-UNK-/\"", ";", "if", "(", "saveDir", "!=", "null", ")", "{", "base_dir", "=", "saveDir", "+", "\"/\"", ";", "}", "FLog", ".", "d", "(", "\"base_dir=\"", "+", "base_dir", ")", ";", "String", "saveDir", "=", "base_dir", ";", "File", "file", "=", "new", "File", "(", "saveDir", ")", ";", "file", ".", "mkdir", "(", ")", ";", "if", "(", "!", "isUsableDirectory", "(", "file", ")", ")", "{", "return", "null", ";", "}", "return", "saveDir", ";", "}", "public", "static", "String", "getThreadDir", "(", "String", "threadName", ")", "{", "String", "saveDir", "=", "getSaveDir", "(", ")", ";", "String", "threadDir", "=", "saveDir", "+", "threadName", "+", "\"/\"", ";", "File", "file", "=", "new", "File", "(", "threadDir", ")", ";", "file", ".", "mkdir", "(", ")", ";", "return", "threadDir", ";", "}", "public", "static", "String", "getSeriarizedDir", "(", ")", "{", "String", "cacheDir", "=", "getCacheDir", "(", ")", ";", "String", "seriarizedDir", "=", "cacheDir", "+", "\"bin/\"", ";", "File", "file", "=", "new", "File", "(", "seriarizedDir", ")", ";", "file", ".", "mkdir", "(", ")", ";", "return", "seriarizedDir", ";", "}", "public", "static", "void", "saveBin", "(", "String", "name", ",", "byte", "[", "]", "bytes", ",", "boolean", "isCache", ")", "{", "String", "filename", ";", "if", "(", "!", "isCache", ")", "{", "filename", "=", "getSaveDir", "(", ")", "+", "name", ";", "}", "else", "{", "filename", "=", "getCacheDir", "(", ")", "+", "name", ";", "}", "FLog", ".", "d", "(", "\"length=\"", "+", "bytes", ".", "length", ")", ";", "File", "file", "=", "new", "File", "(", "filename", ")", ";", "FLog", ".", "d", "(", "filename", ")", ";", "file", ".", "getParentFile", "(", ")", ".", "mkdir", "(", ")", ";", "try", "{", "BufferedOutputStream", "fos", "=", "new", "BufferedOutputStream", "(", "new", "FileOutputStream", "(", "file", ")", ")", ";", "fos", ".", "write", "(", "bytes", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"\"", "+", "name", ")", ";", "}", "}", "public", "static", "void", "saveFromURL", "(", "String", "name", ",", "URL", "url", ",", "boolean", "isCache", ")", "throws", "IOException", "{", "try", "{", "String", "filename", ";", "if", "(", "!", "isCache", ")", "{", "filename", "=", "getSaveDir", "(", ")", "+", "name", ";", "}", "else", "{", "filename", "=", "getCacheDir", "(", ")", "+", "name", ";", "}", "HttpURLConnection", "conn", "=", "(", "HttpURLConnection", ")", "url", ".", "openConnection", "(", ")", ";", "if", "(", "!", "String", ".", "valueOf", "(", "conn", ".", "getResponseCode", "(", ")", ")", ".", "startsWith", "(", "\"2\"", ")", ")", "{", "throw", "new", "IOException", "(", "\"\"", "+", "conn", ".", "getResponseCode", "(", ")", ")", ";", "}", "FLog", ".", "d", "(", "\"\"", "+", "conn", ".", "getResponseCode", "(", ")", ")", ";", "InputStream", "is", "=", "conn", ".", "getInputStream", "(", ")", ";", "File", "file", "=", "new", "File", "(", "filename", ")", ";", "file", ".", "getParentFile", "(", ")", ".", "mkdir", "(", ")", ";", "OutputStream", "fos", "=", "new", "FileOutputStream", "(", "filename", ")", ";", "byte", "[", "]", "buf", "=", "new", "byte", "[", "1024", "]", ";", "int", "len", "=", "0", ";", "while", "(", "(", "len", "=", "is", ".", "read", "(", "buf", ")", ")", ">", "0", ")", "{", "fos", ".", "write", "(", "buf", ",", "0", ",", "len", ")", ";", "}", "fos", ".", "flush", "(", ")", ";", "is", ".", "close", "(", ")", ";", "fos", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "IOException", "(", "e", ".", "toString", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"\"", "+", "name", ")", ";", "}", "}", "public", "static", "String", "loadTextCache", "(", "String", "name", ")", "throws", "IOException", "{", "String", "sdcard_dir", "=", "Environment", ".", "getExternalStorageDirectory", "(", ")", ".", "getPath", "(", ")", ";", "String", "filename", "=", "getCacheDir", "(", ")", "+", "name", ";", "File", "file", "=", "new", "File", "(", "filename", ")", ";", "return", "FileToString", ".", "fileToString", "(", "file", ",", "\"Shift-JIS\"", ")", ";", "}", "public", "static", "Bitmap", "loadBitmapCache", "(", "String", "name", ")", "{", "String", "sdcard_dir", "=", "Environment", ".", "getExternalStorageDirectory", "(", ")", ".", "getPath", "(", ")", ";", "String", "filename", "=", "getCacheDir", "(", ")", "+", "name", ";", "File", "file", "=", "new", "File", "(", "filename", ")", ";", "return", "BitmapFactory", ".", "decodeFile", "(", "filename", ")", ";", "}", "public", "static", "boolean", "cacheExist", "(", "String", "name", ")", "{", "String", "sdcard_dir", "=", "Environment", ".", "getExternalStorageDirectory", "(", ")", ".", "getPath", "(", ")", ";", "String", "filename", "=", "getCacheDir", "(", ")", "+", "name", ";", "File", "file", "=", "new", "File", "(", "filename", ")", ";", "return", "file", ".", "exists", "(", ")", ";", "}", "public", "static", "File", "copyCacheToFile", "(", "String", "urlhash", ",", "String", "url", ")", "throws", "IOException", "{", "String", "srcfilename", "=", "getCacheDir", "(", ")", "+", "urlhash", ";", "String", "dstfilename", "=", "getSaveDir", "(", ")", "+", "url", ";", "InputStream", "input", "=", "null", ";", "OutputStream", "output", "=", "null", ";", "File", "dstFile", "=", "new", "File", "(", "dstfilename", ")", ";", "input", "=", "new", "FileInputStream", "(", "new", "File", "(", "srcfilename", ")", ")", ";", "output", "=", "new", "FileOutputStream", "(", "dstFile", ")", ";", "int", "DEFAULT_BUFFER_SIZE", "=", "1024", "*", "4", ";", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "DEFAULT_BUFFER_SIZE", "]", ";", "int", "n", "=", "0", ";", "while", "(", "-", "1", "!=", "(", "n", "=", "input", ".", "read", "(", "buffer", ")", ")", ")", "{", "output", ".", "write", "(", "buffer", ",", "0", ",", "n", ")", ";", "}", "input", ".", "close", "(", ")", ";", "output", ".", "close", "(", ")", ";", "return", "dstFile", ";", "}", "public", "static", "boolean", "savedImageToThreadExist", "(", "String", "fileName", ",", "String", "threadName", ")", "{", "String", "dstfilename", "=", "getThreadDir", "(", "threadName", ")", "+", "fileName", ";", "File", "file", "=", "new", "File", "(", "dstfilename", ")", ";", "return", "file", ".", "exists", "(", ")", ";", "}", "public", "static", "File", "copyCacheToThreadFile", "(", "String", "urlhash", ",", "String", "url", ",", "String", "threadName", ")", "throws", "IOException", "{", "String", "srcfilename", "=", "getCacheDir", "(", ")", "+", "urlhash", ";", "String", "dstfilename", "=", "getThreadDir", "(", "threadName", ")", "+", "url", ";", "InputStream", "input", "=", "null", ";", "OutputStream", "output", "=", "null", ";", "File", "dstFile", "=", "new", "File", "(", "dstfilename", ")", ";", "input", "=", "new", "FileInputStream", "(", "new", "File", "(", "srcfilename", ")", ")", ";", "output", "=", "new", "FileOutputStream", "(", "dstFile", ")", ";", "int", "DEFAULT_BUFFER_SIZE", "=", "1024", "*", "4", ";", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "DEFAULT_BUFFER_SIZE", "]", ";", "int", "n", "=", "0", ";", "while", "(", "-", "1", "!=", "(", "n", "=", "input", ".", "read", "(", "buffer", ")", ")", ")", "{", "output", ".", "write", "(", "buffer", ",", "0", ",", "n", ")", ";", "}", "input", ".", "close", "(", ")", ";", "output", ".", "close", "(", ")", ";", "return", "dstFile", ";", "}", "static", "Comparator", "comparator", "=", "new", "Comparator", "(", ")", "{", "public", "int", "compare", "(", "Object", "o1", ",", "Object", "o2", ")", "{", "final", "long", "additional_days", "=", "3", "*", "24", "*", "3600", "*", "1000", ";", "File", "f1", "=", "(", "File", ")", "o1", ";", "File", "f2", "=", "(", "File", ")", "o2", ";", "long", "f1_lastmodified", "=", "f1", ".", "lastModified", "(", ")", ";", "if", "(", "FutabaCrypt", ".", "isHTMLName", "(", "f1", ".", "toString", "(", ")", ")", ")", "{", "f1_lastmodified", "+=", "additional_days", ";", "}", "long", "f2_lastmodified", "=", "f2", ".", "lastModified", "(", ")", ";", "if", "(", "FutabaCrypt", ".", "isHTMLName", "(", "f2", ".", "toString", "(", ")", ")", ")", "{", "f2_lastmodified", "+=", "additional_days", ";", "}", "return", "(", "int", ")", "(", "f2_lastmodified", "-", "f1_lastmodified", ")", ";", "}", "}", ";", "public", "static", "void", "limitCache", "(", "int", "num", ")", "{", "File", "cache_dir", "=", "new", "File", "(", "getCacheDir", "(", ")", ")", ";", "File", "[", "]", "files", "=", "cache_dir", ".", "listFiles", "(", ")", ";", "ArrayList", "list", "=", "new", "ArrayList", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "files", ".", "length", ";", "i", "++", ")", "{", "list", ".", "add", "(", "files", "[", "i", "]", ")", ";", "}", "Collections", ".", "sort", "(", "list", ",", "comparator", ")", ";", "int", "sizeSum", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "list", ".", "size", "(", ")", ";", "i", "++", ")", "{", "File", "f", "=", "(", "File", ")", "list", ".", "get", "(", "i", ")", ";", "FLog", ".", "d", "(", "f", ".", "toString", "(", ")", "+", "\"\"", "+", "f", ".", "lastModified", "(", ")", ")", ";", "if", "(", "f", ".", "isDirectory", "(", ")", ")", "{", "}", "else", "{", "sizeSum", "+=", "f", ".", "length", "(", ")", ";", "if", "(", "sizeSum", ">", "num", "*", "1000000", ")", "{", "f", ".", "delete", "(", ")", ";", "FLog", ".", "d", "(", "\"\"", "+", "f", ".", "getName", "(", ")", ")", ";", "}", "}", "}", "}", "static", "private", "void", "deleteDir", "(", "File", "f", ")", "{", "if", "(", "f", ".", "exists", "(", ")", "==", "false", ")", "{", "return", ";", "}", "if", "(", "f", ".", "isFile", "(", ")", ")", "{", "f", ".", "delete", "(", ")", ";", "}", "if", "(", "f", ".", "isDirectory", "(", ")", ")", "{", "File", "[", "]", "files", "=", "f", ".", "listFiles", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "files", ".", "length", ";", "i", "++", ")", "{", "deleteDir", "(", "files", "[", "i", "]", ")", ";", "}", "f", ".", "delete", "(", ")", ";", "}", "}", "static", "private", "String", "toCalendarString", "(", "File", "f", ")", "{", "Calendar", "cal", "=", "Calendar", ".", "getInstance", "(", ")", ";", "cal", ".", "setTimeInMillis", "(", "f", ".", "lastModified", "(", ")", ")", ";", "int", "y", "=", "cal", ".", "get", "(", "Calendar", ".", "YEAR", ")", ";", "int", "m", "=", "cal", ".", "get", "(", "Calendar", ".", "MONTH", ")", ";", "int", "day", "=", "cal", ".", "get", "(", "Calendar", ".", "DAY_OF_MONTH", ")", ";", "return", "String", ".", "valueOf", "(", "y", ")", "+", "\"-\"", "+", "String", ".", "valueOf", "(", "m", "+", "1", ")", "+", "\"-\"", "+", "String", ".", "valueOf", "(", "day", ")", ";", "}", "public", "static", "boolean", "existSeriarized", "(", "String", "name", ")", "{", "String", "filename", "=", "getCacheDir", "(", ")", "+", "\"bin/\"", "+", "name", ";", "File", "file", "=", "new", "File", "(", "filename", ")", ";", "return", "file", ".", "exists", "(", ")", ";", "}", "static", "public", "ObjectInputStream", "getSerialized", "(", "String", "name", ")", "throws", "IOException", "{", "String", "filename", "=", "getSeriarizedDir", "(", ")", "+", "name", ";", "File", "file", "=", "new", "File", "(", "filename", ")", ";", "file", ".", "getParentFile", "(", ")", ".", "mkdir", "(", ")", ";", "FileInputStream", "inFile", "=", "new", "FileInputStream", "(", "filename", ")", ";", "ObjectInputStream", "inObject", "=", "new", "ObjectInputStream", "(", "inFile", ")", ";", "return", "inObject", ";", "}", "static", "public", "void", "setSerialized", "(", "String", "name", ",", "Object", "object", ")", "throws", "IOException", "{", "String", "filename", "=", "getSeriarizedDir", "(", ")", "+", "name", ";", "FileOutputStream", "outFile", "=", "new", "FileOutputStream", "(", "filename", ")", ";", "File", "file", "=", "new", "File", "(", "filename", ")", ";", "file", ".", "getParentFile", "(", ")", ".", "mkdir", "(", ")", ";", "ObjectOutputStream", "outObject", "=", "new", "ObjectOutputStream", "(", "outFile", ")", ";", "outObject", ".", "writeObject", "(", "object", ")", ";", "}", "public", "static", "boolean", "isMountedExSD", "(", ")", "{", "return", "Environment", ".", "MEDIA_MOUNTED", ".", "equals", "(", "Environment", ".", "MEDIA_MOUNTED", ")", ";", "}", "}", "</s>" ]
8,262
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "io", ".", "File", ";", "import", "android", ".", "app", ".", "AlertDialog", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "DialogInterface", ";", "import", "android", ".", "content", ".", "SharedPreferences", ";", "import", "android", ".", "os", ".", "Environment", ";", "import", "android", ".", "preference", ".", "DialogPreference", ";", "import", "android", ".", "util", ".", "AttributeSet", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "widget", ".", "Toast", ";", "import", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ".", "DirectorySelectDialog", ".", "onDirectoryListDialogListener", ";", "public", "class", "DirectorySelectDialogPreference", "extends", "DialogPreference", "implements", "DirectorySelectDialog", ".", "onDirectoryListDialogListener", "{", "DirectorySelectDialog", "dlg", ";", "onDirectoryListDialogListener", "listener", ";", "public", "DirectorySelectDialogPreference", "(", "Context", "context", ",", "AttributeSet", "attrs", ")", "{", "super", "(", "context", ",", "attrs", ")", ";", "}", "@", "Override", "protected", "void", "onBindView", "(", "View", "view", ")", "{", "SharedPreferences", "pref", "=", "getSharedPreferences", "(", ")", ";", "super", ".", "onBindView", "(", "view", ")", ";", "}", "@", "Override", "protected", "void", "onClick", "(", ")", "{", "File", "externalStorage", "=", "new", "File", "(", "\"/\"", ")", ";", "dlg", "=", "new", "DirectorySelectDialog", "(", "getContext", "(", ")", ")", ";", "dlg", ".", "setOnFileListDialogListener", "(", "(", "onDirectoryListDialogListener", ")", "this", ")", ";", "dlg", ".", "show", "(", "externalStorage", ".", "getAbsolutePath", "(", ")", ",", "externalStorage", ".", "getPath", "(", ")", ")", ";", "}", "public", "void", "addListener", "(", "onDirectoryListDialogListener", "listener", ")", "{", "this", ".", "listener", "=", "listener", ";", "}", "public", "void", "changePreference", "(", "String", "path", ")", "{", "SharedPreferences", ".", "Editor", "editor", "=", "getEditor", "(", ")", ";", "editor", ".", "putString", "(", "getKey", "(", ")", ",", "path", ")", ";", "FLog", ".", "d", "(", "\"getkey=\"", "+", "getKey", "(", ")", "+", "\"", "path=\"", "+", "path", ")", ";", "editor", ".", "commit", "(", ")", ";", "notifyChanged", "(", ")", ";", "Toast", ".", "makeText", "(", "getContext", "(", ")", ",", "\"-UNK-\\\"\"", "+", "path", "+", "\"\\\"-UNK-\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "if", "(", "this", ".", "listener", "!=", "null", ")", "{", "this", ".", "listener", ".", "onClickFileList", "(", "path", ")", ";", "}", "}", "public", "void", "onClickFileList", "(", "String", "path", ")", "{", "if", "(", "null", "!=", "path", ")", "{", "if", "(", "!", "SDCard", ".", "isUsableDirectory", "(", "new", "File", "(", "path", ")", ")", ")", "{", "Toast", ".", "makeText", "(", "getContext", "(", ")", ",", "\"-UNK-\\\"\"", "+", "path", "+", "\"\"", ",", "Toast", ".", "LENGTH_LONG", ")", ".", "show", "(", ")", ";", "FLog", ".", "d", "(", "\"\"", ")", ";", "return", ";", "}", "else", "{", "final", "String", "path_f", "=", "path", ";", "AlertDialog", ".", "Builder", "builder", "=", "new", "AlertDialog", ".", "Builder", "(", "getContext", "(", ")", ")", ";", "builder", ".", "setMessage", "(", "\"\"", "+", "\"\"", ")", ".", "setCancelable", "(", "true", ")", ".", "setPositiveButton", "(", "\"OK\"", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "id", ")", "{", "changePreference", "(", "path_f", ")", ";", "}", "}", ")", ".", "setNegativeButton", "(", "\"-UNK-\"", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "id", ")", "{", "dialog", ".", "cancel", "(", ")", ";", "}", "}", ")", ";", "builder", ".", "create", "(", ")", ".", "show", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
8,263
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "Comparator", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "LinkedHashMap", ";", "import", "java", ".", "util", ".", "TreeMap", ";", "import", "android", ".", "app", ".", "Activity", ";", "import", "android", ".", "content", ".", "SharedPreferences", ";", "import", "android", ".", "graphics", ".", "Bitmap", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "preference", ".", "PreferenceManager", ";", "import", "android", ".", "util", ".", "Log", ";", "public", "class", "HistoryManager", "{", "private", "final", "String", "OPT_HISTORY", "=", "\"history\"", ";", "private", "LinkedHashMap", "<", "Integer", ",", "FutabaThreadContent", ">", "threads", "=", "new", "LinkedHashMap", "<", "Integer", ",", "FutabaThreadContent", ">", "(", ")", ";", "public", "void", "clear", "(", ")", "{", "threads", "=", "new", "LinkedHashMap", "<", "Integer", ",", "FutabaThreadContent", ">", "(", ")", ";", "}", "public", "FutabaThreadContent", "get", "(", "int", "threadNum", ")", "throws", "Exception", "{", "if", "(", "!", "threads", ".", "containsKey", "(", "threadNum", ")", ")", "{", "throw", "new", "Exception", "(", "\"Thread", "\"", "+", "threadNum", "+", "\"not", "found\"", ")", ";", "}", "return", "threads", ".", "get", "(", "threadNum", ")", ";", "}", "public", "boolean", "exist", "(", "int", "threadNum", ")", "{", "return", "threads", ".", "containsKey", "(", "threadNum", ")", ";", "}", "public", "int", "size", "(", ")", "{", "return", "threads", ".", "size", "(", ")", ";", "}", "public", "void", "addThread", "(", "FutabaThreadContent", "thread", ",", "int", "maxHistoryNum", ")", "{", "FLog", ".", "d", "(", "\"addThread\"", "+", "thread", ".", "threadNum", ")", ";", "if", "(", "!", "threads", ".", "containsKey", "(", "thread", ".", "threadNum", ")", ")", "{", "threads", ".", "put", "(", "thread", ".", "threadNum", ",", "thread", ")", ";", "}", "else", "{", "FutabaThreadContent", "currentThread", "=", "threads", ".", "get", "(", "thread", ".", "threadNum", ")", ";", "thread", ".", "pointAt", "=", "currentThread", ".", "pointAt", ";", "thread", ".", "seeAt", "=", "currentThread", ".", "seeAt", ";", "threads", ".", "remove", "(", "thread", ".", "threadNum", ")", ";", "threads", ".", "put", "(", "thread", ".", "threadNum", ",", "thread", ")", ";", "}", "FLog", ".", "d", "(", "\"\"", "+", "maxHistoryNum", ")", ";", "if", "(", "threads", ".", "size", "(", ")", ">", "maxHistoryNum", ")", "{", "for", "(", "Object", "key", ":", "threads", ".", "keySet", "(", ")", ")", "{", "threads", ".", "remove", "(", "key", ")", ";", "break", ";", "}", "}", "}", "public", "void", "updateThread", "(", "FutabaThreadContent", "thread_a", ")", "throws", "Exception", "{", "if", "(", "!", "threads", ".", "containsKey", "(", "thread_a", ".", "threadNum", ")", ")", "{", "throw", "new", "Exception", "(", "\"\"", ")", ";", "}", "else", "{", "FutabaThreadContent", "thread", "=", "threads", ".", "get", "(", "thread_a", ".", "threadNum", ")", ";", "if", "(", "Integer", ".", "parseInt", "(", "thread_a", ".", "resNum", ")", "!=", "0", ")", "{", "thread", ".", "resNum", "=", "thread_a", ".", "resNum", ";", "}", "if", "(", "thread_a", ".", "pointAt", "!=", "0", ")", "{", "thread", ".", "pointAt", "=", "thread_a", ".", "pointAt", ";", "}", "if", "(", "thread_a", ".", "seeAt", "!=", "0", ")", "{", "FLog", ".", "d", "(", "\"\"", "+", "thread_a", ".", "seeAt", ")", ";", "thread", ".", "seeAt", "=", "thread_a", ".", "seeAt", ";", "}", "threads", ".", "put", "(", "thread", ".", "threadNum", ",", "thread", ")", ";", "}", "}", "public", "void", "updateThreadRemoveShiori", "(", "FutabaThreadContent", "thread_a", ")", "throws", "Exception", "{", "if", "(", "!", "threads", ".", "containsKey", "(", "thread_a", ".", "threadNum", ")", ")", "{", "throw", "new", "Exception", "(", "\"\"", ")", ";", "}", "else", "{", "FutabaThreadContent", "thread", "=", "threads", ".", "get", "(", "thread_a", ".", "threadNum", ")", ";", "thread", ".", "pointAt", "=", "0", ";", "threads", ".", "put", "(", "thread", ".", "threadNum", ",", "thread", ")", ";", "}", "}", "public", "void", "removeThread", "(", "FutabaThreadContent", "thread", ")", "{", "if", "(", "threads", ".", "containsKey", "(", "thread", ".", "threadNum", ")", ")", "{", "threads", ".", "remove", "(", "thread", ".", "threadNum", ")", ";", "}", "else", "{", "}", "}", "public", "boolean", "Save", "(", ")", "{", "try", "{", "SDCard", ".", "setSerialized", "(", "OPT_HISTORY", ",", "threads", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}", "public", "void", "Load", "(", ")", "{", "try", "{", "if", "(", "SDCard", ".", "existSeriarized", "(", "OPT_HISTORY", ")", ")", "{", "threads", "=", "(", "LinkedHashMap", "<", "Integer", ",", "FutabaThreadContent", ">", ")", "SDCard", ".", "getSerialized", "(", "OPT_HISTORY", ")", ".", "readObject", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "public", "void", "set", "(", "ArrayList", "<", "FutabaThreadContent", ">", "threads_array", ")", "{", "clear", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "threads_array", ".", "size", "(", ")", ";", "++", "i", ")", "{", "addThread", "(", "threads_array", ".", "get", "(", "i", ")", ",", "10000", ")", ";", "}", "}", "public", "ArrayList", "<", "FutabaThreadContent", ">", "getThreadsArray", "(", ")", "{", "ArrayList", "<", "FutabaThreadContent", ">", "threads_array", "=", "new", "ArrayList", "<", "FutabaThreadContent", ">", "(", ")", ";", "Iterator", "it", "=", "threads", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "threads_array", ".", "add", "(", "threads", ".", "get", "(", "it", ".", "next", "(", ")", ")", ")", ";", "}", "ArrayList", "<", "FutabaThreadContent", ">", "threads_array_rev", "=", "new", "ArrayList", "<", "FutabaThreadContent", ">", "(", ")", ";", "for", "(", "int", "i", "=", "threads_array", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "--", "i", ")", "{", "threads_array_rev", ".", "add", "(", "threads_array", ".", "get", "(", "i", ")", ")", ";", "}", "return", "threads_array_rev", ";", "}", "static", "Comparator", "comparator", "=", "new", "Comparator", "(", ")", "{", "public", "int", "compare", "(", "Object", "o1", ",", "Object", "o2", ")", "{", "FutabaThreadContent", "f1", "=", "(", "FutabaThreadContent", ")", "o1", ";", "FutabaThreadContent", "f2", "=", "(", "FutabaThreadContent", ")", "o2", ";", "return", "(", "int", ")", "(", "f2", ".", "lastAccessed", "-", "f1", ".", "lastAccessed", ")", ";", "}", "}", ";", "}", "</s>" ]
8,264
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "net", ".", "HttpURLConnection", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ".", "FutabaThreadAdapter", ".", "ImageGetTask", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "graphics", ".", "Bitmap", ";", "import", "android", ".", "graphics", ".", "Matrix", ";", "import", "android", ".", "os", ".", "AsyncTask", ";", "import", "android", ".", "view", ".", "Display", ";", "import", "android", ".", "view", ".", "LayoutInflater", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "view", ".", "ViewGroup", ";", "import", "android", ".", "view", ".", "WindowManager", ";", "import", "android", ".", "widget", ".", "ArrayAdapter", ";", "import", "android", ".", "widget", ".", "ImageView", ";", "import", "android", ".", "widget", ".", "TextView", ";", "import", "android", ".", "widget", ".", "ImageView", ".", "ScaleType", ";", "public", "class", "ThumbGridAdapter", "extends", "ArrayAdapter", "{", "ArrayList", "<", "String", ">", "urls", ";", "private", "LayoutInflater", "inflater", ";", "private", "int", "width", ";", "private", "int", "height", ";", "private", "int", "itemSize", ";", "public", "ThumbGridAdapter", "(", "Context", "context", ",", "int", "textViewResourceId", ",", "ArrayList", "items", ")", "{", "super", "(", "context", ",", "textViewResourceId", ",", "items", ")", ";", "this", ".", "urls", "=", "items", ";", "this", ".", "inflater", "=", "(", "LayoutInflater", ")", "context", ".", "getSystemService", "(", "Context", ".", "LAYOUT_INFLATER_SERVICE", ")", ";", "WindowManager", "wm", "=", "(", "(", "WindowManager", ")", "context", ".", "getSystemService", "(", "Context", ".", "WINDOW_SERVICE", ")", ")", ";", "Display", "display", "=", "wm", ".", "getDefaultDisplay", "(", ")", ";", "width", "=", "display", ".", "getWidth", "(", ")", ";", "height", "=", "display", ".", "getHeight", "(", ")", ";", "itemSize", "=", "width", "/", "3", "-", "10", ";", "}", "@", "Override", "public", "View", "getView", "(", "int", "position", ",", "View", "convertView", ",", "ViewGroup", "parent", ")", "{", "View", "view", "=", "convertView", ";", "try", "{", "if", "(", "view", "==", "null", ")", "{", "view", "=", "inflater", ".", "inflate", "(", "R", ".", "layout", ".", "thumbgridelement", ",", "null", ")", ";", "}", "String", "url", "=", "(", "String", ")", "urls", ".", "get", "(", "position", ")", ";", "if", "(", "url", "!=", "null", ")", "{", "try", "{", "ImageView", "iv", "=", "(", "ImageView", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "image", ")", ";", "iv", ".", "setTag", "(", "\"\"", "+", "position", ")", ";", "Bitmap", "bm", "=", "Bitmap", ".", "createBitmap", "(", "itemSize", ",", "itemSize", ",", "Bitmap", ".", "Config", ".", "ALPHA_8", ")", ";", "iv", ".", "setImageBitmap", "(", "bm", ")", ";", "ImageGetTask", "task", "=", "new", "ImageGetTask", "(", "iv", ")", ";", "task", ".", "execute", "(", "url", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "return", "view", ";", "}", "class", "ImageGetTask", "extends", "AsyncTask", "<", "String", ",", "Void", ",", "Bitmap", ">", "{", "private", "ImageView", "image", ";", "private", "String", "tag", ";", "public", "ImageGetTask", "(", "ImageView", "_image", ")", "{", "image", "=", "_image", ";", "if", "(", "_image", "==", "null", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "}", "tag", "=", "image", ".", "getTag", "(", ")", ".", "toString", "(", ")", ";", "FLog", ".", "d", "(", "\"tag=\"", "+", "tag", ")", ";", "}", "@", "Override", "protected", "Bitmap", "doInBackground", "(", "String", "...", "urls", ")", "{", "Bitmap", "bm", "=", "ImageCache", ".", "getImage", "(", "urls", "[", "0", "]", "+", "\"_t\"", ")", ";", "if", "(", "bm", "==", "null", ")", "{", "bm", "=", "ImageCache", ".", "getImage", "(", "urls", "[", "0", "]", ")", ";", "if", "(", "bm", "==", "null", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "try", "{", "ImageCache", ".", "setImage", "(", "urls", "[", "0", "]", ")", ";", "bm", "=", "ImageCache", ".", "getImage", "(", "urls", "[", "0", "]", ")", ";", "bm", "=", "ImageResizer", ".", "ResizeCenter", "(", "bm", ",", "itemSize", ")", ";", "ImageCache", ".", "setImageFromBitmap", "(", "urls", "[", "0", "]", "+", "\"_t\"", ",", "bm", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "FLog", ".", "d", "(", "\"fail", "with", "\"", "+", "urls", "[", "0", "]", ")", ";", "try", "{", "Thread", ".", "sleep", "(", "1", "*", "1000", ")", ";", "}", "catch", "(", "Exception", "e2", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e2", ")", ";", "}", "}", "finally", "{", "}", "}", "else", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "bm", "=", "ImageResizer", ".", "ResizeCenter", "(", "bm", ",", "itemSize", ")", ";", "ImageCache", ".", "setImageFromBitmap", "(", "urls", "[", "0", "]", "+", "\"_t\"", ",", "bm", ")", ";", "}", "}", "else", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "}", "return", "bm", ";", "}", "@", "Override", "protected", "void", "onPostExecute", "(", "Bitmap", "result", ")", "{", "try", "{", "if", "(", "image", "!=", "null", "&&", "tag", ".", "equals", "(", "image", ".", "getTag", "(", ")", ")", ")", "{", "if", "(", "result", "==", "null", ")", "{", "return", ";", "}", "image", ".", "setImageBitmap", "(", "result", ")", ";", "if", "(", "true", ")", "{", "image", ".", "setOnClickListener", "(", "new", "View", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "View", "v", ")", "{", "try", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "Intent", "intent", "=", "new", "Intent", "(", ")", ";", "ThumbGrid", "activity", "=", "(", "ThumbGrid", ")", "getContext", "(", ")", ";", "intent", ".", "putExtra", "(", "\"imgURLs\"", ",", "activity", ".", "imgURLs", ")", ";", "intent", ".", "putExtra", "(", "\"thumbURLs\"", ",", "activity", ".", "thumbURLs", ")", ";", "intent", ".", "putExtra", "(", "\"myImgURL\"", ",", "activity", ".", "imgURLs", ".", "get", "(", "Integer", ".", "parseInt", "(", "tag", ")", ")", ")", ";", "intent", ".", "setClassName", "(", "activity", ".", "getPackageName", "(", ")", ",", "activity", ".", "getClass", "(", ")", ".", "getPackage", "(", ")", ".", "getName", "(", ")", "+", "\"\"", ")", ";", "activity", ".", "startActivity", "(", "intent", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", ")", ";", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", "}", "</s>" ]
8,265
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ".", "DirectorySelectDialog", ".", "onDirectoryListDialogListener", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "preference", ".", "CheckBoxPreference", ";", "import", "android", ".", "preference", ".", "EditTextPreference", ";", "import", "android", ".", "preference", ".", "Preference", ";", "import", "android", ".", "preference", ".", "PreferenceActivity", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "widget", ".", "Toast", ";", "import", "android", ".", "preference", ".", "Preference", ".", "OnPreferenceChangeListener", ";", "public", "class", "PrefSetting", "extends", "PreferenceActivity", "{", "@", "Override", "public", "void", "onCreate", "(", "Bundle", "savedInstanceState", ")", "{", "super", ".", "onCreate", "(", "savedInstanceState", ")", ";", "addPreferencesFromResource", "(", "R", ".", "xml", ".", "prefsetting", ")", ";", "try", "{", "EditTextPreference", "etp", "=", "(", "EditTextPreference", ")", "this", ".", "findPreference", "(", "getString", "(", "R", ".", "string", ".", "cachesize", ")", ")", ";", "etp", ".", "setOnPreferenceChangeListener", "(", "new", "OnPreferenceChangeListener", "(", ")", "{", "public", "boolean", "onPreferenceChange", "(", "Preference", "preference", ",", "Object", "newValue", ")", "{", "return", "CacheSizeChange", "(", "preference", ",", "newValue", ")", ";", "}", "}", ")", ";", "EditTextPreference", "etp_hist", "=", "(", "EditTextPreference", ")", "this", ".", "findPreference", "(", "getString", "(", "R", ".", "string", ".", "historynum", ")", ")", ";", "etp_hist", ".", "setOnPreferenceChangeListener", "(", "new", "OnPreferenceChangeListener", "(", ")", "{", "public", "boolean", "onPreferenceChange", "(", "Preference", "preference", ",", "Object", "newValue", ")", "{", "return", "HistorySizeChange", "(", "preference", ",", "newValue", ")", ";", "}", "}", ")", ";", "EditTextPreference", "etp_threadStrNum", "=", "(", "EditTextPreference", ")", "this", ".", "findPreference", "(", "\"threadStrNum\"", ")", ";", "etp_threadStrNum", ".", "setOnPreferenceChangeListener", "(", "new", "OnPreferenceChangeListener", "(", ")", "{", "public", "boolean", "onPreferenceChange", "(", "Preference", "preference", ",", "Object", "newValue", ")", "{", "return", "ThreadStrNumChange", "(", "preference", ",", "newValue", ")", ";", "}", "}", ")", ";", "EditTextPreference", "etp_delkey", "=", "(", "EditTextPreference", ")", "this", ".", "findPreference", "(", "getString", "(", "R", ".", "string", ".", "deletekey", ")", ")", ";", "etp_delkey", ".", "setOnPreferenceChangeListener", "(", "new", "OnPreferenceChangeListener", "(", ")", "{", "public", "boolean", "onPreferenceChange", "(", "Preference", "preference", ",", "Object", "newValue", ")", "{", "return", "DeleteKeyChange", "(", "preference", ",", "newValue", ")", ";", "}", "}", ")", ";", "final", "DirectorySelectDialogPreference", "savedir", "=", "(", "DirectorySelectDialogPreference", ")", "this", ".", "findPreference", "(", "\"saveDir\"", ")", ";", "String", "saveSummaryFooter", "=", "\"\"", ";", "if", "(", "SDCard", ".", "saveDir", "!=", "null", ")", "{", "saveSummaryFooter", "+=", "\"-UNK-n-UNK-:\\\"\"", "+", "SDCard", ".", "saveDir", "+", "\"\\\"\"", ";", "}", "savedir", ".", "setSummary", "(", "getString", "(", "R", ".", "string", ".", "savedirsummary", ")", "+", "saveSummaryFooter", ")", ";", "savedir", ".", "addListener", "(", "new", "onDirectoryListDialogListener", "(", ")", "{", "public", "void", "onClickFileList", "(", "String", "path", ")", "{", "savedir", ".", "setSummary", "(", "path", ")", ";", "}", "}", ")", ";", "CheckBoxPreference", "innerCache", "=", "(", "CheckBoxPreference", ")", "this", ".", "findPreference", "(", "\"innerCache\"", ")", ";", "innerCache", ".", "setSummary", "(", "R", ".", "string", ".", "innerCacheSummary", ")", ";", "innerCache", ".", "setOnPreferenceChangeListener", "(", "new", "OnPreferenceChangeListener", "(", ")", "{", "public", "boolean", "onPreferenceChange", "(", "Preference", "preference", ",", "Object", "newValue", ")", "{", "return", "InnerCacheChange", "(", "preference", ",", "newValue", ")", ";", "}", "}", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "private", "boolean", "CacheSizeChange", "(", "Preference", "preference", ",", "Object", "newValue", ")", "{", "String", "input", "=", "newValue", ".", "toString", "(", ")", ";", "try", "{", "if", "(", "input", "!=", "null", "&&", "Integer", ".", "parseInt", "(", "input", ")", ">", "0", "&&", "Integer", ".", "parseInt", "(", "input", ")", ">", "4", "&&", "Integer", ".", "parseInt", "(", "input", ")", "<=", "1000", ")", "{", "preference", ".", "setSummary", "(", "input", ")", ";", "return", "true", ";", "}", "else", "{", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "Toast", ".", "makeText", "(", "this", ",", "\"\"", ",", "Toast", ".", "LENGTH_LONG", ")", ".", "show", "(", ")", ";", "return", "false", ";", "}", "private", "boolean", "HistorySizeChange", "(", "Preference", "preference", ",", "Object", "newValue", ")", "{", "String", "input", "=", "newValue", ".", "toString", "(", ")", ";", "try", "{", "if", "(", "input", "!=", "null", "&&", "Integer", ".", "parseInt", "(", "input", ")", ">=", "0", "&&", "Integer", ".", "parseInt", "(", "input", ")", "<=", "100", ")", "{", "preference", ".", "setSummary", "(", "input", ")", ";", "return", "true", ";", "}", "else", "{", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "Toast", ".", "makeText", "(", "this", ",", "\"\"", ",", "Toast", ".", "LENGTH_LONG", ")", ".", "show", "(", ")", ";", "return", "false", ";", "}", "private", "boolean", "ThreadStrNumChange", "(", "Preference", "preference", ",", "Object", "newValue", ")", "{", "String", "input", "=", "newValue", ".", "toString", "(", ")", ";", "try", "{", "if", "(", "input", "!=", "null", "&&", "Integer", ".", "parseInt", "(", "input", ")", ">=", "4", "&&", "Integer", ".", "parseInt", "(", "input", ")", "<=", "50", ")", "{", "preference", ".", "setSummary", "(", "input", ")", ";", "return", "true", ";", "}", "else", "{", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "Toast", ".", "makeText", "(", "this", ",", "\"\"", ",", "Toast", ".", "LENGTH_LONG", ")", ".", "show", "(", ")", ";", "return", "false", ";", "}", "private", "boolean", "DeleteKeyChange", "(", "Preference", "preference", ",", "Object", "newValue", ")", "{", "String", "input", "=", "newValue", ".", "toString", "(", ")", ";", "try", "{", "if", "(", "input", "!=", "null", "&&", "input", ".", "length", "(", ")", "<=", "8", ")", "{", "preference", ".", "setSummary", "(", "input", ")", ";", "return", "true", ";", "}", "else", "{", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "Toast", ".", "makeText", "(", "this", ",", "\"\"", ",", "Toast", ".", "LENGTH_LONG", ")", ".", "show", "(", ")", ";", "return", "false", ";", "}", "private", "boolean", "InnerCacheChange", "(", "Preference", "preference", ",", "Object", "newValue", ")", "{", "String", "input", "=", "newValue", ".", "toString", "(", ")", ";", "FLog", ".", "d", "(", "\"newvalue=\"", "+", "newValue", ")", ";", "try", "{", "if", "(", "input", "!=", "null", ")", "{", "FLog", ".", "d", "(", "\"input=\"", "+", "input", ")", ";", "SDCard", ".", "copyCacheSetting", "(", "this", ")", ";", "return", "true", ";", "}", "else", "{", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "return", "false", ";", "}", "private", "boolean", "SaveDirChange", "(", "Preference", "preference", ",", "Object", "newValue", ")", "{", "String", "input", "=", "newValue", ".", "toString", "(", ")", ";", "try", "{", "if", "(", "input", "!=", "null", ")", "{", "SDCard", ".", "setSaveDir", "(", "this", ")", ";", "return", "true", ";", "}", "else", "{", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "return", "false", ";", "}", "private", "String", "getDirFooter", "(", ")", "{", "return", "\"(-UNK-\"", "+", "SDCard", ".", "getBaseDir", "(", ")", "+", "\"-UNK-)\"", ";", "}", "@", "Override", "public", "void", "onDestroy", "(", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "super", ".", "onDestroy", "(", ")", ";", "try", "{", "SDCard", ".", "setCacheDir", "(", "this", ")", ";", "SDCard", ".", "setSaveDir", "(", "this", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", "</s>" ]
8,266
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "android", ".", "app", ".", "Activity", ";", "import", "android", ".", "app", ".", "AlertDialog", ";", "import", "android", ".", "app", ".", "ListActivity", ";", "import", "android", ".", "net", ".", "Uri", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "view", ".", "Display", ";", "import", "android", ".", "view", ".", "KeyEvent", ";", "import", "android", ".", "view", ".", "Menu", ";", "import", "android", ".", "view", ".", "MenuInflater", ";", "import", "android", ".", "view", ".", "MenuItem", ";", "import", "android", ".", "view", ".", "Window", ";", "import", "android", ".", "view", ".", "WindowManager", ";", "import", "android", ".", "content", ".", "ContentResolver", ";", "import", "android", ".", "content", ".", "ContentValues", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "DialogInterface", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "content", ".", "SharedPreferences", ";", "import", "android", ".", "content", ".", "res", ".", "Configuration", ";", "import", "android", ".", "graphics", ".", "Bitmap", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "java", ".", "io", ".", "BufferedReader", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "InputStreamReader", ";", "import", "java", ".", "text", ".", "SimpleDateFormat", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Date", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "apache", ".", "http", ".", "HttpEntity", ";", "import", "org", ".", "apache", ".", "http", ".", "HttpResponse", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "HttpClient", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "methods", ".", "HttpGet", ";", "import", "org", ".", "apache", ".", "http", ".", "impl", ".", "client", ".", "DefaultHttpClient", ";", "import", "org", ".", "apache", ".", "http", ".", "params", ".", "HttpConnectionParams", ";", "import", "org", ".", "apache", ".", "http", ".", "params", ".", "HttpParams", ";", "import", "org", ".", "apache", ".", "http", ".", "protocol", ".", "BasicHttpContext", ";", "import", "org", ".", "apache", ".", "http", ".", "protocol", ".", "DefaultedHttpContext", ";", "import", "org", ".", "apache", ".", "http", ".", "protocol", ".", "HttpContext", ";", "import", "android", ".", "app", ".", "ProgressDialog", ";", "import", "java", ".", "lang", ".", "Thread", ";", "import", "java", ".", "net", ".", "HttpURLConnection", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "net", ".", "UnknownHostException", ";", "import", "android", ".", "os", ".", "AsyncTask", ";", "import", "android", ".", "os", ".", "Handler", ";", "import", "android", ".", "os", ".", "Message", ";", "import", "android", ".", "preference", ".", "PreferenceManager", ";", "import", "android", ".", "provider", ".", "MediaStore", ".", "Images", ";", "import", "android", ".", "widget", ".", "AdapterView", ";", "import", "android", ".", "widget", ".", "Button", ";", "import", "android", ".", "widget", ".", "EditText", ";", "import", "android", ".", "widget", ".", "ImageButton", ";", "import", "android", ".", "widget", ".", "ImageView", ";", "import", "android", ".", "widget", ".", "LinearLayout", ";", "import", "android", ".", "widget", ".", "ListView", ";", "import", "android", ".", "widget", ".", "TextView", ";", "import", "android", ".", "widget", ".", "Toast", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "view", ".", "inputmethod", ".", "InputMethodManager", ";", "import", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ".", "FutabaThreadAdapter", ".", "ImageGetTask", ";", "import", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ".", "R", ".", "id", ";", "public", "class", "FutabaThread", "extends", "Activity", "implements", "Runnable", "{", "public", "ArrayList", "<", "FutabaStatus", ">", "statuses", "=", "null", ";", "public", "FutabaThreadAdapter", "adapter", "=", "null", ";", "public", "String", "threadURL", "=", "null", ";", "public", "String", "baseURL", "=", "null", ";", "public", "String", "BBSName", "=", "null", ";", "public", "int", "threadNum", ";", "public", "Toast", "toast", ";", "private", "ProgressDialog", "waitDialog", ";", "private", "Thread", "thread", ";", "private", "boolean", "showDeletedRes", "=", "false", ";", "private", "ListView", "listView", ";", "int", "position", "=", "0", ";", "int", "positionY", "=", "0", ";", "int", "currentSize", "=", "0", ";", "int", "prevSize", "=", "0", ";", "final", "int", "TO_IMAGECATALOG", "=", "0", ";", "final", "int", "TO_POST", "=", "1", ";", "private", "int", "itemLongClick_chosen", "=", "0", ";", "@", "Override", "public", "void", "onCreate", "(", "Bundle", "savedInstanceState", ")", "{", "super", ".", "onCreate", "(", "savedInstanceState", ")", ";", "if", "(", "getResources", "(", ")", ".", "getBoolean", "(", "R", ".", "bool", ".", "avoidsleep", ")", ")", "{", "Window", "window", "=", "getWindow", "(", ")", ";", "window", ".", "addFlags", "(", "WindowManager", ".", "LayoutParams", ".", "FLAG_KEEP_SCREEN_ON", ")", ";", "}", "try", "{", "SharedPreferences", "preferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "this", ")", ";", "showDeletedRes", "=", "preferences", ".", "getBoolean", "(", "getString", "(", "R", ".", "string", ".", "showdeletedres", ")", ",", "false", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "Intent", "intent", "=", "getIntent", "(", ")", ";", "String", "superFutabaLinkURL", "=", "intent", ".", "getDataString", "(", ")", ";", "if", "(", "superFutabaLinkURL", "!=", "null", ")", "{", "FLog", ".", "d", "(", "\"\"", "+", "superFutabaLinkURL", ")", ";", "Pattern", "baseURLpattern", "=", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "DOTALL", ")", ";", "Matcher", "threadm", "=", "baseURLpattern", ".", "matcher", "(", "superFutabaLinkURL", ")", ";", "if", "(", "threadm", ".", "find", "(", ")", ")", "{", "baseURL", "=", "threadm", ".", "group", "(", "1", ")", ";", "threadNum", "=", "Integer", ".", "parseInt", "(", "threadm", ".", "group", "(", "2", ")", ")", ";", "BBSName", "=", "\"-UNK-\"", ";", "threadURL", "=", "baseURL", "+", "\"res/\"", "+", "threadNum", "+", "\".htm\"", ";", "FLog", ".", "d", "(", "\"threadURL=\"", "+", "threadURL", ")", ";", "}", "else", "{", "Toast", ".", "makeText", "(", "this", ",", "\"URL-UNK-\"", ",", "Toast", ".", "LENGTH_LONG", ")", ".", "show", "(", ")", ";", "}", "}", "else", "{", "baseURL", "=", "(", "String", ")", "intent", ".", "getSerializableExtra", "(", "\"baseUrl\"", ")", ";", "threadNum", "=", "Integer", ".", "parseInt", "(", "(", "String", ")", "intent", ".", "getSerializableExtra", "(", "\"threadNum\"", ")", ")", ";", "BBSName", "=", "(", "String", ")", "intent", ".", "getSerializableExtra", "(", "\"BBSName\"", ")", ";", "try", "{", "HistoryManager", "man", "=", "new", "HistoryManager", "(", ")", ";", "man", ".", "Load", "(", ")", ";", "FutabaThreadContent", "thread", ";", "thread", "=", "man", ".", "get", "(", "threadNum", ")", ";", "FLog", ".", "d", "(", "\"seeAt=\"", "+", "thread", ".", "seeAt", ")", ";", "position", "=", "thread", ".", "seeAt", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "threadURL", "=", "baseURL", "+", "\"res/\"", "+", "threadNum", "+", "\".htm\"", ";", "}", "statuses", "=", "new", "ArrayList", "<", "FutabaStatus", ">", "(", ")", ";", "setContentView", "(", "R", ".", "layout", ".", "futaba_thread", ")", ";", "listView", "=", "(", "ListView", ")", "findViewById", "(", "id", ".", "threadlistview", ")", ";", "adapter", "=", "new", "FutabaThreadAdapter", "(", "this", ",", "StateMan", ".", "getThreadRowResourceId", "(", "this", ")", ",", "statuses", ")", ";", "listView", ".", "setAdapter", "(", "adapter", ")", ";", "listView", ".", "setOnItemLongClickListener", "(", "new", "FutabaThreadOnLongClickListener", "(", ")", ")", ";", "try", "{", "SharedPreferences", "preferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "this", ")", ";", "boolean", "fastScrollEnabled", "=", "preferences", ".", "getBoolean", "(", "\"\"", ",", "false", ")", ";", "listView", ".", "setFastScrollEnabled", "(", "fastScrollEnabled", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "setWait", "(", ")", ";", "}", "public", "void", "setWait", "(", ")", "{", "if", "(", "waitDialog", "!=", "null", ")", "{", "waitDialog", ".", "dismiss", "(", ")", ";", "}", "waitDialog", "=", "new", "ProgressDialog", "(", "this", ")", ";", "waitDialog", ".", "setMessage", "(", "this", ".", "getString", "(", "R", ".", "string", ".", "loading", ")", ")", ";", "waitDialog", ".", "setProgressStyle", "(", "ProgressDialog", ".", "STYLE_SPINNER", ")", ";", "waitDialog", ".", "show", "(", ")", ";", "thread", "=", "new", "Thread", "(", "this", ")", ";", "thread", ".", "start", "(", ")", ";", "}", "public", "void", "run", "(", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "100", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "handler", ".", "sendEmptyMessage", "(", "0", ")", ";", "}", "private", "Handler", "handler", "=", "new", "Handler", "(", ")", "{", "public", "void", "handleMessage", "(", "Message", "msg", ")", "{", "try", "{", "loading", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", ";", "final", "Handler", "handler2", "=", "new", "Handler", "(", ")", ";", "final", "Handler", "handler3", "=", "new", "Handler", "(", ")", ";", "private", "void", "loading", "(", ")", "{", "LinearLayout", "searchBar", "=", "(", "LinearLayout", ")", "findViewById", "(", "id", ".", "search_bar", ")", ";", "EditText", "searchWord", "=", "(", "EditText", ")", "findViewById", "(", "R", ".", "id", ".", "searchinput", ")", ";", "searchWord", ".", "setOnKeyListener", "(", "new", "View", ".", "OnKeyListener", "(", ")", "{", "public", "boolean", "onKey", "(", "View", "v", ",", "int", "keyCode", ",", "KeyEvent", "event", ")", "{", "FLog", ".", "d", "(", "\"onKey\"", "+", "event", ")", ";", "if", "(", "event", ".", "getAction", "(", ")", "==", "KeyEvent", ".", "ACTION_DOWN", "&&", "keyCode", "==", "KeyEvent", ".", "KEYCODE_ENTER", ")", "{", "return", "true", ";", "}", "if", "(", "event", ".", "getAction", "(", ")", "==", "KeyEvent", ".", "ACTION_UP", "&&", "keyCode", "==", "KeyEvent", ".", "KEYCODE_ENTER", ")", "{", "EditText", "word", "=", "(", "EditText", ")", "findViewById", "(", "R", ".", "id", ".", "searchinput", ")", ";", "FutabaThread", "activity", "=", "(", "FutabaThread", ")", "v", ".", "getContext", "(", ")", ";", "activity", ".", "onClickSearchButton", "(", "v", ")", ";", "return", "false", ";", "}", "return", "false", ";", "}", "}", ")", ";", "searchBar", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "FutabaThreadContentGetter", "getterThread", "=", "new", "FutabaThreadContentGetter", "(", ")", ";", "getterThread", ".", "start", "(", ")", ";", "}", "public", "ArrayList", "<", "String", ">", "getImageURLs", "(", ")", "{", "Iterator", "iterator", "=", "statuses", ".", "iterator", "(", ")", ";", "int", "i", "=", "0", ";", "ArrayList", "<", "String", ">", "list", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "FutabaStatus", "status", "=", "(", "FutabaStatus", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "status", ".", "bigImgURL", "!=", "null", ")", "{", "FLog", ".", "d", "(", "\"image\"", "+", "status", ".", "bigImgURL", ")", ";", "list", ".", "add", "(", "status", ".", "bigImgURL", ")", ";", "}", "i", "++", ";", "}", "return", "list", ";", "}", "public", "ArrayList", "<", "String", ">", "getThumbURLs", "(", ")", "{", "Iterator", "iterator", "=", "statuses", ".", "iterator", "(", ")", ";", "int", "i", "=", "0", ";", "ArrayList", "<", "String", ">", "list", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "FutabaStatus", "status", "=", "(", "FutabaStatus", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "status", ".", "imgURL", "!=", "null", ")", "{", "FLog", ".", "d", "(", "\"thumbimage\"", "+", "status", ".", "imgURL", ")", ";", "list", ".", "add", "(", "status", ".", "imgURL", ")", ";", "}", "i", "++", ";", "}", "return", "list", ";", "}", "public", "void", "onClickReloadBtn", "(", "View", "v", ")", "{", "try", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "position", "=", "listView", ".", "getFirstVisiblePosition", "(", ")", ";", "positionY", "=", "listView", ".", "getChildAt", "(", "0", ")", ".", "getTop", "(", ")", ";", ";", "FLog", ".", "d", "(", "\"position=\"", "+", "position", ")", ";", "setWait", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "public", "void", "onClickGoTopBtn", "(", "View", "v", ")", "{", "listView", ".", "setSelection", "(", "0", ")", ";", "}", "public", "void", "onClickGridViewBtn", "(", "View", "v", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "Intent", "intent", "=", "new", "Intent", "(", ")", ";", "ArrayList", "<", "String", ">", "thumbURLs", "=", "getThumbURLs", "(", ")", ";", "if", "(", "thumbURLs", ".", "size", "(", ")", "==", "0", ")", "{", "return", ";", "}", "int", "pos", "=", "listView", ".", "getFirstVisiblePosition", "(", ")", ";", "int", "imagepos", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<=", "pos", ";", "++", "i", ")", "{", "FutabaStatus", "status", "=", "(", "FutabaStatus", ")", "adapter", ".", "items", ".", "get", "(", "i", ")", ";", "if", "(", "status", ".", "imgURL", "!=", "null", "&&", "!", "status", ".", "imgURL", ".", "equals", "(", "\"\"", ")", ")", "{", "imagepos", "++", ";", "}", "}", "imagepos", "=", "Math", ".", "max", "(", "0", ",", "imagepos", "-", "1", ")", ";", "intent", ".", "putExtra", "(", "\"position\"", ",", "imagepos", ")", ";", "intent", ".", "putExtra", "(", "\"imgURLs\"", ",", "getImageURLs", "(", ")", ")", ";", "intent", ".", "putExtra", "(", "\"thumbURLs\"", ",", "thumbURLs", ")", ";", "intent", ".", "setClassName", "(", "getPackageName", "(", ")", ",", "getClass", "(", ")", ".", "getPackage", "(", ")", ".", "getName", "(", ")", "+", "\".ThumbGrid\"", ")", ";", "startActivity", "(", "intent", ")", ";", "}", "public", "void", "onClickGoBottomBtn", "(", "View", "v", ")", "{", "listView", ".", "setSelection", "(", "listView", ".", "getCount", "(", ")", "-", "1", ")", ";", "}", "public", "void", "onClickGoBtn", "(", "View", "v", ")", "{", "WindowManager", "wm", "=", "(", "WindowManager", ")", "getSystemService", "(", "Context", ".", "WINDOW_SERVICE", ")", ";", "Display", "display", "=", "wm", ".", "getDefaultDisplay", "(", ")", ";", "}", "public", "void", "onClickPostBtn", "(", "View", "v", ")", "{", "Intent", "intent", "=", "new", "Intent", "(", ")", ";", "intent", ".", "putExtra", "(", "\"baseURL\"", ",", "baseURL", ")", ";", "intent", ".", "putExtra", "(", "\"threadNum\"", ",", "threadNum", ")", ";", "intent", ".", "setClassName", "(", "getPackageName", "(", ")", ",", "getClass", "(", ")", ".", "getPackage", "(", ")", ".", "getName", "(", ")", "+", "\".Post\"", ")", ";", "startActivityForResult", "(", "intent", ",", "TO_POST", ")", ";", "}", "@", "Override", "public", "boolean", "onCreateOptionsMenu", "(", "Menu", "menu", ")", "{", "super", ".", "onCreateOptionsMenu", "(", "menu", ")", ";", "MenuInflater", "inflater", "=", "getMenuInflater", "(", ")", ";", "inflater", ".", "inflate", "(", "R", ".", "menu", ".", "menu_thread", ",", "menu", ")", ";", "return", "true", ";", "}", "public", "void", "registerShiori", "(", "int", "position", ")", "{", "try", "{", "if", "(", "position", "==", "0", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "\"\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "else", "{", "FutabaStatus", "item", "=", "(", "FutabaStatus", ")", "adapter", ".", "items", ".", "get", "(", "position", ")", ";", "if", "(", "FutabaStatus", ".", "isBlank", "(", "item", ")", ")", "{", "position", "+=", "1", ";", "item", "=", "(", "FutabaStatus", ")", "adapter", ".", "items", ".", "get", "(", "position", ")", ";", "}", "HistoryManager", "man", "=", "new", "HistoryManager", "(", ")", ";", "man", ".", "Load", "(", ")", ";", "FutabaThreadContent", "thread", "=", "new", "FutabaThreadContent", "(", ")", ";", "thread", ".", "pointAt", "=", "item", ".", "id", ";", "thread", ".", "threadNum", "=", "threadNum", ";", "FLog", ".", "d", "(", "thread", ".", "toString", "(", ")", ")", ";", "man", ".", "updateThread", "(", "thread", ")", ";", "man", ".", "Save", "(", ")", ";", "View", "view", "=", "listView", ".", "getChildAt", "(", "0", ")", ";", "adapter", ".", "shioriPosition", "=", "item", ".", "id", ";", "adapter", ".", "setShioriStatus", "(", "view", ")", ";", "adapter", ".", "notifyDataSetChanged", "(", ")", ";", "listView", ".", "invalidate", "(", ")", ";", "Toast", ".", "makeText", "(", "this", ",", "\"-UNK-\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "public", "void", "removeShiori", "(", "int", "position", ")", "{", "try", "{", "HistoryManager", "man", "=", "new", "HistoryManager", "(", ")", ";", "man", ".", "Load", "(", ")", ";", "FutabaThreadContent", "thread", "=", "new", "FutabaThreadContent", "(", ")", ";", "thread", ".", "pointAt", "=", "-", "1", ";", "thread", ".", "threadNum", "=", "threadNum", ";", "FLog", ".", "d", "(", "thread", ".", "toString", "(", ")", ")", ";", "man", ".", "updateThreadRemoveShiori", "(", "thread", ")", ";", "man", ".", "Save", "(", ")", ";", "View", "view", "=", "listView", ".", "getChildAt", "(", "0", ")", ";", "adapter", ".", "shioriPosition", "=", "0", ";", "adapter", ".", "notifyDataSetChanged", "(", ")", ";", "listView", ".", "invalidate", "(", ")", ";", "Toast", ".", "makeText", "(", "this", ",", "\"-UNK-\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "public", "void", "searchShiori", "(", ")", "{", "try", "{", "HistoryManager", "man", "=", "new", "HistoryManager", "(", ")", ";", "man", ".", "Load", "(", ")", ";", "FutabaThreadContent", "thread", "=", "man", ".", "get", "(", "threadNum", ")", ";", "int", "position", "=", "thread", ".", "pointAt", ";", "if", "(", "position", "==", "0", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "\"-UNK-\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "else", "{", "int", "i", "=", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "adapter", ".", "items", ".", "size", "(", ")", ";", "++", "i", ")", "{", "FutabaStatus", "status", "=", "(", "FutabaStatus", ")", "adapter", ".", "items", ".", "get", "(", "i", ")", ";", "if", "(", "status", ".", "id", "==", "position", ")", "{", "listView", ".", "setSelection", "(", "i", ")", ";", "Toast", ".", "makeText", "(", "this", ",", "\"-UNK-\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "break", ";", "}", "}", "if", "(", "i", "==", "adapter", ".", "items", ".", "size", "(", ")", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "\"\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "Toast", ".", "makeText", "(", "this", ",", "\"-UNK-\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "}", "@", "Override", "public", "boolean", "onOptionsItemSelected", "(", "MenuItem", "item", ")", "{", "Intent", "intent", ";", "switch", "(", "item", ".", "getItemId", "(", ")", ")", "{", "case", "R", ".", "id", ".", "search", ":", "LinearLayout", "searchBar", "=", "(", "LinearLayout", ")", "findViewById", "(", "id", ".", "search_bar", ")", ";", "if", "(", "searchBar", ".", "getVisibility", "(", ")", "==", "View", ".", "GONE", ")", "{", "searchBar", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "}", "else", "{", "searchBar", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "}", "return", "true", ";", "case", "R", ".", "id", ".", "download", ":", "saveAll", "(", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "post", ":", "onClickPostBtn", "(", "null", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "possave", ":", "{", "int", "position", "=", "listView", ".", "getFirstVisiblePosition", "(", ")", ";", "registerShiori", "(", "position", ")", ";", "}", "return", "true", ";", "case", "R", ".", "id", ".", "posload", ":", "searchShiori", "(", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "share", ":", "intent", "=", "new", "Intent", "(", "Intent", ".", "ACTION_SEND", ")", ";", "intent", ".", "setType", "(", "\"text/plain\"", ")", ";", "intent", ".", "putExtra", "(", "Intent", ".", "EXTRA_TEXT", ",", "threadURL", ")", ";", "try", "{", "startActivityForResult", "(", "intent", ",", "0", ")", ";", "}", "catch", "(", "android", ".", "content", ".", "ActivityNotFoundException", "ex", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "\"\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "return", "true", ";", "case", "R", ".", "id", ".", "settings", ":", "intent", "=", "new", "Intent", "(", ")", ";", "intent", ".", "setClassName", "(", "getPackageName", "(", ")", ",", "getClass", "(", ")", ".", "getPackage", "(", ")", ".", "getName", "(", ")", "+", "\".PrefSetting\"", ")", ";", "startActivity", "(", "intent", ")", ";", "return", "true", ";", "case", "R", ".", "id", ".", "about", ":", "Uri", "uri", "=", "Uri", ".", "parse", "(", "getString", "(", "R", ".", "string", ".", "helpurl", ")", ")", ";", "intent", "=", "new", "Intent", "(", "Intent", ".", "ACTION_VIEW", ",", "uri", ")", ";", "intent", ".", "setClassName", "(", "\"\"", ",", "\"\"", ")", ";", "try", "{", "startActivity", "(", "intent", ")", ";", "}", "catch", "(", "android", ".", "content", ".", "ActivityNotFoundException", "ex", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "\"-UNK-\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}", "public", "void", "saveAll", "(", ")", "{", "if", "(", "waitDialog", "!=", "null", ")", "{", "waitDialog", ".", "dismiss", "(", ")", ";", "}", "waitDialog", "=", "new", "ProgressDialog", "(", "this", ")", ";", "waitDialog", ".", "setMessage", "(", "this", ".", "getString", "(", "R", ".", "string", ".", "loading", ")", ")", ";", "waitDialog", ".", "setProgressStyle", "(", "ProgressDialog", ".", "STYLE_SPINNER", ")", ";", "waitDialog", ".", "show", "(", ")", ";", "ArrayList", "<", "String", ">", "imgURLs", "=", "getImageURLs", "(", ")", ";", "imgURLs", ".", "add", "(", "threadURL", ")", ";", "FutabaThreadAllImageRetriever", "getterThread", "=", "new", "FutabaThreadAllImageRetriever", "(", ")", ";", "getterThread", ".", "setImageURLs", "(", "imgURLs", ")", ";", "getterThread", ".", "start", "(", ")", ";", "}", "private", "class", "FutabaThreadAllImageRetriever", "extends", "Thread", "{", "private", "ArrayList", "<", "String", ">", "imgURLs", ";", "public", "void", "setImageURLs", "(", "ArrayList", "<", "String", ">", "imgURLs", ")", "{", "this", ".", "imgURLs", "=", "imgURLs", ";", "}", "@", "Override", "public", "void", "run", "(", ")", "{", "int", "saveItemNum", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "imgURLs", ".", "size", "(", ")", ";", "++", "i", ")", "{", "if", "(", "!", "waitDialog", ".", "isShowing", "(", ")", ")", "{", "return", ";", "}", "final", "int", "current", "=", "i", ";", "try", "{", "final", "String", "imgURL", "=", "imgURLs", ".", "get", "(", "i", ")", ";", "String", "threadName", "=", "\"\"", ";", "if", "(", "false", "&&", "statuses", ".", "size", "(", ")", "!=", "0", ")", "{", "FutabaStatus", "status", "=", "statuses", ".", "get", "(", "0", ")", ";", "Date", "date", "=", "new", "Date", "(", ")", ";", "SimpleDateFormat", "sdf1", "=", "new", "SimpleDateFormat", "(", "\"yyyyMMDD\"", ")", ";", "threadName", "=", "\"\"", "+", "BBSName", "+", "\"_\"", "+", "sdf1", ".", "format", "(", "date", ")", "+", "\"_-UNK-\"", "+", "threadNum", ";", "}", "else", "{", "threadName", "=", "\"\"", "+", "BBSName", "+", "\"_-UNK-\"", "+", "threadNum", ";", "}", "FLog", ".", "d", "(", "\"\"", "+", "imgURL", ")", ";", "File", "file", "=", "new", "File", "(", "imgURL", ")", ";", "if", "(", "!", "imgURL", ".", "contains", "(", "\"htm\"", ")", "&&", "SDCard", ".", "savedImageToThreadExist", "(", "file", ".", "getName", "(", ")", ",", "threadName", ")", ")", "{", "continue", ";", "}", "File", "saved_file", "=", "ImageCache", ".", "saveImageToThread", "(", "imgURL", ",", "threadName", ")", ";", "if", "(", "saved_file", "==", "null", ")", "{", "ImageCache", ".", "setImage", "(", "imgURL", ")", ";", "saved_file", "=", "ImageCache", ".", "saveImageToThread", "(", "imgURL", ",", "threadName", ")", ";", "}", "if", "(", "saved_file", "!=", "null", ")", "{", "saveItemNum", "+=", "1", ";", "}", "final", "File", "saved_file_f", "=", "saved_file", ";", "handler3", ".", "post", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "if", "(", "saved_file_f", "!=", "null", ")", "{", "waitDialog", ".", "setMessage", "(", "\"-UNK-n\"", "+", "saved_file_f", "+", "\"n-UNK-(\"", "+", "(", "current", "+", "1", ")", "+", "\"/\"", "+", "imgURLs", ".", "size", "(", ")", "+", "\")\"", ")", ";", "String", "mimeType", "=", "StringUtil", ".", "getMIMEType", "(", "saved_file_f", ".", "getName", "(", ")", ")", ";", "FLog", ".", "d", "(", "\"name=\"", "+", "saved_file_f", ".", "getName", "(", ")", ")", ";", "FLog", ".", "d", "(", "\"mime=\"", "+", "mimeType", ")", ";", "ContentResolver", "contentResolver", "=", "getContentResolver", "(", ")", ";", "ContentValues", "values", "=", "new", "ContentValues", "(", "7", ")", ";", "values", ".", "put", "(", "Images", ".", "Media", ".", "TITLE", ",", "saved_file_f", ".", "getName", "(", ")", ")", ";", "values", ".", "put", "(", "Images", ".", "Media", ".", "DISPLAY_NAME", ",", "saved_file_f", ".", "getName", "(", ")", ")", ";", "values", ".", "put", "(", "Images", ".", "Media", ".", "DATE_TAKEN", ",", "System", ".", "currentTimeMillis", "(", ")", ")", ";", "values", ".", "put", "(", "Images", ".", "Media", ".", "MIME_TYPE", ",", "mimeType", ")", ";", "values", ".", "put", "(", "Images", ".", "Media", ".", "ORIENTATION", ",", "0", ")", ";", "values", ".", "put", "(", "Images", ".", "Media", ".", "DATA", ",", "saved_file_f", ".", "getPath", "(", ")", ")", ";", "values", ".", "put", "(", "Images", ".", "Media", ".", "SIZE", ",", "saved_file_f", ".", "length", "(", ")", ")", ";", "contentResolver", ".", "insert", "(", "Images", ".", "Media", ".", "EXTERNAL_CONTENT_URI", ",", "values", ")", ";", "}", "else", "{", "if", "(", "toast", "!=", "null", ")", "{", "toast", ".", "cancel", "(", ")", ";", "}", "toast", ".", "makeText", "(", "adapter", ".", "getContext", "(", ")", ",", "\"-UNK-\"", "+", "imgURL", "+", "\"-UNK-\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "}", "}", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "final", "int", "saveItemNum_f", "=", "saveItemNum", ";", "handler3", ".", "post", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "waitDialog", ".", "dismiss", "(", ")", ";", "if", "(", "toast", "!=", "null", ")", "{", "toast", ".", "cancel", "(", ")", ";", "}", "toast", ".", "makeText", "(", "adapter", ".", "getContext", "(", ")", ",", "\"\"", "+", "saveItemNum_f", "+", "\"\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "}", ")", ";", "System", ".", "gc", "(", ")", ";", "}", "}", "protected", "void", "onActivityResult", "(", "int", "requestCode", ",", "int", "resultCode", ",", "Intent", "intent", ")", "{", "try", "{", "FLog", ".", "d", "(", "\"\"", "+", "requestCode", ")", ";", "if", "(", "requestCode", "==", "TO_IMAGECATALOG", ")", "{", "String", "imgURL", "=", "(", "String", ")", "intent", ".", "getSerializableExtra", "(", "\"imgURL\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "statuses", ".", "size", "(", ")", ";", "++", "i", ")", "{", "if", "(", "imgURL", ".", "equals", "(", "statuses", ".", "get", "(", "i", ")", ".", "bigImgURL", ")", ")", "{", "listView", ".", "setSelection", "(", "Math", ".", "min", "(", "i", ",", "listView", ".", "getCount", "(", ")", ")", ")", ";", "break", ";", "}", "}", "}", "else", "if", "(", "requestCode", "==", "TO_POST", ")", "{", "String", "posted", "=", "\"\"", ";", "try", "{", "posted", "=", "(", "String", ")", "intent", ".", "getSerializableExtra", "(", "\"posted\"", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "if", "(", "!", "posted", ".", "equals", "(", "\"\"", ")", ")", "{", "this", ".", "onClickReloadBtn", "(", "null", ")", ";", "}", "}", "else", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "private", "boolean", "isAnonymousThread", "(", "String", "url", ")", "{", "return", "url", ".", "contains", "(", "\"\"", ")", "||", "url", ".", "contains", "(", "\"\"", ")", "||", "url", ".", "contains", "(", "\"\"", ")", "||", "url", ".", "contains", "(", "\"\"", ")", ";", "}", "private", "class", "FutabaThreadContentGetter", "extends", "Thread", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "try", "{", "boolean", "anonymous", "=", "false", ";", "if", "(", "isAnonymousThread", "(", "baseURL", ")", ")", "{", "anonymous", "=", "true", ";", "}", "currentSize", "=", "prevSize", "=", "0", ";", "String", "toast_text", "=", "\"\"", ";", "Boolean", "network_ok", "=", "true", ";", "Boolean", "cache_ok", "=", "true", ";", "FutabaThreadParser", "cacheParser", "=", "new", "FutabaThreadParser", "(", ")", ";", "FutabaThreadParser", "webParser", "=", "new", "FutabaThreadParser", "(", ")", ";", "if", "(", "SDCard", ".", "cacheExist", "(", "FutabaCrypt", ".", "createDigest", "(", "threadURL", ")", ")", ")", "{", "String", "cacheThreadHtml", "=", "SDCard", ".", "loadTextCache", "(", "FutabaCrypt", ".", "createDigest", "(", "threadURL", ")", ")", ";", "cacheParser", ".", "parse", "(", "cacheThreadHtml", ",", "anonymous", ",", "showDeletedRes", ")", ";", "FLog", ".", "d", "(", "\"cache", "ok", "\"", "+", "threadURL", ")", ";", "}", "else", "{", "cache_ok", "=", "false", ";", "FLog", ".", "d", "(", "\"cache", "fail", "\"", "+", "threadURL", ")", ";", "}", "String", "threadHtml", "=", "\"\"", ";", "try", "{", "SDCard", ".", "saveFromURL", "(", "FutabaCrypt", ".", "createDigest", "(", "threadURL", ")", ",", "new", "URL", "(", "threadURL", ")", ",", "true", ")", ";", "String", "webThreadHtml", "=", "SDCard", ".", "loadTextCache", "(", "FutabaCrypt", ".", "createDigest", "(", "threadURL", ")", ")", ";", "webParser", ".", "parse", "(", "webThreadHtml", ",", "anonymous", ",", "showDeletedRes", ")", ";", "if", "(", "cache_ok", ")", "{", "try", "{", "HistoryManager", "man", "=", "new", "HistoryManager", "(", ")", ";", "FutabaThreadContent", "thread", "=", "new", "FutabaThreadContent", "(", ")", ";", "thread", ".", "threadNum", "=", "threadNum", ";", "thread", ".", "resNum", "=", "\"\"", "+", "Math", ".", "max", "(", "0", ",", "webParser", ".", "getStatuses", "(", ")", ".", "size", "(", ")", "-", "1", ")", ";", "man", ".", "Load", "(", ")", ";", "man", ".", "updateThread", "(", "thread", ")", ";", "man", ".", "Save", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "network_ok", "=", "true", ";", "}", "catch", "(", "IOException", "e", ")", "{", "network_ok", "=", "false", ";", "String", "cause", "=", "\"\"", ";", "if", "(", "e", ".", "toString", "(", ")", ".", "contains", "(", "\"\"", ")", ")", "{", "cause", "=", "\"-UNK-\"", ";", "}", "if", "(", "cache_ok", ")", "{", "toast_text", "=", "cause", "+", "\"\"", ";", "}", "else", "{", "toast_text", "=", "cause", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "network_ok", "=", "false", ";", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "if", "(", "cache_ok", ")", "{", "toast_text", "=", "\"\"", ";", "}", "else", "{", "toast_text", "=", "\"\"", ";", "}", "}", "HistoryManager", "man", "=", "new", "HistoryManager", "(", ")", ";", "man", ".", "Load", "(", ")", ";", "if", "(", "(", "!", "network_ok", ")", "&&", "(", "!", "cache_ok", ")", ")", "{", "FutabaThreadContent", "thread", "=", "new", "FutabaThreadContent", "(", ")", ";", "thread", ".", "threadNum", "=", "threadNum", ";", "FLog", ".", "d", "(", "\"del", "thread\"", "+", "thread", ".", "toString", "(", ")", ")", ";", "man", ".", "removeThread", "(", "thread", ")", ";", "man", ".", "Save", "(", ")", ";", "}", "try", "{", "FutabaThreadContent", "thisThread", "=", "man", ".", "get", "(", "threadNum", ")", ";", "adapter", ".", "shioriPosition", "=", "thisThread", ".", "pointAt", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "ArrayList", "<", "FutabaStatus", ">", "statuses", "=", "new", "ArrayList", "<", "FutabaStatus", ">", "(", ")", ";", "if", "(", "network_ok", ")", "{", "statuses", "=", "webParser", ".", "getStatuses", "(", ")", ";", "int", "num", "=", "webParser", ".", "getStatuses", "(", ")", ".", "size", "(", ")", ";", "currentSize", "=", "num", ";", "if", "(", "cache_ok", ")", "{", "num", "-=", "cacheParser", ".", "getStatuses", "(", ")", ".", "size", "(", ")", ";", "prevSize", "=", "cacheParser", ".", "getStatuses", "(", ")", ".", "size", "(", ")", ";", "if", "(", "num", "<", "0", ")", "{", "FLog", ".", "d", "(", "\"currentSize=\"", "+", "currentSize", "+", "\"", "prevSize=\"", "+", "prevSize", ")", ";", "toast_text", "=", "\"-UNK-:\"", "+", "Math", ".", "max", "(", "num", ",", "0", ")", "+", "\"-UNK-\"", ";", "}", "else", "{", "toast_text", "=", "\"-UNK-:\"", "+", "num", "+", "\"-UNK-\"", ";", "}", "}", "else", "{", "toast_text", "=", "\"-UNK-\"", "+", "Math", ".", "max", "(", "num", "-", "1", ",", "0", ")", "+", "\"-UNK-\"", ";", "currentSize", "=", "prevSize", "=", "num", ";", "}", "}", "else", "if", "(", "cache_ok", ")", "{", "statuses", "=", "cacheParser", ".", "getStatuses", "(", ")", ";", "}", "FLog", ".", "d", "(", "\"parse", "end\"", "+", "statuses", ".", "size", "(", ")", ")", ";", "FutabaThreadParser", "parser", "=", "webParser", ";", "if", "(", "!", "network_ok", ")", "{", "parser", "=", "cacheParser", ";", "}", "final", "String", "title", "=", "parser", ".", "getTitle", "(", "20", ")", "+", "\"", "-", "\"", "+", "getString", "(", "R", ".", "string", ".", "app_name", ")", ";", "final", "String", "toast_text_f", "=", "toast_text", ";", "final", "ArrayList", "<", "FutabaStatus", ">", "statuses_ref", "=", "statuses", ";", "final", "int", "prevSize_ref", "=", "prevSize", ";", "handler2", ".", "post", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "adapter", ".", "items", ".", "clear", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "statuses_ref", ".", "size", "(", ")", ";", "++", "i", ")", "{", "if", "(", "i", "!=", "0", "&&", "i", "==", "prevSize_ref", ")", "{", "adapter", ".", "items", ".", "add", "(", "FutabaStatus", ".", "createBlank", "(", ")", ")", ";", "}", "adapter", ".", "items", ".", "add", "(", "statuses_ref", ".", "get", "(", "i", ")", ")", ";", "if", "(", "i", "==", "statuses_ref", ".", "size", "(", ")", "-", "1", "&&", "!", "statuses_ref", ".", "get", "(", "0", ")", ".", "endTime", ".", "equals", "(", "\"\"", ")", ")", "{", "adapter", ".", "items", ".", "add", "(", "FutabaStatus", ".", "createEndTime", "(", "statuses_ref", ".", "get", "(", "0", ")", ".", "endTime", ")", ")", ";", "}", "}", "try", "{", "if", "(", "waitDialog", "!=", "null", ")", "{", "waitDialog", ".", "dismiss", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "Toast", ".", "makeText", "(", "adapter", ".", "getContext", "(", ")", ",", "toast_text_f", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "setTitle", "(", "title", ")", ";", "adapter", ".", "notifyDataSetChanged", "(", ")", ";", "listView", ".", "invalidate", "(", ")", ";", "if", "(", "position", "!=", "0", ")", "{", "listView", ".", "setSelectionFromTop", "(", "Math", ".", "min", "(", "position", ",", "listView", ".", "getCount", "(", ")", ")", ",", "positionY", ")", ";", "}", "}", "}", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", "public", "void", "saveImage", "(", "String", "imgURL", ")", "{", "if", "(", "this", ".", "toast", "!=", "null", ")", "{", "this", ".", "toast", ".", "cancel", "(", ")", ";", "}", "this", ".", "toast", "=", "Toast", ".", "makeText", "(", "this", ",", "\"-UNK-...\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ";", "this", ".", "toast", ".", "show", "(", ")", ";", "FutabaThreadImageRetriever", "getterThread", "=", "new", "FutabaThreadImageRetriever", "(", ")", ";", "getterThread", ".", "setImageURL", "(", "imgURL", ")", ";", "getterThread", ".", "start", "(", ")", ";", "}", "private", "class", "FutabaThreadImageRetriever", "extends", "Thread", "{", "private", "String", "imgURL", ";", "public", "void", "setImageURL", "(", "String", "imgURL", ")", "{", "this", ".", "imgURL", "=", "imgURL", ";", "}", "@", "Override", "public", "void", "run", "(", ")", "{", "try", "{", "String", "imgFile", "=", "imgURL", ";", "FLog", ".", "d", "(", "\"\"", "+", "imgURL", ")", ";", "File", "file", "=", "new", "File", "(", "imgFile", ")", ";", "File", "saved_file", "=", "ImageCache", ".", "saveImage", "(", "imgFile", ")", ";", "if", "(", "saved_file", "==", "null", ")", "{", "ImageCache", ".", "setImage", "(", "imgFile", ")", ";", "saved_file", "=", "ImageCache", ".", "saveImage", "(", "imgFile", ")", ";", "}", "final", "File", "saved_file_f", "=", "saved_file", ";", "handler3", ".", "post", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "FutabaThread", "fthread", "=", "(", "FutabaThread", ")", "adapter", ".", "getContext", "(", ")", ";", "if", "(", "saved_file_f", "!=", "null", ")", "{", "if", "(", "fthread", ".", "toast", "!=", "null", ")", "{", "fthread", ".", "toast", ".", "cancel", "(", ")", ";", "}", "fthread", ".", "toast", "=", "Toast", ".", "makeText", "(", "fthread", ",", "saved_file_f", ".", "getAbsolutePath", "(", ")", "+", "\"-UNK-\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ";", "fthread", ".", "toast", ".", "show", "(", ")", ";", "String", "mimeType", "=", "StringUtil", ".", "getMIMEType", "(", "saved_file_f", ".", "getName", "(", ")", ")", ";", "FLog", ".", "d", "(", "\"name=\"", "+", "saved_file_f", ".", "getName", "(", ")", ")", ";", "FLog", ".", "d", "(", "\"mime=\"", "+", "mimeType", ")", ";", "ContentResolver", "contentResolver", "=", "getContentResolver", "(", ")", ";", "ContentValues", "values", "=", "new", "ContentValues", "(", "7", ")", ";", "values", ".", "put", "(", "Images", ".", "Media", ".", "TITLE", ",", "saved_file_f", ".", "getName", "(", ")", ")", ";", "values", ".", "put", "(", "Images", ".", "Media", ".", "DISPLAY_NAME", ",", "saved_file_f", ".", "getName", "(", ")", ")", ";", "values", ".", "put", "(", "Images", ".", "Media", ".", "DATE_TAKEN", ",", "System", ".", "currentTimeMillis", "(", ")", ")", ";", "values", ".", "put", "(", "Images", ".", "Media", ".", "MIME_TYPE", ",", "mimeType", ")", ";", "values", ".", "put", "(", "Images", ".", "Media", ".", "ORIENTATION", ",", "0", ")", ";", "values", ".", "put", "(", "Images", ".", "Media", ".", "DATA", ",", "saved_file_f", ".", "getPath", "(", ")", ")", ";", "values", ".", "put", "(", "Images", ".", "Media", ".", "SIZE", ",", "saved_file_f", ".", "length", "(", ")", ")", ";", "contentResolver", ".", "insert", "(", "Images", ".", "Media", ".", "EXTERNAL_CONTENT_URI", ",", "values", ")", ";", "}", "else", "{", "if", "(", "fthread", ".", "toast", "!=", "null", ")", "{", "fthread", ".", "toast", ".", "cancel", "(", ")", ";", "}", "fthread", ".", "toast", "=", "Toast", ".", "makeText", "(", "fthread", ",", "\"-UNK-\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ";", "fthread", ".", "toast", ".", "show", "(", ")", ";", "}", "}", "}", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "waitDialog", ".", "dismiss", "(", ")", ";", "}", "}", "public", "void", "onClickSearchButton", "(", "View", "v", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "if", "(", "true", ")", "{", "EditText", "searchEdit", "=", "(", "EditText", ")", "findViewById", "(", "id", ".", "searchinput", ")", ";", "String", "searchText", "=", "searchEdit", ".", "getText", "(", ")", ".", "toString", "(", ")", ";", "String", "[", "]", "queries", "=", "StringUtil", ".", "querySplit", "(", "searchText", ")", ";", "adapter", ".", "searchQueries", "=", "queries", ";", "boolean", "found", "=", "false", ";", "for", "(", "int", "i", "=", "listView", ".", "getFirstVisiblePosition", "(", ")", "+", "1", ";", "i", "<", "statuses", ".", "size", "(", ")", ";", "++", "i", ")", "{", "String", "text", "=", "statuses", ".", "get", "(", "i", ")", ".", "text", ";", "if", "(", "StringUtil", ".", "isQueryMatchOr", "(", "text", ",", "queries", ",", "false", ")", ")", "{", "listView", ".", "setSelection", "(", "i", ")", ";", "found", "=", "true", ";", "break", ";", "}", "}", "if", "(", "!", "found", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "Math", ".", "min", "(", "listView", ".", "getFirstVisiblePosition", "(", ")", "+", "1", ",", "statuses", ".", "size", "(", ")", ")", ";", "++", "i", ")", "{", "String", "text", "=", "statuses", ".", "get", "(", "i", ")", ".", "text", ";", "if", "(", "StringUtil", ".", "isQueryMatchOr", "(", "text", ",", "queries", ",", "false", ")", ")", "{", "listView", ".", "setSelection", "(", "i", ")", ";", "found", "=", "true", ";", "if", "(", "true", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "\"\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "break", ";", "}", "}", "}", "if", "(", "!", "found", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "\"-UNK-\"", "+", "searchText", "+", "\"\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "InputMethodManager", "imm", "=", "(", "InputMethodManager", ")", "getSystemService", "(", "INPUT_METHOD_SERVICE", ")", ";", "imm", ".", "hideSoftInputFromWindow", "(", "v", ".", "getWindowToken", "(", ")", ",", "0", ")", ";", "}", "}", "public", "void", "onClickSearchHideButton", "(", "View", "v", ")", "{", "LinearLayout", "searchBar", "=", "(", "LinearLayout", ")", "findViewById", "(", "id", ".", "search_bar", ")", ";", "searchBar", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "InputMethodManager", "imm", "=", "(", "InputMethodManager", ")", "getSystemService", "(", "INPUT_METHOD_SERVICE", ")", ";", "imm", ".", "hideSoftInputFromWindow", "(", "v", ".", "getWindowToken", "(", ")", ",", "0", ")", ";", "}", "public", "boolean", "onSearchRequested", "(", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "if", "(", "true", ")", "{", "LinearLayout", "searchBar", "=", "(", "LinearLayout", ")", "findViewById", "(", "id", ".", "search_bar", ")", ";", "if", "(", "searchBar", ".", "getVisibility", "(", ")", "==", "View", ".", "GONE", ")", "{", "searchBar", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "}", "else", "{", "searchBar", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "InputMethodManager", "imm", "=", "(", "InputMethodManager", ")", "getSystemService", "(", "INPUT_METHOD_SERVICE", ")", ";", "imm", ".", "hideSoftInputFromWindow", "(", "getCurrentFocus", "(", ")", ".", "getWindowToken", "(", ")", ",", "0", ")", ";", "}", "}", "return", "false", ";", "}", "@", "Override", "public", "void", "onPause", "(", ")", "{", "super", ".", "onPause", "(", ")", ";", "int", "seeAt", "=", "listView", ".", "getFirstVisiblePosition", "(", ")", ";", "try", "{", "HistoryManager", "man", "=", "new", "HistoryManager", "(", ")", ";", "man", ".", "Load", "(", ")", ";", "FutabaThreadContent", "thread", "=", "new", "FutabaThreadContent", "(", ")", ";", "thread", ".", "seeAt", "=", "seeAt", ";", "thread", ".", "threadNum", "=", "threadNum", ";", "FLog", ".", "d", "(", "\"seeAt=\"", "+", "seeAt", ")", ";", "man", ".", "updateThread", "(", "thread", ")", ";", "man", ".", "Save", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "public", "boolean", "dispatchKeyEvent", "(", "KeyEvent", "event", ")", "{", "FLog", ".", "d", "(", "\"\"", "+", "event", ".", "getAction", "(", ")", ")", ";", "int", "action", "=", "event", ".", "getAction", "(", ")", ";", "int", "keyCode", "=", "event", ".", "getKeyCode", "(", ")", ";", "if", "(", "keyCode", "==", "KeyEvent", ".", "KEYCODE_VOLUME_DOWN", ")", "{", "if", "(", "action", "==", "KeyEvent", ".", "ACTION_UP", ")", "{", "FLog", ".", "d", "(", "\"vdown\"", "+", "listView", ".", "getFirstVisiblePosition", "(", ")", ")", ";", "int", "topPositionY", "=", "listView", ".", "getChildAt", "(", "0", ")", ".", "getTop", "(", ")", ";", "WindowManager", "wm", "=", "(", "WindowManager", ")", "getSystemService", "(", "Context", ".", "WINDOW_SERVICE", ")", ";", "Display", "disp", "=", "wm", ".", "getDefaultDisplay", "(", ")", ";", "int", "height", "=", "disp", ".", "getHeight", "(", ")", ";", "listView", ".", "setSelectionFromTop", "(", "listView", ".", "getFirstVisiblePosition", "(", ")", ",", "topPositionY", "-", "(", "height", "-", "200", ")", ")", ";", "}", "return", "true", ";", "}", "else", "if", "(", "keyCode", "==", "KeyEvent", ".", "KEYCODE_VOLUME_UP", ")", "{", "if", "(", "action", "==", "KeyEvent", ".", "ACTION_UP", ")", "{", "int", "topPositionY", "=", "listView", ".", "getChildAt", "(", "0", ")", ".", "getTop", "(", ")", ";", "WindowManager", "wm", "=", "(", "WindowManager", ")", "getSystemService", "(", "Context", ".", "WINDOW_SERVICE", ")", ";", "Display", "disp", "=", "wm", ".", "getDefaultDisplay", "(", ")", ";", "int", "height", "=", "disp", ".", "getHeight", "(", ")", ";", "listView", ".", "setSelectionFromTop", "(", "listView", ".", "getFirstVisiblePosition", "(", ")", ",", "topPositionY", "+", "(", "height", "-", "200", ")", ")", ";", "}", "return", "true", ";", "}", "return", "super", ".", "dispatchKeyEvent", "(", "event", ")", ";", "}", "@", "Override", "public", "void", "onConfigurationChanged", "(", "Configuration", "newConfig", ")", "{", "super", ".", "onConfigurationChanged", "(", "newConfig", ")", ";", "}", "}", "</s>" ]
8,267
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "CookieStore", ";", "import", "org", ".", "apache", ".", "http", ".", "cookie", ".", "Cookie", ";", "import", "org", ".", "apache", ".", "http", ".", "impl", ".", "client", ".", "DefaultHttpClient", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "java", ".", "util", ".", "List", ";", "public", "class", "FutabaCookieManager", "{", "static", "List", "<", "Cookie", ">", "data", "=", "null", ";", "public", "static", "void", "saveCookie", "(", "DefaultHttpClient", "httpClient", ")", "{", "data", "=", "httpClient", ".", "getCookieStore", "(", ")", ".", "getCookies", "(", ")", ";", "}", "public", "static", "void", "loadCookie", "(", "DefaultHttpClient", "httpClient", ")", "{", "if", "(", "data", "!=", "null", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "data", ".", "size", "(", ")", ";", "i", "++", ")", "{", "FLog", ".", "d", "(", "\"cookie:", "\"", "+", "data", ".", "get", "(", "i", ")", ".", "toString", "(", ")", ")", ";", "httpClient", ".", "getCookieStore", "(", ")", ".", "addCookie", "(", "data", ".", "get", "(", "i", ")", ")", ";", "}", "}", "}", "public", "static", "void", "PrintCookie", "(", ")", "{", "if", "(", "data", "==", "null", "||", "data", ".", "isEmpty", "(", ")", ")", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "}", "else", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "data", ".", "size", "(", ")", ";", "i", "++", ")", "{", "FLog", ".", "d", "(", "\"1", "\"", "+", "data", ".", "get", "(", "i", ")", ".", "toString", "(", ")", ")", ";", "}", "}", "}", "}", "</s>" ]
8,268
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "android", ".", "app", ".", "Activity", ";", "import", "android", ".", "graphics", ".", "Bitmap", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "io", ".", "ByteArrayOutputStream", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "net", ".", "URL", ";", "public", "class", "ImageCache", "{", "public", "static", "Bitmap", "getImage", "(", "String", "url", ")", "{", "String", "urlHash", "=", "FutabaCrypt", ".", "createDigest", "(", "url", ")", ";", "try", "{", "if", "(", "SDCard", ".", "cacheExist", "(", "urlHash", ")", ")", "{", "return", "SDCard", ".", "loadBitmapCache", "(", "urlHash", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "return", "null", ";", "}", "private", "static", "byte", "[", "]", "bmp2data", "(", "Bitmap", "src", ",", "Bitmap", ".", "CompressFormat", "format", ",", "int", "quality", ")", "{", "ByteArrayOutputStream", "os", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "src", ".", "compress", "(", "format", ",", "quality", ",", "os", ")", ";", "return", "os", ".", "toByteArray", "(", ")", ";", "}", "public", "static", "boolean", "setImage", "(", "String", "url", ")", "{", "String", "urlHash", "=", "FutabaCrypt", ".", "createDigest", "(", "url", ")", ";", "try", "{", "SDCard", ".", "saveFromURL", "(", "urlHash", ",", "new", "URL", "(", "url", ")", ",", "true", ")", ";", "return", "true", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "return", "false", ";", "}", "public", "static", "boolean", "setImageFromBitmap", "(", "String", "url", ",", "Bitmap", "bmp", ")", "{", "String", "urlHash", "=", "FutabaCrypt", ".", "createDigest", "(", "url", ")", ";", "byte", "[", "]", "bytes", "=", "bmp2data", "(", "bmp", ",", "Bitmap", ".", "CompressFormat", ".", "PNG", ",", "100", ")", ";", "try", "{", "SDCard", ".", "saveBin", "(", "urlHash", ",", "bytes", ",", "true", ")", ";", "return", "true", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "return", "false", ";", "}", "public", "static", "File", "saveImage", "(", "String", "url", ")", "{", "String", "urlHash", "=", "FutabaCrypt", ".", "createDigest", "(", "url", ")", ";", "File", "file", "=", "new", "File", "(", "url", ")", ";", "if", "(", "SDCard", ".", "cacheExist", "(", "urlHash", ")", ")", "{", "try", "{", "return", "SDCard", ".", "copyCacheToFile", "(", "urlHash", ",", "file", ".", "getName", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "else", "{", "}", "return", "null", ";", "}", "public", "static", "File", "saveImageToThread", "(", "String", "url", ",", "String", "threadName", ")", "{", "String", "urlHash", "=", "FutabaCrypt", ".", "createDigest", "(", "url", ")", ";", "File", "file", "=", "new", "File", "(", "url", ")", ";", "if", "(", "SDCard", ".", "cacheExist", "(", "urlHash", ")", ")", "{", "try", "{", "return", "SDCard", ".", "copyCacheToThreadFile", "(", "urlHash", ",", "file", ".", "getName", "(", ")", ",", "threadName", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "else", "{", "}", "return", "null", ";", "}", "public", "static", "void", "GC", "(", ")", "{", "}", "}", "</s>" ]
8,269
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "SharedPreferences", ";", "import", "android", ".", "content", ".", "SharedPreferences", ".", "Editor", ";", "import", "android", ".", "preference", ".", "PreferenceManager", ";", "public", "class", "StateMan", "{", "private", "final", "static", "String", "PREFNAME", "=", "\"ftbtpref\"", ";", "private", "final", "static", "String", "SORTKEY", "=", "\"catalogSort\"", ";", "public", "static", "int", "getSortParam", "(", "Context", "context", ")", "{", "SharedPreferences", "pref", "=", "context", ".", "getSharedPreferences", "(", "PREFNAME", ",", "Context", ".", "MODE_PRIVATE", ")", ";", "int", "sorttype", "=", "pref", ".", "getInt", "(", "SORTKEY", ",", "0", ")", ";", "return", "sorttype", ";", "}", "public", "static", "void", "setSortParam", "(", "Context", "context", ",", "int", "i", ")", "{", "SharedPreferences", "pref", "=", "context", ".", "getSharedPreferences", "(", "PREFNAME", ",", "Context", ".", "MODE_PRIVATE", ")", ";", "Editor", "e", "=", "pref", ".", "edit", "(", ")", ";", "e", ".", "putInt", "(", "SORTKEY", ",", "i", ")", ";", "e", ".", "commit", "(", ")", ";", "}", "private", "static", "int", "getFontSizeSetting", "(", "Context", "context", ")", "{", "int", "fontSizeSetting", "=", "0", ";", "try", "{", "SharedPreferences", "preferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "context", ")", ";", "fontSizeSetting", "=", "Integer", ".", "parseInt", "(", "preferences", ".", "getString", "(", "\"\"", ",", "\"0\"", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "return", "0", ";", "}", "return", "fontSizeSetting", ";", "}", "public", "static", "float", "getMainFontSize", "(", "Context", "context", ")", "{", "int", "fontSizeSetting", "=", "getFontSizeSetting", "(", "context", ")", ";", "return", "16.0f", "+", "fontSizeSetting", ";", "}", "public", "static", "float", "getDescFontSize", "(", "Context", "context", ")", "{", "int", "fontSizeSetting", "=", "getFontSizeSetting", "(", "context", ")", ";", "return", "14.0f", "+", "fontSizeSetting", ";", "}", "public", "static", "float", "getBBSFontSize", "(", "Context", "context", ")", "{", "int", "fontSizeSetting", "=", "getFontSizeSetting", "(", "context", ")", ";", "return", "16.0f", "+", "fontSizeSetting", "*", "0.5f", ";", "}", "public", "static", "float", "getBBSDescFontSize", "(", "Context", "context", ")", "{", "int", "fontSizeSetting", "=", "getFontSizeSetting", "(", "context", ")", ";", "return", "14.0f", "+", "fontSizeSetting", "*", "0.5f", ";", "}", "public", "static", "float", "getTabFontSize", "(", "Context", "context", ")", "{", "int", "fontSizeSetting", "=", "getFontSizeSetting", "(", "context", ")", ";", "return", "20.0f", "+", "fontSizeSetting", ";", "}", "public", "static", "boolean", "getVerticalThreadRow", "(", "Context", "context", ")", "{", "boolean", "verticalThreadRow", "=", "false", ";", "try", "{", "SharedPreferences", "preferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "context", ")", ";", "verticalThreadRow", "=", "!", "preferences", ".", "getBoolean", "(", "\"\"", ",", "false", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "return", "false", ";", "}", "FLog", ".", "d", "(", "\"\"", "+", "verticalThreadRow", ")", ";", "return", "verticalThreadRow", ";", "}", "public", "static", "int", "getThreadRowResourceId", "(", "Context", "context", ")", "{", "if", "(", "getVerticalThreadRow", "(", "context", ")", ")", "{", "return", "R", ".", "layout", ".", "futaba_thread_row", ";", "}", "else", "{", "return", "R", ".", "layout", ".", "futaba_thread_row_yoko", ";", "}", "}", "}", "</s>" ]
8,270
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "widget", ".", "AdapterView", ";", "import", "android", ".", "widget", ".", "Button", ";", "import", "android", ".", "widget", ".", "LinearLayout", ";", "import", "android", ".", "widget", ".", "ListView", ";", "import", "android", ".", "widget", ".", "TextView", ";", "import", "android", ".", "widget", ".", "Toast", ";", "import", "android", ".", "graphics", ".", "Typeface", ";", "import", "android", ".", "view", ".", "ViewGroup", ";", "import", "android", ".", "widget", ".", "ArrayAdapter", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "view", ".", "LayoutInflater", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "os", ".", "AsyncTask", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "io", ".", "ByteArrayOutputStream", ";", "import", "java", ".", "io", ".", "BufferedOutputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "BufferedInputStream", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "java", ".", "net", ".", "HttpURLConnection", ";", "import", "android", ".", "graphics", ".", "Bitmap", ";", "import", "android", ".", "graphics", ".", "BitmapFactory", ";", "import", "android", ".", "widget", ".", "ImageView", ";", "import", "android", ".", "view", ".", "WindowManager", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "view", ".", "Display", ";", "import", "java", ".", "lang", ".", "Thread", ";", "public", "class", "FutabaBBSMenuAdapter", "extends", "ArrayAdapter", "{", "public", "ArrayList", "items", ";", "private", "LayoutInflater", "inflater", ";", "public", "FutabaBBSMenuAdapter", "(", "Context", "context", ",", "int", "textViewResourceId", ",", "ArrayList", "items", ")", "{", "super", "(", "context", ",", "textViewResourceId", ",", "items", ")", ";", "try", "{", "this", ".", "items", "=", "items", ";", "this", ".", "inflater", "=", "(", "LayoutInflater", ")", "context", ".", "getSystemService", "(", "Context", ".", "LAYOUT_INFLATER_SERVICE", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "@", "Override", "public", "View", "getView", "(", "int", "position", ",", "View", "convertView", ",", "ViewGroup", "parent", ")", "{", "View", "view", "=", "convertView", ";", "try", "{", "if", "(", "view", "==", "null", ")", "{", "view", "=", "inflater", ".", "inflate", "(", "R", ".", "layout", ".", "futaba_bbs_row", ",", "null", ")", ";", "}", "final", "FutabaBBSContent", "item", "=", "(", "FutabaBBSContent", ")", "items", ".", "get", "(", "position", ")", ";", "if", "(", "item", "!=", "null", ")", "{", "TextView", "url", "=", "(", "TextView", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "url", ")", ";", "url", ".", "setTextSize", "(", "StateMan", ".", "getBBSDescFontSize", "(", "getContext", "(", ")", ")", ")", ";", "url", ".", "setText", "(", "item", ".", "url", ")", ";", "TextView", "name", "=", "(", "TextView", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "name", ")", ";", "name", ".", "setTextSize", "(", "StateMan", ".", "getBBSFontSize", "(", "getContext", "(", ")", ")", ")", ";", "name", ".", "setText", "(", "item", ".", "name", ")", ";", "final", "Button", "buttonFavorite", "=", "(", "Button", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "favorite_btn", ")", ";", "final", "FutabaBBSMenu", "activity", "=", "(", "FutabaBBSMenu", ")", "getContext", "(", ")", ";", "if", "(", "true", ")", "{", "if", "(", "!", "item", ".", "faved", ")", "{", "buttonFavorite", ".", "setBackgroundDrawable", "(", "getContext", "(", ")", ".", "getResources", "(", ")", ".", "getDrawable", "(", "R", ".", "drawable", ".", "star_big_off", ")", ")", ";", "}", "else", "{", "buttonFavorite", ".", "setBackgroundDrawable", "(", "getContext", "(", ")", ".", "getResources", "(", ")", ".", "getDrawable", "(", "R", ".", "drawable", ".", "star_big_on", ")", ")", ";", "}", "}", "else", "{", "buttonFavorite", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "}", "final", "ViewGroup", "view_parent", "=", "parent", ";", "buttonFavorite", ".", "setOnClickListener", "(", "new", "View", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "View", "v", ")", "{", "if", "(", "activity", ".", "mode", ".", "equals", "(", "\"all\"", ")", ")", "{", "if", "(", "!", "item", ".", "faved", ")", "{", "ftbt", "ftbt_top", "=", "(", "ftbt", ")", "activity", ".", "getParent", "(", ")", ";", "item", ".", "faved", "=", "true", ";", "ftbt_top", ".", "addFavoriteBBSs", "(", "item", ")", ";", "FutabaBBSMenu", "activity", "=", "(", "FutabaBBSMenu", ")", "getContext", "(", ")", ";", "activity", ".", "adapter", ".", "notifyDataSetChanged", "(", ")", ";", "Toast", ".", "makeText", "(", "activity", ",", "item", ".", "name", "+", "\"\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "else", "{", "ftbt", "ftbt_top", "=", "(", "ftbt", ")", "activity", ".", "getParent", "(", ")", ";", "item", ".", "faved", "=", "false", ";", "ftbt_top", ".", "removeFavoriteBBSs", "(", "item", ")", ";", "Toast", ".", "makeText", "(", "activity", ",", "item", ".", "name", "+", "\"\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "}", "else", "{", "ftbt", "ftbt_top", "=", "(", "ftbt", ")", "activity", ".", "getParent", "(", ")", ";", "item", ".", "faved", "=", "false", ";", "ftbt_top", ".", "removeFavoriteBBSs", "(", "item", ")", ";", "Toast", ".", "makeText", "(", "activity", ",", "item", ".", "name", "+", "\"\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "view_parent", ".", "invalidate", "(", ")", ";", "notifyDataSetChanged", "(", ")", ";", "}", "}", ")", ";", "LinearLayout", "ll_main", "=", "(", "LinearLayout", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "ll_main", ")", ";", "ll_main", ".", "setOnClickListener", "(", "new", "View", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "View", "v", ")", "{", "FLog", ".", "d", "(", "\"onclick_bbs\"", ")", ";", "FutabaBBSMenu", "activity", "=", "(", "FutabaBBSMenu", ")", "getContext", "(", ")", ";", "activity", ".", "transSetting", "(", "item", ")", ";", "}", "}", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "return", "view", ";", "}", "}", "</s>" ]
8,271
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "io", ".", "BufferedReader", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStreamReader", ";", "import", "android", ".", "util", ".", "Log", ";", "public", "class", "FileToString", "{", "public", "static", "String", "fileToString", "(", "File", "file", ",", "String", "encoding", ")", "throws", "IOException", "{", "BufferedReader", "br", "=", "null", ";", "try", "{", "br", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "new", "FileInputStream", "(", "file", ")", ",", "encoding", ")", ")", ";", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "int", "c", ";", "while", "(", "(", "c", "=", "br", ".", "read", "(", ")", ")", "!=", "-", "1", ")", "{", "sb", ".", "append", "(", "(", "char", ")", "c", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "finally", "{", "br", ".", "close", "(", ")", ";", "}", "}", "}", "</s>" ]
8,272
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "view", ".", "LayoutInflater", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "view", ".", "ViewGroup", ";", "import", "android", ".", "widget", ".", "ArrayAdapter", ";", "import", "android", ".", "widget", ".", "Button", ";", "import", "android", ".", "widget", ".", "TextView", ";", "import", "android", ".", "widget", ".", "Toast", ";", "public", "class", "FocusEditAdapter", "extends", "ArrayAdapter", "{", "public", "ArrayList", "<", "String", ">", "items", ";", "private", "LayoutInflater", "inflater", ";", "private", "Context", "context", ";", "public", "FocusEditAdapter", "(", "Context", "context", ",", "int", "textViewResourceId", ",", "ArrayList", "items", ")", "{", "super", "(", "context", ",", "textViewResourceId", ",", "items", ")", ";", "this", ".", "items", "=", "(", "ArrayList", "<", "String", ">", ")", "items", ";", "this", ".", "context", "=", "context", ";", "this", ".", "inflater", "=", "(", "LayoutInflater", ")", "context", ".", "getSystemService", "(", "Context", ".", "LAYOUT_INFLATER_SERVICE", ")", ";", "}", "@", "Override", "public", "View", "getView", "(", "int", "position", ",", "View", "convertView", ",", "ViewGroup", "parent", ")", "{", "View", "view", "=", "convertView", ";", "if", "(", "view", "==", "null", ")", "{", "view", "=", "inflater", ".", "inflate", "(", "R", ".", "layout", ".", "focuswords_row", ",", "null", ")", ";", "}", "final", "String", "item", "=", "(", "String", ")", "items", ".", "get", "(", "position", ")", ";", "view", "=", "inflater", ".", "inflate", "(", "R", ".", "layout", ".", "focuswords_row", ",", "null", ")", ";", "TextView", "word_v", "=", "(", "TextView", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "word", ")", ";", "word_v", ".", "setText", "(", "item", ")", ";", "final", "FocusEditAdapter", "adapter", "=", "this", ";", "final", "int", "position_f", "=", "position", ";", "Button", "delWordButton", "=", "(", "Button", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "delword", ")", ";", "delWordButton", ".", "setOnClickListener", "(", "new", "View", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "View", "v", ")", "{", "try", "{", "adapter", ".", "deleteAt", "(", "position_f", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", ")", ";", "return", "view", ";", "}", "public", "void", "deleteAt", "(", "int", "position", ")", "{", "String", "text", "=", "this", ".", "items", ".", "get", "(", "position", ")", ";", "this", ".", "items", ".", "remove", "(", "position", ")", ";", "notifyDataSetChanged", "(", ")", ";", "try", "{", "FocusedSettings", ".", "set", "(", "getContext", "(", ")", ",", "this", ".", "items", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "Toast", ".", "makeText", "(", "getContext", "(", ")", ",", "\"-UNK-\"", "+", "text", "+", "\"\"", ",", "Toast", ".", "LENGTH_LONG", ")", ".", "show", "(", ")", ";", "}", "public", "void", "addLast", "(", "String", "elem", ")", "{", "this", ".", "items", ".", "add", "(", "elem", ")", ";", "this", ".", "notifyDataSetChanged", "(", ")", ";", "try", "{", "FocusedSettings", ".", "set", "(", "getContext", "(", ")", ",", "this", ".", "items", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", "</s>" ]
8,273
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "io", ".", "Serializable", ";", "public", "class", "FutabaThreadContent", "implements", "Serializable", "{", "private", "static", "final", "long", "serialVersionUID", "=", "3L", ";", "public", "String", "userName", ";", "public", "String", "title", ";", "public", "String", "text", ";", "public", "String", "mailTo", ";", "public", "int", "id", ";", "public", "String", "imgURL", ";", "public", "int", "threadNum", ";", "public", "int", "threadNumPrev", ";", "public", "String", "baseUrl", ";", "public", "String", "resNum", ";", "public", "String", "BBSName", ";", "public", "int", "pointAt", ";", "public", "int", "seeAt", ";", "public", "long", "lastAccessed", ";", "public", "boolean", "isChecked", "=", "false", ";", "FutabaThreadContent", "(", ")", "{", "userName", "=", "\"\"", ";", "title", "=", "\"\"", ";", "text", "=", "\"\"", ";", "mailTo", "=", "\"\"", ";", "id", "=", "0", ";", "resNum", "=", "\"\"", ";", "BBSName", "=", "\"\"", ";", "baseUrl", "=", "\"\"", ";", "resNum", "=", "\"0\"", ";", "lastAccessed", "=", "0", ";", "pointAt", "=", "0", ";", "seeAt", "=", "0", ";", "}", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "userName", "+", "\"", "title=\"", "+", "title", "+", "\"", "text=\"", "+", "text", "+", "\"", "mailTo=\"", "+", "mailTo", "+", "\"", "id=\"", "+", "id", "+", "\"", "imgURL=\"", "+", "imgURL", "+", "\"", "threadNum=\"", "+", "threadNum", "+", "\"", "baseUrl=\"", "+", "baseUrl", "+", "\"", "resNum=\"", "+", "resNum", "+", "\"", "BBSName=\"", "+", "BBSName", "+", "\"\"", "+", "lastAccessed", "+", "\"", "isChecked=\"", "+", "isChecked", "+", "\"", "pointAt=\"", "+", "pointAt", ";", "}", "public", "static", "FutabaThreadContent", "createBlank", "(", ")", "{", "FutabaThreadContent", "st", "=", "new", "FutabaThreadContent", "(", ")", ";", "st", ".", "id", "=", "-", "1", ";", "return", "st", ";", "}", "public", "static", "boolean", "isBlank", "(", "FutabaThreadContent", "thread", ")", "{", "return", "thread", ".", "id", "==", "-", "1", ";", "}", "public", "static", "FutabaThreadContent", "createMenu1", "(", ")", "{", "FutabaThreadContent", "st", "=", "new", "FutabaThreadContent", "(", ")", ";", "st", ".", "text", "=", "\"-UNK-\"", ";", "st", ".", "id", "=", "-", "2", ";", "return", "st", ";", "}", "public", "static", "FutabaThreadContent", "createMenu2", "(", ")", "{", "FutabaThreadContent", "st", "=", "new", "FutabaThreadContent", "(", ")", ";", "st", ".", "text", "=", "\"-UNK-\"", ";", "st", ".", "id", "=", "-", "3", ";", "return", "st", ";", "}", "public", "static", "boolean", "isMenu1", "(", "FutabaThreadContent", "st", ")", "{", "return", "st", ".", "id", "==", "-", "2", ";", "}", "public", "static", "boolean", "isMenu2", "(", "FutabaThreadContent", "st", ")", "{", "return", "st", ".", "id", "==", "-", "3", ";", "}", "}", "</s>" ]
8,274
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "io", ".", "ByteArrayOutputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "UnsupportedEncodingException", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "http", ".", "HttpResponse", ";", "import", "org", ".", "apache", ".", "http", ".", "HttpStatus", ";", "import", "org", ".", "apache", ".", "http", ".", "NameValuePair", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "ClientProtocolException", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "entity", ".", "UrlEncodedFormEntity", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "methods", ".", "HttpGet", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "methods", ".", "HttpPost", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "params", ".", "ClientPNames", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "params", ".", "CookiePolicy", ";", "import", "org", ".", "apache", ".", "http", ".", "impl", ".", "client", ".", "DefaultHttpClient", ";", "import", "org", ".", "apache", ".", "http", ".", "message", ".", "BasicNameValuePair", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "SharedPreferences", ";", "import", "android", ".", "preference", ".", "PreferenceManager", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "webkit", ".", "CookieManager", ";", "public", "class", "CatalogHtmlReader", "{", "public", "static", "String", "Read", "(", "String", "urlStr", ",", "Context", "context", ",", "int", "sortType", ")", "throws", "Exception", "{", "CookieManager", ".", "getInstance", "(", ")", ".", "setAcceptCookie", "(", "true", ")", ";", "CookieManager", ".", "getInstance", "(", ")", ".", "removeExpiredCookie", "(", ")", ";", "int", "catalogX", "=", "10", ";", "int", "catalogY", "=", "5", ";", "String", "threadStrNum", "=", "\"50\"", ";", "try", "{", "SharedPreferences", "preferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "context", ")", ";", "int", "temp", "=", "Integer", ".", "parseInt", "(", "preferences", ".", "getString", "(", "\"\"", ",", "\"50\"", ")", ")", ";", "catalogX", "=", "temp", "/", "5", ";", "threadStrNum", "=", "preferences", ".", "getString", "(", "\"threadStrNum\"", ",", "\"50\"", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "DefaultHttpClient", "httpClient", ";", "httpClient", "=", "new", "DefaultHttpClient", "(", ")", ";", "FutabaCookieManager", ".", "loadCookie", "(", "httpClient", ")", ";", "httpClient", ".", "getParams", "(", ")", ".", "setParameter", "(", "ClientPNames", ".", "COOKIE_POLICY", ",", "CookiePolicy", ".", "BROWSER_COMPATIBILITY", ")", ";", "httpClient", ".", "getParams", "(", ")", ".", "setParameter", "(", "\"\"", ",", "5000", ")", ";", "httpClient", ".", "getParams", "(", ")", ".", "setParameter", "(", "\"\"", ",", "3000", ")", ";", "HttpPost", "httppost", "=", "new", "HttpPost", "(", "urlStr", ")", ";", "List", "<", "NameValuePair", ">", "nameValuePair", "=", "new", "ArrayList", "<", "NameValuePair", ">", "(", "4", ")", ";", "nameValuePair", ".", "add", "(", "new", "BasicNameValuePair", "(", "\"mode\"", ",", "\"catset\"", ")", ")", ";", "nameValuePair", ".", "add", "(", "new", "BasicNameValuePair", "(", "\"cx\"", ",", "String", ".", "valueOf", "(", "catalogX", ")", ")", ")", ";", "nameValuePair", ".", "add", "(", "new", "BasicNameValuePair", "(", "\"cy\"", ",", "String", ".", "valueOf", "(", "catalogY", ")", ")", ")", ";", "nameValuePair", ".", "add", "(", "new", "BasicNameValuePair", "(", "\"cl\"", ",", "threadStrNum", ")", ")", ";", "String", "urlStrAppend", "=", "urlStr", "+", "\"?mode=cat\"", ";", "if", "(", "sortType", ">", "0", "&&", "sortType", "<", "5", ")", "{", "urlStrAppend", "+=", "\"&sort=\"", "+", "sortType", ";", "}", "String", "data", "=", "null", ";", "httppost", ".", "setEntity", "(", "new", "UrlEncodedFormEntity", "(", "nameValuePair", ")", ")", ";", "HttpResponse", "response", "=", "httpClient", ".", "execute", "(", "httppost", ")", ";", "ByteArrayOutputStream", "byteArrayOutputStream", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "response", ".", "getEntity", "(", ")", ".", "writeTo", "(", "byteArrayOutputStream", ")", ";", "HttpGet", "httpget", "=", "new", "HttpGet", "(", "urlStrAppend", ")", ";", "HttpResponse", "httpResponse", "=", "null", ";", "httpResponse", "=", "httpClient", ".", "execute", "(", "httpget", ")", ";", "FutabaCookieManager", ".", "saveCookie", "(", "httpClient", ")", ";", "int", "status", "=", "httpResponse", ".", "getStatusLine", "(", ")", ".", "getStatusCode", "(", ")", ";", "if", "(", "HttpStatus", ".", "SC_OK", "==", "status", ")", "{", "ByteArrayOutputStream", "outputStream", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "httpResponse", ".", "getEntity", "(", ")", ".", "writeTo", "(", "outputStream", ")", ";", "SDCard", ".", "saveBin", "(", "FutabaCrypt", ".", "createDigest", "(", "urlStr", ")", ",", "outputStream", ".", "toByteArray", "(", ")", ",", "true", ")", ";", "data", "=", "outputStream", ".", "toString", "(", "\"SHIFT-JIS\"", ")", ";", "}", "else", "{", "FLog", ".", "d", "(", "\"\"", "+", "status", ")", ";", "throw", "new", "Exception", "(", "\"\"", ")", ";", "}", "return", "data", ";", "}", "}", "</s>" ]
8,275
[ "<s>", "package", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ";", "import", "java", ".", "io", ".", "ByteArrayOutputStream", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "net", ".", "URI", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "nio", ".", "charset", ".", "Charset", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "http", ".", "Header", ";", "import", "org", ".", "apache", ".", "http", ".", "HttpResponse", ";", "import", "org", ".", "apache", ".", "http", ".", "NameValuePair", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "CookieStore", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "entity", ".", "UrlEncodedFormEntity", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "methods", ".", "HttpGet", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "methods", ".", "HttpPost", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "params", ".", "ClientPNames", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "params", ".", "CookiePolicy", ";", "import", "org", ".", "apache", ".", "http", ".", "cookie", ".", "Cookie", ";", "import", "org", ".", "apache", ".", "http", ".", "impl", ".", "client", ".", "DefaultHttpClient", ";", "import", "org", ".", "apache", ".", "http", ".", "message", ".", "BasicNameValuePair", ";", "import", "cx", ".", "ath", ".", "dekosuke", ".", "ftbt", ".", "R", ".", "id", ";", "import", "android", ".", "app", ".", "Activity", ";", "import", "android", ".", "app", ".", "AlertDialog", ";", "import", "android", ".", "app", ".", "ProgressDialog", ";", "import", "android", ".", "content", ".", "DialogInterface", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "content", ".", "SharedPreferences", ";", "import", "android", ".", "database", ".", "Cursor", ";", "import", "android", ".", "graphics", ".", "Bitmap", ";", "import", "android", ".", "graphics", ".", "BitmapFactory", ";", "import", "android", ".", "graphics", ".", "Color", ";", "import", "android", ".", "net", ".", "Uri", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "os", ".", "Handler", ";", "import", "android", ".", "os", ".", "Message", ";", "import", "android", ".", "preference", ".", "PreferenceManager", ";", "import", "android", ".", "provider", ".", "MediaStore", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "view", ".", "Window", ";", "import", "android", ".", "view", ".", "WindowManager", ";", "import", "android", ".", "webkit", ".", "CookieManager", ";", "import", "android", ".", "webkit", ".", "CookieSyncManager", ";", "import", "android", ".", "widget", ".", "Button", ";", "import", "android", ".", "widget", ".", "EditText", ";", "import", "android", ".", "widget", ".", "TableLayout", ";", "import", "android", ".", "widget", ".", "TextView", ";", "import", "android", ".", "widget", ".", "Toast", ";", "import", "org", ".", "apache", ".", "http", ".", "entity", ".", "mime", ".", "HttpMultipartMode", ";", "import", "org", ".", "apache", ".", "http", ".", "entity", ".", "mime", ".", "MultipartEntity", ";", "import", "org", ".", "apache", ".", "http", ".", "entity", ".", "mime", ".", "content", ".", "FileBody", ";", "import", "org", ".", "apache", ".", "http", ".", "entity", ".", "mime", ".", "content", ".", "StringBody", ";", "public", "class", "Post", "extends", "Activity", "implements", "Runnable", "{", "public", "String", "urlStr", ";", "public", "int", "threadNum", ";", "public", "String", "threadURL", ";", "public", "String", "postText", ";", "ProgressDialog", "waitDialog", ";", "Thread", "thread", ";", "final", "int", "REQUEST_IMAGEPICK_CONSTANT", "=", "0x100200", ";", "Uri", "imageContent", "=", "null", ";", "boolean", "newthread", "=", "false", ";", "@", "Override", "public", "void", "onCreate", "(", "Bundle", "savedInstanceState", ")", "{", "super", ".", "onCreate", "(", "savedInstanceState", ")", ";", "if", "(", "getResources", "(", ")", ".", "getBoolean", "(", "R", ".", "bool", ".", "avoidsleep", ")", ")", "{", "Window", "window", "=", "getWindow", "(", ")", ";", "window", ".", "addFlags", "(", "WindowManager", ".", "LayoutParams", ".", "FLAG_KEEP_SCREEN_ON", ")", ";", "}", "try", "{", "FLog", ".", "d", "(", "\"\"", ")", ";", "Intent", "intent", "=", "getIntent", "(", ")", ";", "String", "baseURL", "=", "(", "String", ")", "intent", ".", "getSerializableExtra", "(", "\"baseURL\"", ")", ";", "threadNum", "=", "(", "Integer", ")", "intent", ".", "getSerializableExtra", "(", "\"threadNum\"", ")", ";", "postText", "=", "(", "String", ")", "intent", ".", "getSerializableExtra", "(", "\"postText\"", ")", ";", "if", "(", "threadNum", "==", "0", ")", "{", "newthread", "=", "true", ";", "}", "if", "(", "newthread", ")", "{", "threadURL", "=", "baseURL", ";", "}", "else", "{", "threadURL", "=", "baseURL", "+", "threadNum", ";", "}", "urlStr", "=", "baseURL", "+", "\"futaba.php\"", ";", "setContentView", "(", "R", ".", "layout", ".", "post", ")", ";", "TextView", "titleText", "=", "(", "TextView", ")", "findViewById", "(", "id", ".", "titletext", ")", ";", "if", "(", "newthread", ")", "{", "titleText", ".", "setText", "(", "\"-UNK-\"", ")", ";", "}", "EditText", "comment_v", "=", "(", "EditText", ")", "findViewById", "(", "id", ".", "comment", ")", ";", "if", "(", "postText", "!=", "null", ")", "{", "comment_v", ".", "setText", "(", "postText", ")", ";", "comment_v", ".", "setSelection", "(", "postText", ".", "length", "(", ")", ")", ";", "}", "String", "deleteKey", "=", "\"\"", ";", "try", "{", "SharedPreferences", "preferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "this", ")", ";", "deleteKey", "=", "preferences", ".", "getString", "(", "getString", "(", "R", ".", "string", ".", "deletekey", ")", ",", "\"\"", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "if", "(", "!", "deleteKey", ".", "equals", "(", "\"\"", ")", ")", "{", "TextView", "deleteKey_v", "=", "(", "TextView", ")", "findViewById", "(", "id", ".", "deletekey", ")", ";", "deleteKey_v", ".", "setText", "(", "deleteKey", ")", ";", "}", "FLog", ".", "d", "(", "\"deletekey=\"", "+", "deleteKey", ")", ";", "Button", "postbutton", "=", "(", "Button", ")", "findViewById", "(", "id", ".", "postbutton", ")", ";", "postbutton", ".", "setOnClickListener", "(", "new", "View", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "View", "v", ")", "{", "onClickPostButton", "(", "v", ")", ";", "}", "}", ")", ";", "Button", "imgchoosebutton", "=", "(", "Button", ")", "findViewById", "(", "id", ".", "imgchoosebutton", ")", ";", "imgchoosebutton", ".", "setOnClickListener", "(", "new", "View", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "View", "v", ")", "{", "onClickImageChooseButton", "(", "v", ")", ";", "}", "}", ")", ";", "CookieSyncManager", ".", "createInstance", "(", "this", ")", ";", "CookieSyncManager", ".", "getInstance", "(", ")", ".", "startSync", "(", ")", ";", "FutabaCookieManager", ".", "PrintCookie", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "@", "Override", "protected", "void", "onResume", "(", ")", "{", "super", ".", "onResume", "(", ")", ";", "CookieSyncManager", ".", "getInstance", "(", ")", ".", "stopSync", "(", ")", ";", "}", "@", "Override", "protected", "void", "onPause", "(", ")", "{", "super", ".", "onPause", "(", ")", ";", "CookieSyncManager", ".", "getInstance", "(", ")", ".", "sync", "(", ")", ";", "}", "public", "void", "setWait", "(", ")", "{", "waitDialog", "=", "new", "ProgressDialog", "(", "this", ")", ";", "waitDialog", ".", "setMessage", "(", "this", ".", "getString", "(", "R", ".", "string", ".", "loading", ")", ")", ";", "waitDialog", ".", "setProgressStyle", "(", "ProgressDialog", ".", "STYLE_SPINNER", ")", ";", "waitDialog", ".", "show", "(", ")", ";", "thread", "=", "new", "Thread", "(", "this", ")", ";", "thread", ".", "start", "(", ")", ";", "}", "public", "void", "run", "(", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "100", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "handler", ".", "sendEmptyMessage", "(", "0", ")", ";", "}", "private", "Handler", "handler", "=", "new", "Handler", "(", ")", "{", "public", "void", "handleMessage", "(", "Message", "msg", ")", "{", "try", "{", "loading", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "}", ";", "public", "void", "onClickPostButton", "(", "View", "v", ")", "{", "AlertDialog", ".", "Builder", "dlg", ";", "dlg", "=", "new", "AlertDialog", ".", "Builder", "(", "Post", ".", "this", ")", ";", "dlg", ".", "setTitle", "(", "\"-UNK-\"", ")", ";", "dlg", ".", "setCancelable", "(", "true", ")", ";", "dlg", ".", "setMessage", "(", "\"-UNK-\"", ")", ";", "dlg", ".", "setPositiveButton", "(", "\"OK\"", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "id", ")", "{", "Post", ".", "this", ".", "setWait", "(", ")", ";", "}", "}", ")", ";", "dlg", ".", "setNegativeButton", "(", "\"-UNK-\"", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "id", ")", "{", "}", "}", ")", ";", "dlg", ".", "show", "(", ")", ";", "}", "public", "void", "onClickImageChooseButton", "(", "View", "v", ")", "{", "Intent", "intent", "=", "new", "Intent", "(", "Intent", ".", "ACTION_PICK", ")", ";", "intent", ".", "setType", "(", "\"image/*\"", ")", ";", "startActivityForResult", "(", "intent", ",", "REQUEST_IMAGEPICK_CONSTANT", ")", ";", "}", "protected", "void", "onActivityResult", "(", "int", "requestCode", ",", "int", "resultCode", ",", "Intent", "data", ")", "{", "if", "(", "resultCode", "==", "RESULT_OK", "&&", "requestCode", "==", "REQUEST_IMAGEPICK_CONSTANT", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "\"-UNK-\"", "+", "data", ".", "getData", "(", ")", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "imageContent", "=", "data", ".", "getData", "(", ")", ";", "Button", "imgchoosebutton", "=", "(", "Button", ")", "findViewById", "(", "id", ".", "imgchoosebutton", ")", ";", "imgchoosebutton", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "TextView", "imgchoosenotify", "=", "(", "TextView", ")", "findViewById", "(", "id", ".", "imgchoosenotify", ")", ";", "imgchoosenotify", ".", "setText", "(", "\"-UNK-:\"", "+", "imageContent", ".", "toString", "(", ")", ")", ";", "imgchoosenotify", ".", "setTextColor", "(", "Color", ".", "RED", ")", ";", "}", "}", "private", "void", "loading", "(", ")", "{", "TextView", "name_v", "=", "(", "TextView", ")", "findViewById", "(", "id", ".", "name", ")", ";", "String", "name", "=", "name_v", ".", "getText", "(", ")", ".", "toString", "(", ")", ";", "TextView", "email_v", "=", "(", "TextView", ")", "findViewById", "(", "id", ".", "email", ")", ";", "String", "email", "=", "email_v", ".", "getText", "(", ")", ".", "toString", "(", ")", ";", "TextView", "comment_v", "=", "(", "TextView", ")", "findViewById", "(", "id", ".", "comment", ")", ";", "String", "comment", "=", "comment_v", ".", "getText", "(", ")", ".", "toString", "(", ")", ";", "TextView", "deletekey_v", "=", "(", "TextView", ")", "findViewById", "(", "id", ".", "deletekey", ")", ";", "String", "deletekey", "=", "deletekey_v", ".", "getText", "(", ")", ".", "toString", "(", ")", ";", "FLog", ".", "d", "(", "\"threadNum=\"", "+", "threadNum", ")", ";", "FLog", ".", "d", "(", "\"urlStr=\"", "+", "urlStr", ")", ";", "FLog", ".", "d", "(", "\"comment=\"", "+", "comment", ")", ";", "FLog", ".", "d", "(", "\"deletekey=\"", "+", "deletekey", ")", ";", "FLog", ".", "d", "(", "\"email=\"", "+", "email", ")", ";", "FLog", ".", "d", "(", "\"name=\"", "+", "name", ")", ";", "FLog", ".", "d", "(", "\"threadURL=\"", "+", "threadURL", ")", ";", "if", "(", "false", ")", "{", "return", ";", "}", "try", "{", "FLog", ".", "d", "(", "\"start", "post!\"", ")", ";", "DefaultHttpClient", "httpClient", ";", "httpClient", "=", "new", "DefaultHttpClient", "(", ")", ";", "FutabaCookieManager", ".", "loadCookie", "(", "httpClient", ")", ";", "httpClient", ".", "getParams", "(", ")", ".", "setParameter", "(", "ClientPNames", ".", "COOKIE_POLICY", ",", "CookiePolicy", ".", "BROWSER_COMPATIBILITY", ")", ";", "httpClient", ".", "getParams", "(", ")", ".", "setParameter", "(", "\"\"", ",", "5000", ")", ";", "httpClient", ".", "getParams", "(", ")", ".", "setParameter", "(", "\"\"", ",", "3000", ")", ";", "try", "{", "{", "List", "<", "Cookie", ">", "cookies", "=", "httpClient", ".", "getCookieStore", "(", ")", ".", "getCookies", "(", ")", ";", "if", "(", "true", ")", "{", "FLog", ".", "d", "(", "\"Cookie", "None\"", ")", ";", "Toast", ".", "makeText", "(", "this", ",", "\"\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "HttpGet", "httpGet", "=", "new", "HttpGet", "(", "urlStr", ")", ";", "HttpResponse", "httpResponse", "=", "null", ";", "httpResponse", "=", "httpClient", ".", "execute", "(", "httpGet", ")", ";", "ByteArrayOutputStream", "byteArrayOutputStream", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "httpResponse", ".", "getEntity", "(", ")", ".", "writeTo", "(", "byteArrayOutputStream", ")", ";", "String", "retData", "=", "byteArrayOutputStream", ".", "toString", "(", "\"Shift-JIS\"", ")", ";", "FutabaCookieManager", ".", "saveCookie", "(", "httpClient", ")", ";", "FLog", ".", "d", "(", "retData", ")", ";", "FLog", ".", "d", "(", "\"\"", ")", ";", "try", "{", "Thread", ".", "sleep", "(", "3000", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "}", "else", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "cookies", ".", "size", "(", ")", ";", "i", "++", ")", "{", "FLog", ".", "d", "(", "\"\"", "+", "cookies", ".", "get", "(", "i", ")", ".", "toString", "(", ")", ")", ";", "}", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "HttpPost", "httppost", "=", "new", "HttpPost", "(", "urlStr", ")", ";", "if", "(", "false", ")", "{", "}", "MultipartEntity", "entity", "=", "new", "MultipartEntity", "(", "HttpMultipartMode", ".", "BROWSER_COMPATIBLE", ")", ";", "Charset", "sjisCharset", "=", "Charset", ".", "forName", "(", "\"Shift_JIS\"", ")", ";", "entity", ".", "addPart", "(", "\"email\"", ",", "new", "StringBody", "(", "email", ",", "sjisCharset", ")", ")", ";", "entity", ".", "addPart", "(", "\"name\"", ",", "new", "StringBody", "(", "name", ",", "sjisCharset", ")", ")", ";", "entity", ".", "addPart", "(", "\"mode\"", ",", "new", "StringBody", "(", "\"regist\"", ")", ")", ";", "if", "(", "!", "newthread", ")", "{", "entity", ".", "addPart", "(", "\"resto\"", ",", "new", "StringBody", "(", "\"\"", "+", "threadNum", ")", ")", ";", "}", "entity", ".", "addPart", "(", "\"com\"", ",", "new", "StringBody", "(", "comment", ",", "sjisCharset", ")", ")", ";", "entity", ".", "addPart", "(", "\"sub\"", ",", "new", "StringBody", "(", "\"\"", ")", ")", ";", "entity", ".", "addPart", "(", "\"pwd\"", ",", "new", "StringBody", "(", "deletekey", ")", ")", ";", "if", "(", "imageContent", "!=", "null", ")", "{", "FLog", ".", "d", "(", "\"\"", "+", "imageContent", ")", ";", "FLog", ".", "d", "(", "\"getPath=\"", "+", "imageContent", ".", "getPath", "(", ")", ")", ";", "Cursor", "c", "=", "getContentResolver", "(", ")", ".", "query", "(", "imageContent", ",", "null", ",", "null", ",", "null", ",", "null", ")", ";", "c", ".", "moveToFirst", "(", ")", ";", "String", "filename", "=", "c", ".", "getString", "(", "c", ".", "getColumnIndex", "(", "MediaStore", ".", "MediaColumns", ".", "DATA", ")", ")", ";", "FLog", ".", "d", "(", "\"filename=\"", "+", "filename", ")", ";", "FileBody", "fileBody", "=", "new", "FileBody", "(", "new", "File", "(", "filename", ")", ")", ";", "entity", ".", "addPart", "(", "\"upfile\"", ",", "fileBody", ")", ";", "}", "httppost", ".", "setEntity", "(", "entity", ")", ";", "httppost", ".", "addHeader", "(", "\"referer\"", ",", "threadURL", ")", ";", "HttpResponse", "response", "=", "httpClient", ".", "execute", "(", "httppost", ")", ";", "FutabaCookieManager", ".", "saveCookie", "(", "httpClient", ")", ";", "ByteArrayOutputStream", "byteArrayOutputStream2", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "response", ".", "getEntity", "(", ")", ".", "writeTo", "(", "byteArrayOutputStream2", ")", ";", "String", "retData2", "=", "byteArrayOutputStream2", ".", "toString", "(", "\"Shift-JIS\"", ")", ";", "Log", ".", "v", "(", "\"ftbt\"", ",", "retData2", ")", ";", "FLog", ".", "d", "(", "\"\"", ")", ";", "PostParser", "parser", "=", "new", "PostParser", "(", ")", ";", "String", "contents", "=", "parser", ".", "parse", "(", "this", ",", "retData2", ")", ";", "if", "(", "!", "contents", ".", "equals", "(", "\"\"", ")", ")", "{", "Toast", ".", "makeText", "(", "this", ",", "contents", ",", "Toast", ".", "LENGTH_LONG", ")", ".", "show", "(", ")", ";", "}", "else", "{", "Toast", ".", "makeText", "(", "this", ",", "\"-UNK-\"", ",", "Toast", ".", "LENGTH_LONG", ")", ".", "show", "(", ")", ";", "}", "setOnReturn", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "FLog", ".", "d", "(", "\"message\"", ",", "e", ")", ";", "}", "waitDialog", ".", "dismiss", "(", ")", ";", "finish", "(", ")", ";", "}", "public", "void", "setOnReturn", "(", ")", "{", "Intent", "ret_i", "=", "new", "Intent", "(", ")", ";", "ret_i", ".", "putExtra", "(", "\"posted\"", ",", "\"true\"", ")", ";", "setResult", "(", "RESULT_OK", ",", "ret_i", ")", ";", "}", "}", "</s>" ]
8,276
[ "<s>", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "com", ".", "shotgunsoftware", ".", "*", ";", "class", "UpdateExample", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "try", "{", "URL", "u", "=", "new", "URL", "(", "\"\"", ")", ";", "Shotgun", "s", "=", "new", "Shotgun", "(", "u", ",", "\"kp_testing\"", ",", "\"\"", ")", ";", "HashMap", "asset", "=", "new", "HashMap", "(", ")", ";", "asset", ".", "put", "(", "\"type\"", ",", "\"Asset\"", ")", ";", "asset", ".", "put", "(", "\"id\"", ",", "new", "Integer", "(", "638", ")", ")", ";", "ArrayList", "l", "=", "new", "ArrayList", "(", ")", ";", "l", ".", "add", "(", "asset", ")", ";", "HashMap", "data", "=", "new", "HashMap", "(", ")", ";", "data", ".", "put", "(", "\"\"", ",", "\"ip\"", ")", ";", "data", ".", "put", "(", "\"assets\"", ",", "l", ")", ";", "HashMap", "modes", "=", "new", "HashMap", "(", ")", ";", "modes", ".", "put", "(", "\"assets\"", ",", "\"add\"", ")", ";", "UpdateRequest", "ur", "=", "new", "UpdateRequest", "(", "\"Shot\"", ",", "new", "Integer", "(", "1520", ")", ")", ";", "ur", ".", "setData", "(", "data", ")", ";", "ur", ".", "setMultiEntityUpdateModes", "(", "modes", ")", ";", "Map", "r", "=", "s", ".", "update", "(", "ur", ")", ";", "Object", "[", "]", "assets", "=", "(", "Object", "[", "]", ")", "r", ".", "get", "(", "\"assets\"", ")", ";", "System", ".", "out", ".", "println", "(", "java", ".", "util", ".", "Arrays", ".", "toString", "(", "assets", ")", ")", ";", "modes", ".", "put", "(", "\"assets\"", ",", "\"remove\"", ")", ";", "r", "=", "s", ".", "update", "(", "ur", ")", ";", "assets", "=", "(", "Object", "[", "]", ")", "r", ".", "get", "(", "\"assets\"", ")", ";", "System", ".", "out", ".", "println", "(", "java", ".", "util", ".", "Arrays", ".", "toString", "(", "assets", ")", ")", ";", "modes", ".", "put", "(", "\"assets\"", ",", "\"add\"", ")", ";", "r", "=", "s", ".", "update", "(", "ur", ")", ";", "assets", "=", "(", "Object", "[", "]", ")", "r", ".", "get", "(", "\"assets\"", ")", ";", "System", ".", "out", ".", "println", "(", "java", ".", "util", ".", "Arrays", ".", "toString", "(", "assets", ")", ")", ";", "HashMap", "parents", "=", "new", "HashMap", "(", ")", ";", "parents", ".", "put", "(", "\"\"", ",", "asset", ")", ";", "data", "=", "new", "HashMap", "(", ")", ";", "data", ".", "put", "(", "\"\"", ",", "\"test\"", ")", ";", "ur", "=", "new", "UpdateRequest", "(", "\"Shot\"", ",", "new", "Integer", "(", "1520", ")", ")", ";", "ur", ".", "setData", "(", "data", ")", ";", "ur", ".", "setMultiEntityParents", "(", "parents", ")", ";", "r", "=", "s", ".", "update", "(", "ur", ")", ";", "System", ".", "out", ".", "println", "(", "r", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}", "}", "</s>" ]
8,277
[ "<s>", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "util", ".", "List", ";", "import", "com", ".", "shotgunsoftware", ".", "*", ";", "class", "FindExample", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "try", "{", "URL", "u", "=", "new", "URL", "(", "\"\"", ")", ";", "Shotgun", "s", "=", "new", "Shotgun", "(", "u", ",", "\"kp_testing\"", ",", "\"\"", ")", ";", "FindRequest", "fr", "=", "new", "FindRequest", "(", "\"Shot\"", ")", ";", "fr", ".", "setFields", "(", "new", "String", "[", "]", "{", "\"code\"", ",", "\"\"", "}", ")", ";", "Condition", "descCond", "=", "new", "Condition", "(", "\"description\"", ",", "\"is_not\"", ",", "new", "Object", "[", "]", "{", "null", "}", ")", ";", "fr", ".", "setCondition", "(", "descCond", ")", ";", "fr", ".", "setSort", "(", "new", "Sort", "(", "\"code\"", ",", "false", ")", ")", ";", "List", "recs", "=", "s", ".", "find", "(", "fr", ")", ";", "System", ".", "out", ".", "println", "(", "\"Returned", "\"", "+", "recs", ".", "size", "(", ")", "+", "\"", "records.\"", ")", ";", "Condition", "statusCond", "=", "new", "Condition", "(", "\"\"", ",", "\"is\"", ",", "new", "Object", "[", "]", "{", "\"ip\"", "}", ")", ";", "ConditionGroup", "cg", "=", "new", "ConditionGroup", "(", ")", ";", "cg", ".", "addCondition", "(", "descCond", ")", ";", "cg", ".", "addCondition", "(", "statusCond", ")", ";", "fr", ".", "setConditions", "(", "cg", ")", ";", "recs", "=", "s", ".", "find", "(", "fr", ")", ";", "System", ".", "out", ".", "println", "(", "\"Returned", "\"", "+", "recs", ".", "size", "(", ")", "+", "\"", "records.\"", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}", "}", "</s>" ]
8,278
[ "<s>", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "com", ".", "shotgunsoftware", ".", "*", ";", "class", "CreateDeleteExample", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "try", "{", "URL", "u", "=", "new", "URL", "(", "\"\"", ")", ";", "Shotgun", "s", "=", "new", "Shotgun", "(", "u", ",", "\"kp_testing\"", ",", "\"\"", ")", ";", "HashMap", "asset", "=", "new", "HashMap", "(", ")", ";", "asset", ".", "put", "(", "\"type\"", ",", "\"Asset\"", ")", ";", "asset", ".", "put", "(", "\"id\"", ",", "new", "Integer", "(", "638", ")", ")", ";", "HashMap", "step", "=", "new", "HashMap", "(", ")", ";", "step", ".", "put", "(", "\"type\"", ",", "\"Step\"", ")", ";", "step", ".", "put", "(", "\"id\"", ",", "new", "Integer", "(", "10", ")", ")", ";", "HashMap", "project", "=", "new", "HashMap", "(", ")", ";", "project", ".", "put", "(", "\"type\"", ",", "\"Project\"", ")", ";", "project", ".", "put", "(", "\"id\"", ",", "new", "Integer", "(", "64", ")", ")", ";", "HashMap", "data", "=", "new", "HashMap", "(", ")", ";", "data", ".", "put", "(", "\"content\"", ",", "\"New", "Tast\"", ")", ";", "data", ".", "put", "(", "\"entity\"", ",", "asset", ")", ";", "data", ".", "put", "(", "\"\"", ",", "\"ip\"", ")", ";", "data", ".", "put", "(", "\"step\"", ",", "step", ")", ";", "data", ".", "put", "(", "\"project\"", ",", "project", ")", ";", "CreateRequest", "cr", "=", "new", "CreateRequest", "(", "\"Task\"", ")", ";", "cr", ".", "setData", "(", "data", ")", ";", "Map", "r", "=", "s", ".", "create", "(", "cr", ")", ";", "Integer", "id", "=", "(", "Integer", ")", "r", ".", "get", "(", "\"id\"", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", "+", "id", ".", "toString", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "r", ")", ";", "DeleteRequest", "dr", "=", "new", "DeleteRequest", "(", "\"Task\"", ",", "id", ")", ";", "boolean", "didDelete", "=", "s", ".", "delete", "(", "dr", ")", ";", "if", "(", "didDelete", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", "+", "id", ".", "toString", "(", ")", ")", ";", "}", "didDelete", "=", "s", ".", "delete", "(", "dr", ")", ";", "if", "(", "!", "didDelete", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", "+", "id", ".", "toString", "(", ")", "+", "\"\"", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}", "}", "</s>" ]
8,279
[ "<s>", "package", "com", ".", "shotgunsoftware", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "HashMap", ";", "public", "class", "UpdateRequest", "{", "String", "entityType", ";", "Integer", "entityId", ";", "Map", "data", ";", "Map", "multiEntityUpdateModes", ";", "Map", "multiEntityParents", ";", "public", "UpdateRequest", "(", "String", "entityType", ",", "Integer", "entityId", ")", "{", "this", ".", "entityType", "=", "entityType", ";", "this", ".", "entityId", "=", "entityId", ";", "this", ".", "data", "=", "new", "HashMap", "(", ")", ";", "this", ".", "multiEntityUpdateModes", "=", "new", "HashMap", "(", ")", ";", "this", ".", "multiEntityParents", "=", "new", "HashMap", "(", ")", ";", "}", "public", "void", "setData", "(", "Map", "data", ")", "{", "this", ".", "data", "=", "data", ";", "}", "public", "void", "setMultiEntityUpdateModes", "(", "Map", "modes", ")", "{", "this", ".", "multiEntityUpdateModes", "=", "modes", ";", "}", "public", "void", "setMultiEntityParents", "(", "Map", "parents", ")", "{", "this", ".", "multiEntityParents", "=", "parents", ";", "}", "}", "</s>" ]
8,280
[ "<s>", "package", "com", ".", "shotgunsoftware", ";", "public", "class", "Sort", "{", "String", "fieldName", ";", "boolean", "ascending", ";", "public", "Sort", "(", "String", "fieldName", ")", "{", "this", "(", "fieldName", ",", "true", ")", ";", "}", "public", "Sort", "(", "String", "fieldName", ",", "boolean", "ascending", ")", "{", "this", ".", "fieldName", "=", "fieldName", ";", "this", ".", "ascending", "=", "ascending", ";", "}", "}", "</s>" ]
8,281
[ "<s>", "package", "com", ".", "shotgunsoftware", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Map", ".", "Entry", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "org", ".", "apache", ".", "xmlrpc", ".", "client", ".", "*", ";", "import", "org", ".", "apache", ".", "xmlrpc", ".", "common", ".", "*", ";", "import", "org", ".", "apache", ".", "xmlrpc", ".", "parser", ".", "*", ";", "import", "org", ".", "apache", ".", "xmlrpc", ".", "serializer", ".", "NullSerializer", ";", "import", "org", ".", "apache", ".", "ws", ".", "commons", ".", "util", ".", "NamespaceContextImpl", ";", "import", "org", ".", "apache", ".", "xmlrpc", ".", "XmlRpcException", ";", "public", "class", "Shotgun", "{", "private", "Map", "auth", ";", "private", "XmlRpcClient", "client", ";", "public", "Shotgun", "(", "URL", "url", ",", "String", "script_name", ",", "String", "script_key", ")", "{", "this", ".", "auth", "=", "new", "HashMap", "(", ")", ";", "this", ".", "auth", ".", "put", "(", "\"script_name\"", ",", "script_name", ")", ";", "this", ".", "auth", ".", "put", "(", "\"script_key\"", ",", "script_key", ")", ";", "XmlRpcClientConfigImpl", "config", "=", "new", "XmlRpcClientConfigImpl", "(", ")", ";", "config", ".", "setServerURL", "(", "url", ")", ";", "config", ".", "setEnabledForExtensions", "(", "true", ")", ";", "this", ".", "client", "=", "new", "XmlRpcClient", "(", ")", ";", "client", ".", "setConfig", "(", "config", ")", ";", "client", ".", "setTypeFactory", "(", "new", "MyTypeFactory", "(", "client", ")", ")", ";", "}", "public", "List", "find", "(", "FindRequest", "fr", ")", "throws", "XmlRpcException", "{", "HashMap", "req", "=", "new", "HashMap", "(", ")", ";", "req", ".", "put", "(", "\"type\"", ",", "fr", ".", "entityType", ")", ";", "req", ".", "put", "(", "\"\"", ",", "fr", ".", "returnFields", ")", ";", "req", ".", "put", "(", "\"filters\"", ",", "fr", ".", "conditions", ".", "toHash", "(", ")", ")", ";", "List", "sorts", "=", "new", "ArrayList", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "fr", ".", "sorts", ".", "length", ";", "i", "++", ")", "{", "Map", "sort", "=", "new", "HashMap", "(", ")", ";", "sort", ".", "put", "(", "\"field_name\"", ",", "fr", ".", "sorts", "[", "i", "]", ".", "fieldName", ")", ";", "sort", ".", "put", "(", "\"direction\"", ",", "fr", ".", "sorts", "[", "i", "]", ".", "ascending", "?", "\"asc\"", ":", "\"desc\"", ")", ";", "sorts", ".", "add", "(", "sort", ")", ";", "}", "if", "(", "fr", ".", "sorts", "!=", "null", ")", "req", ".", "put", "(", "\"sorts\"", ",", "sorts", ")", ";", "int", "currentPage", "=", "1", ";", "HashMap", "paging", "=", "new", "HashMap", "(", ")", ";", "paging", ".", "put", "(", "\"\"", ",", "new", "Integer", "(", "500", ")", ")", ";", "paging", ".", "put", "(", "\"current_page\"", ",", "new", "Integer", "(", "currentPage", ")", ")", ";", "req", ".", "put", "(", "\"paging\"", ",", "paging", ")", ";", "Object", "[", "]", "params", "=", "new", "Object", "[", "]", "{", "this", ".", "auth", ",", "req", "}", ";", "boolean", "done", "=", "false", ";", "List", "records", "=", "new", "ArrayList", "(", ")", ";", "while", "(", "!", "done", ")", "{", "Map", "response", "=", "(", "Map", ")", "this", ".", "client", ".", "execute", "(", "\"read\"", ",", "params", ")", ";", "Map", "result", "=", "(", "Map", ")", "response", ".", "get", "(", "\"results\"", ")", ";", "Map", "pagingInfo", "=", "(", "Map", ")", "result", ".", "get", "(", "\"paging_info\"", ")", ";", "Object", "[", "]", "entities", "=", "(", "Object", "[", "]", ")", "result", ".", "get", "(", "\"entities\"", ")", ";", "Integer", "entityCount", "=", "(", "Integer", ")", "pagingInfo", ".", "get", "(", "\"entity_count\"", ")", ";", "records", ".", "addAll", "(", "java", ".", "util", ".", "Arrays", ".", "asList", "(", "entities", ")", ")", ";", "if", "(", "records", ".", "size", "(", ")", "==", "entityCount", ".", "intValue", "(", ")", ")", "{", "done", "=", "true", ";", "}", "else", "{", "paging", ".", "put", "(", "\"current_page\"", ",", "new", "Integer", "(", "++", "currentPage", ")", ")", ";", "}", "}", "return", "records", ";", "}", "public", "Map", "create", "(", "CreateRequest", "cr", ")", "throws", "XmlRpcException", "{", "HashMap", "req", "=", "new", "HashMap", "(", ")", ";", "req", ".", "put", "(", "\"type\"", ",", "cr", ".", "entityType", ")", ";", "List", "fields", "=", "new", "ArrayList", "(", ")", ";", "for", "(", "Iterator", "iter", "=", "cr", ".", "data", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "Entry", "e", "=", "(", "Entry", ")", "iter", ".", "next", "(", ")", ";", "HashMap", "rf", "=", "new", "HashMap", "(", ")", ";", "rf", ".", "put", "(", "\"field_name\"", ",", "e", ".", "getKey", "(", ")", ")", ";", "rf", ".", "put", "(", "\"value\"", ",", "e", ".", "getValue", "(", ")", ")", ";", "fields", ".", "add", "(", "rf", ")", ";", "}", "req", ".", "put", "(", "\"fields\"", ",", "fields", ")", ";", "Object", "[", "]", "params", "=", "new", "Object", "[", "]", "{", "this", ".", "auth", ",", "req", "}", ";", "Map", "response", "=", "(", "Map", ")", "this", ".", "client", ".", "execute", "(", "\"create\"", ",", "params", ")", ";", "Map", "results", "=", "(", "Map", ")", "response", ".", "get", "(", "\"results\"", ")", ";", "return", "results", ";", "}", "public", "Map", "update", "(", "UpdateRequest", "ur", ")", "throws", "XmlRpcException", "{", "HashMap", "req", "=", "new", "HashMap", "(", ")", ";", "req", ".", "put", "(", "\"type\"", ",", "ur", ".", "entityType", ")", ";", "req", ".", "put", "(", "\"id\"", ",", "ur", ".", "entityId", ")", ";", "List", "fields", "=", "new", "ArrayList", "(", ")", ";", "for", "(", "Iterator", "iter", "=", "ur", ".", "data", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "Entry", "e", "=", "(", "Entry", ")", "iter", ".", "next", "(", ")", ";", "HashMap", "rf", "=", "new", "HashMap", "(", ")", ";", "String", "key", "=", "(", "String", ")", "e", ".", "getKey", "(", ")", ";", "rf", ".", "put", "(", "\"field_name\"", ",", "key", ")", ";", "rf", ".", "put", "(", "\"value\"", ",", "e", ".", "getValue", "(", ")", ")", ";", "if", "(", "ur", ".", "multiEntityUpdateModes", ".", "containsKey", "(", "key", ")", ")", "{", "rf", ".", "put", "(", "\"\"", ",", "ur", ".", "multiEntityUpdateModes", ".", "get", "(", "key", ")", ")", ";", "}", "if", "(", "ur", ".", "multiEntityParents", ".", "containsKey", "(", "key", ")", ")", "{", "rf", ".", "put", "(", "\"\"", ",", "ur", ".", "multiEntityParents", ".", "get", "(", "key", ")", ")", ";", "}", "fields", ".", "add", "(", "rf", ")", ";", "}", "req", ".", "put", "(", "\"fields\"", ",", "fields", ")", ";", "Object", "[", "]", "params", "=", "new", "Object", "[", "]", "{", "this", ".", "auth", ",", "req", "}", ";", "Map", "response", "=", "(", "Map", ")", "this", ".", "client", ".", "execute", "(", "\"update\"", ",", "params", ")", ";", "Map", "results", "=", "(", "Map", ")", "response", ".", "get", "(", "\"results\"", ")", ";", "return", "results", ";", "}", "public", "boolean", "delete", "(", "DeleteRequest", "dr", ")", "throws", "XmlRpcException", "{", "HashMap", "req", "=", "new", "HashMap", "(", ")", ";", "req", ".", "put", "(", "\"type\"", ",", "dr", ".", "entityType", ")", ";", "req", ".", "put", "(", "\"id\"", ",", "dr", ".", "entityId", ")", ";", "Object", "[", "]", "params", "=", "new", "Object", "[", "]", "{", "this", ".", "auth", ",", "req", "}", ";", "Map", "response", "=", "(", "Map", ")", "this", ".", "client", ".", "execute", "(", "\"delete\"", ",", "params", ")", ";", "Boolean", "didDelete", "=", "(", "Boolean", ")", "response", ".", "get", "(", "\"results\"", ")", ";", "return", "(", "didDelete", ".", "equals", "(", "Boolean", ".", "TRUE", ")", ")", ";", "}", "class", "MyTypeFactory", "extends", "TypeFactoryImpl", "{", "public", "MyTypeFactory", "(", "XmlRpcController", "pController", ")", "{", "super", "(", "pController", ")", ";", "}", "public", "TypeParser", "getParser", "(", "XmlRpcStreamConfig", "pConfig", ",", "NamespaceContextImpl", "pContext", ",", "String", "pURI", ",", "String", "pLocalName", ")", "{", "if", "(", "\"\"", ".", "equals", "(", "pURI", ")", "&&", "NullSerializer", ".", "NIL_TAG", ".", "equals", "(", "pLocalName", ")", ")", "{", "return", "new", "NullParser", "(", ")", ";", "}", "else", "{", "return", "super", ".", "getParser", "(", "pConfig", ",", "pContext", ",", "pURI", ",", "pLocalName", ")", ";", "}", "}", "}", "}", "</s>" ]
8,282
[ "<s>", "package", "com", ".", "shotgunsoftware", ";", "import", "java", ".", "util", ".", "Map", ";", "interface", "ConditionInterface", "{", "Map", "toHash", "(", ")", ";", "}", "</s>" ]
8,283
[ "<s>", "package", "com", ".", "shotgunsoftware", ";", "public", "class", "DeleteRequest", "{", "String", "entityType", ";", "Integer", "entityId", ";", "public", "DeleteRequest", "(", "String", "entityType", ",", "Integer", "entityId", ")", "{", "this", ".", "entityType", "=", "entityType", ";", "this", ".", "entityId", "=", "entityId", ";", "}", "}", "</s>" ]
8,284
[ "<s>", "package", "com", ".", "shotgunsoftware", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "HashMap", ";", "public", "class", "ConditionGroup", "implements", "ConditionInterface", "{", "boolean", "isAndGroup", ";", "List", "children", ";", "public", "ConditionGroup", "(", ")", "{", "this", "(", "true", ")", ";", "}", "public", "ConditionGroup", "(", "boolean", "isAndGroup", ")", "{", "this", ".", "isAndGroup", "=", "isAndGroup", ";", "this", ".", "children", "=", "new", "ArrayList", "(", ")", ";", "}", "public", "void", "addCondition", "(", "Condition", "c", ")", "{", "children", ".", "add", "(", "c", ")", ";", "}", "public", "void", "addConditionGroup", "(", "ConditionGroup", "cg", ")", "{", "children", ".", "add", "(", "cg", ")", ";", "}", "public", "Map", "toHash", "(", ")", "{", "Map", "h", "=", "new", "HashMap", "(", ")", ";", "List", "l", "=", "new", "ArrayList", "(", ")", ";", "for", "(", "Iterator", "iter", "=", "children", ".", "iterator", "(", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "ConditionInterface", "ci", "=", "(", "ConditionInterface", ")", "iter", ".", "next", "(", ")", ";", "l", ".", "add", "(", "ci", ".", "toHash", "(", ")", ")", ";", "}", "h", ".", "put", "(", "\"\"", ",", "this", ".", "isAndGroup", "?", "\"and\"", ":", "\"or\"", ")", ";", "h", ".", "put", "(", "\"conditions\"", ",", "l", ")", ";", "return", "h", ";", "}", "}", "</s>" ]
8,285
[ "<s>", "package", "com", ".", "shotgunsoftware", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "HashMap", ";", "public", "class", "Condition", "implements", "ConditionInterface", "{", "String", "path", ";", "String", "relation", ";", "Object", "[", "]", "values", ";", "public", "Condition", "(", "String", "path", ",", "String", "relation", ",", "Object", "[", "]", "values", ")", "{", "this", ".", "path", "=", "path", ";", "this", ".", "relation", "=", "relation", ";", "this", ".", "values", "=", "values", ";", "}", "public", "Map", "toHash", "(", ")", "{", "Map", "h", "=", "new", "HashMap", "(", ")", ";", "h", ".", "put", "(", "\"path\"", ",", "this", ".", "path", ")", ";", "h", ".", "put", "(", "\"relation\"", ",", "this", ".", "relation", ")", ";", "h", ".", "put", "(", "\"values\"", ",", "this", ".", "values", ")", ";", "return", "h", ";", "}", "}", "</s>" ]
8,286
[ "<s>", "package", "com", ".", "shotgunsoftware", ";", "public", "class", "FindRequest", "{", "String", "entityType", ";", "String", "[", "]", "returnFields", ";", "Sort", "[", "]", "sorts", ";", "ConditionGroup", "conditions", ";", "public", "FindRequest", "(", "String", "entityType", ")", "{", "this", ".", "entityType", "=", "entityType", ";", "this", ".", "sorts", "=", "new", "Sort", "[", "]", "{", "}", ";", "this", ".", "conditions", "=", "new", "ConditionGroup", "(", ")", ";", "}", "public", "void", "setFields", "(", "String", "fields", "[", "]", ")", "{", "this", ".", "returnFields", "=", "fields", ";", "}", "public", "void", "setCondition", "(", "Condition", "c", ")", "{", "this", ".", "conditions", "=", "new", "ConditionGroup", "(", ")", ";", "this", ".", "conditions", ".", "addCondition", "(", "c", ")", ";", "}", "public", "void", "setConditions", "(", "ConditionGroup", "cg", ")", "{", "this", ".", "conditions", "=", "cg", ";", "}", "public", "void", "setSort", "(", "Sort", "sort", ")", "{", "this", ".", "sorts", "=", "new", "Sort", "[", "]", "{", "sort", "}", ";", "}", "public", "void", "setSorts", "(", "Sort", "[", "]", "sorts", ")", "{", "this", ".", "sorts", "=", "sorts", ";", "}", "}", "</s>" ]
8,287
[ "<s>", "package", "com", ".", "shotgunsoftware", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "HashMap", ";", "public", "class", "CreateRequest", "{", "String", "entityType", ";", "Map", "data", ";", "public", "CreateRequest", "(", "String", "entityType", ")", "{", "this", ".", "entityType", "=", "entityType", ";", "this", ".", "data", "=", "new", "HashMap", "(", ")", ";", "}", "public", "void", "setData", "(", "Map", "data", ")", "{", "this", ".", "data", "=", "data", ";", "}", "}", "</s>" ]
8,288
[ "<s>", "package", "biz", ".", "sawatzki", ".", "phoneload", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileOutputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "net", ".", "HttpURLConnection", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "com", ".", "phonegap", ".", "api", ".", "PluginResult", ";", "import", "com", ".", "phonegap", ".", "FileUtils", ";", "public", "class", "FileDownloadThread", "extends", "Thread", "{", "private", "static", "final", "String", "LOG_TAG", "=", "\"\"", ";", "private", "String", "source", ",", "target", ",", "callbackId", ";", "private", "PhoneLoad", "fileTransfer", ";", "private", "boolean", "stopRequested", "=", "false", ";", "public", "FileDownloadThread", "(", "PhoneLoad", "fileTransfer", ",", "String", "source", ",", "String", "target", ",", "String", "callbackId", ")", "{", "this", ".", "source", "=", "source", ";", "this", ".", "target", "=", "target", ";", "this", ".", "callbackId", "=", "callbackId", ";", "this", ".", "fileTransfer", "=", "fileTransfer", ";", "}", "@", "Override", "public", "void", "run", "(", ")", "{", "try", "{", "download", "(", "source", ",", "target", ",", "callbackId", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "fileTransfer", ".", "error", "(", "\"\"", ",", "callbackId", ")", ";", "}", "}", "public", "void", "requestStop", "(", ")", "{", "stopRequested", "=", "true", ";", "}", "public", "void", "download", "(", "String", "source", ",", "String", "target", ",", "String", "callbackId", ")", "throws", "IOException", "{", "try", "{", "FileDownloadResult", "result", "=", "new", "FileDownloadResult", "(", ")", ";", "File", "file", "=", "new", "File", "(", "target", ")", ";", "file", ".", "getParentFile", "(", ")", ".", "mkdirs", "(", ")", ";", "URL", "url", "=", "new", "URL", "(", "source", ")", ";", "HttpURLConnection", "connection", "=", "(", "HttpURLConnection", ")", "url", ".", "openConnection", "(", ")", ";", "connection", ".", "setRequestMethod", "(", "\"GET\"", ")", ";", "connection", ".", "setDoOutput", "(", "true", ")", ";", "connection", ".", "connect", "(", ")", ";", "Log", ".", "d", "(", "LOG_TAG", ",", "\"\"", "+", "url", ")", ";", "result", ".", "setResponseCode", "(", "connection", ".", "getResponseCode", "(", ")", ")", ";", "result", ".", "setBytesTotal", "(", "connection", ".", "getContentLength", "(", ")", ")", ";", "InputStream", "inputStream", "=", "connection", ".", "getInputStream", "(", ")", ";", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "4096", "]", ";", "int", "bytesRead", "=", "0", ";", "long", "totalBytes", "=", "0", ";", "FileOutputStream", "outputStream", "=", "new", "FileOutputStream", "(", "file", ")", ";", "bytesRead", "=", "inputStream", ".", "read", "(", "buffer", ")", ";", "PluginResult", "progress", ";", "long", "lastTime", "=", "0", ";", "long", "curTime", "=", "0", ";", "while", "(", "bytesRead", ">", "0", ")", "{", "outputStream", ".", "write", "(", "buffer", ",", "0", ",", "bytesRead", ")", ";", "totalBytes", "+=", "bytesRead", ";", "result", ".", "setBytesReceived", "(", "totalBytes", ")", ";", "bytesRead", "=", "inputStream", ".", "read", "(", "buffer", ")", ";", "curTime", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "if", "(", "(", "bytesRead", "==", "0", ")", "||", "(", "curTime", ">", "(", "lastTime", "+", "200", ")", ")", ")", "{", "progress", "=", "new", "PluginResult", "(", "PluginResult", ".", "Status", ".", "OK", ",", "result", ".", "toJSONObject", "(", ")", ",", "FileDownloadResult", ".", "CAST_CODE", ")", ";", "progress", ".", "setKeepCallback", "(", "true", ")", ";", "fileTransfer", ".", "success", "(", "progress", ",", "callbackId", ")", ";", "lastTime", "=", "curTime", ";", "}", "if", "(", "stopRequested", ")", "{", "fileTransfer", ".", "error", "(", "\"\"", ",", "callbackId", ")", ";", "return", ";", "}", "}", "inputStream", ".", "close", "(", ")", ";", "connection", ".", "disconnect", "(", ")", ";", "outputStream", ".", "close", "(", ")", ";", "Log", ".", "d", "(", "LOG_TAG", ",", "\"Saved", "file:", "\"", "+", "target", ")", ";", "FileUtils", "fileUtil", "=", "new", "FileUtils", "(", ")", ";", "result", ".", "setFileEntry", "(", "fileUtil", ".", "getEntry", "(", "file", ")", ")", ";", "result", ".", "setCompleted", "(", ")", ";", "PluginResult", "pluginResult", "=", "new", "PluginResult", "(", "PluginResult", ".", "Status", ".", "OK", ",", "result", ".", "toJSONObject", "(", ")", ",", "FileDownloadResult", ".", "CAST_CODE", ")", ";", "fileTransfer", ".", "success", "(", "pluginResult", ",", "callbackId", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "Log", ".", "d", "(", "LOG_TAG", ",", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "throw", "new", "IOException", "(", "\"\"", ")", ";", "}", "}", "}", "</s>" ]
8,289
[ "<s>", "package", "biz", ".", "sawatzki", ".", "phoneload", ";", "import", "org", ".", "json", ".", "JSONException", ";", "import", "org", ".", "json", ".", "JSONObject", ";", "public", "class", "FileUploadResult", "extends", "FileTransferResult", "{", "private", "long", "bytesSent", "=", "0", ";", "private", "String", "response", "=", "null", ";", "public", "long", "getBytesSent", "(", ")", "{", "return", "bytesSent", ";", "}", "public", "void", "setBytesSent", "(", "long", "bytes", ")", "{", "this", ".", "bytesSent", "=", "bytes", ";", "}", "public", "String", "getResponse", "(", ")", "{", "return", "response", ";", "}", "public", "void", "setResponse", "(", "String", "response", ")", "{", "this", ".", "response", "=", "response", ";", "}", "public", "JSONObject", "toJSONObject", "(", ")", "throws", "JSONException", "{", "return", "new", "JSONObject", "(", "\"{bytesSent:\"", "+", "bytesSent", "+", "\"\"", "+", "getResponseCode", "(", ")", "+", "\",response:\"", "+", "JSONObject", ".", "quote", "(", "response", ")", "+", "\"}\"", ")", ";", "}", "}", "</s>" ]
8,290
[ "<s>", "package", "biz", ".", "sawatzki", ".", "phoneload", ";", "import", "org", ".", "json", ".", "JSONException", ";", "import", "org", ".", "json", ".", "JSONObject", ";", "public", "class", "FileTransferResult", "{", "private", "int", "responseCode", "=", "-", "1", ";", "public", "int", "getResponseCode", "(", ")", "{", "return", "responseCode", ";", "}", "public", "void", "setResponseCode", "(", "int", "responseCode", ")", "{", "this", ".", "responseCode", "=", "responseCode", ";", "}", "}", "</s>" ]
8,291
[ "<s>", "package", "biz", ".", "sawatzki", ".", "phoneload", ";", "import", "java", ".", "io", ".", "DataInputStream", ";", "import", "java", ".", "io", ".", "DataOutputStream", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "FileNotFoundException", ";", "import", "java", ".", "io", ".", "FileOutputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "net", ".", "HttpURLConnection", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "security", ".", "cert", ".", "CertificateException", ";", "import", "java", ".", "security", ".", "cert", ".", "X509Certificate", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "javax", ".", "net", ".", "ssl", ".", "HostnameVerifier", ";", "import", "javax", ".", "net", ".", "ssl", ".", "HttpsURLConnection", ";", "import", "javax", ".", "net", ".", "ssl", ".", "SSLContext", ";", "import", "javax", ".", "net", ".", "ssl", ".", "SSLException", ";", "import", "javax", ".", "net", ".", "ssl", ".", "SSLSession", ";", "import", "javax", ".", "net", ".", "ssl", ".", "SSLSocketFactory", ";", "import", "javax", ".", "net", ".", "ssl", ".", "TrustManager", ";", "import", "javax", ".", "net", ".", "ssl", ".", "X509TrustManager", ";", "import", "org", ".", "json", ".", "JSONArray", ";", "import", "org", ".", "json", ".", "JSONException", ";", "import", "org", ".", "json", ".", "JSONObject", ";", "import", "android", ".", "net", ".", "Uri", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "webkit", ".", "CookieManager", ";", "import", "com", ".", "phonegap", ".", "api", ".", "Plugin", ";", "import", "com", ".", "phonegap", ".", "api", ".", "PluginResult", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "com", ".", "phonegap", ".", "FileUtils", ";", "public", "class", "PhoneLoad", "extends", "Plugin", "{", "private", "static", "final", "String", "LOG_TAG", "=", "\"PhoneLoad\"", ";", "private", "static", "final", "String", "LINE_START", "=", "\"--\"", ";", "private", "static", "final", "String", "LINE_END", "=", "\"rn\"", ";", "private", "static", "final", "String", "BOUNDRY", "=", "\"*****\"", ";", "public", "static", "int", "FILE_NOT_FOUND_ERR", "=", "1", ";", "public", "static", "int", "INVALID_URL_ERR", "=", "2", ";", "public", "static", "int", "CONNECTION_ERR", "=", "3", ";", "private", "SSLSocketFactory", "defaultSSLSocketFactory", "=", "null", ";", "private", "HostnameVerifier", "defaultHostnameVerifier", "=", "null", ";", "private", "HashMap", "<", "String", ",", "FileDownloadThread", ">", "downloadWorkers", ";", "public", "PhoneLoad", "(", ")", "{", "super", "(", ")", ";", "downloadWorkers", "=", "new", "HashMap", "<", "String", ",", "FileDownloadThread", ">", "(", ")", ";", "}", "@", "Override", "public", "PluginResult", "execute", "(", "String", "action", ",", "JSONArray", "args", ",", "String", "callbackId", ")", "{", "String", "source", "=", "null", ";", "String", "target", "=", "null", ";", "String", "id", "=", "null", ";", "if", "(", "action", ".", "equals", "(", "\"download\"", ")", "||", "action", ".", "equals", "(", "\"upload\"", ")", ")", "{", "try", "{", "source", "=", "args", ".", "getString", "(", "0", ")", ";", "target", "=", "args", ".", "getString", "(", "1", ")", ";", "if", "(", "args", ".", "length", "(", ")", ">", "2", ")", "id", "=", "args", ".", "getString", "(", "2", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "Log", ".", "d", "(", "LOG_TAG", ",", "\"\"", ")", ";", "return", "new", "PluginResult", "(", "PluginResult", ".", "Status", ".", "JSON_EXCEPTION", ",", "\"\"", ")", ";", "}", "}", "else", "if", "(", "action", ".", "equals", "(", "\"\"", ")", ")", "{", "try", "{", "id", "=", "args", ".", "getString", "(", "0", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "Log", ".", "d", "(", "LOG_TAG", ",", "\"\"", ")", ";", "return", "new", "PluginResult", "(", "PluginResult", ".", "Status", ".", "JSON_EXCEPTION", ",", "\"\"", ")", ";", "}", "}", "try", "{", "if", "(", "action", ".", "equals", "(", "\"upload\"", ")", ")", "{", "String", "fileKey", "=", "null", ";", "String", "fileName", "=", "null", ";", "String", "mimeType", "=", "null", ";", "fileKey", "=", "getArgument", "(", "args", ",", "2", ",", "\"file\"", ")", ";", "fileName", "=", "getArgument", "(", "args", ",", "3", ",", "\"image.jpg\"", ")", ";", "mimeType", "=", "getArgument", "(", "args", ",", "4", ",", "\"image/jpeg\"", ")", ";", "JSONObject", "params", "=", "args", ".", "optJSONObject", "(", "5", ")", ";", "boolean", "trustEveryone", "=", "args", ".", "optBoolean", "(", "6", ")", ";", "boolean", "chunkedMode", "=", "args", ".", "optBoolean", "(", "7", ")", ";", "FileUploadResult", "r", "=", "upload", "(", "source", ",", "target", ",", "fileKey", ",", "fileName", ",", "mimeType", ",", "params", ",", "trustEveryone", ",", "chunkedMode", ")", ";", "Log", ".", "d", "(", "LOG_TAG", ",", "\"\"", ")", ";", "return", "new", "PluginResult", "(", "PluginResult", ".", "Status", ".", "OK", ",", "r", ".", "toJSONObject", "(", ")", ")", ";", "}", "else", "if", "(", "action", ".", "equals", "(", "\"download\"", ")", ")", "{", "Log", ".", "d", "(", "LOG_TAG", ",", "\"\"", ")", ";", "FileDownloadThread", "t", "=", "new", "FileDownloadThread", "(", "this", ",", "source", ",", "target", ",", "callbackId", ")", ";", "downloadWorkers", ".", "put", "(", "id", ",", "t", ")", ";", "t", ".", "start", "(", ")", ";", "PluginResult", "result", "=", "new", "PluginResult", "(", "PluginResult", ".", "Status", ".", "NO_RESULT", ")", ";", "result", ".", "setKeepCallback", "(", "true", ")", ";", "return", "result", ";", "}", "else", "if", "(", "action", ".", "equals", "(", "\"\"", ")", ")", "{", "if", "(", "id", "!=", "null", ")", "{", "FileDownloadThread", "t", "=", "downloadWorkers", ".", "get", "(", "id", ")", ";", "if", "(", "t", "!=", "null", ")", "{", "t", ".", "requestStop", "(", ")", ";", "try", "{", "t", ".", "join", "(", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "}", "Log", ".", "d", "(", "LOG_TAG", ",", "\"\"", ")", ";", "}", "return", "new", "PluginResult", "(", "PluginResult", ".", "Status", ".", "OK", ")", ";", "}", "else", "{", "return", "new", "PluginResult", "(", "PluginResult", ".", "Status", ".", "INVALID_ACTION", ")", ";", "}", "}", "catch", "(", "FileNotFoundException", "e", ")", "{", "Log", ".", "e", "(", "LOG_TAG", ",", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "JSONObject", "error", "=", "createFileTransferError", "(", "FILE_NOT_FOUND_ERR", ",", "source", ",", "target", ")", ";", "return", "new", "PluginResult", "(", "PluginResult", ".", "Status", ".", "IO_EXCEPTION", ",", "error", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "Log", ".", "e", "(", "LOG_TAG", ",", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "JSONObject", "error", "=", "createFileTransferError", "(", "INVALID_URL_ERR", ",", "source", ",", "target", ")", ";", "return", "new", "PluginResult", "(", "PluginResult", ".", "Status", ".", "IO_EXCEPTION", ",", "error", ")", ";", "}", "catch", "(", "SSLException", "e", ")", "{", "Log", ".", "e", "(", "LOG_TAG", ",", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "Log", ".", "d", "(", "LOG_TAG", ",", "\"\"", ")", ";", "JSONObject", "error", "=", "createFileTransferError", "(", "CONNECTION_ERR", ",", "source", ",", "target", ")", ";", "return", "new", "PluginResult", "(", "PluginResult", ".", "Status", ".", "IO_EXCEPTION", ",", "error", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "Log", ".", "e", "(", "LOG_TAG", ",", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "JSONObject", "error", "=", "createFileTransferError", "(", "CONNECTION_ERR", ",", "source", ",", "target", ")", ";", "return", "new", "PluginResult", "(", "PluginResult", ".", "Status", ".", "IO_EXCEPTION", ",", "error", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "Log", ".", "e", "(", "LOG_TAG", ",", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "return", "new", "PluginResult", "(", "PluginResult", ".", "Status", ".", "JSON_EXCEPTION", ")", ";", "}", "}", "final", "static", "HostnameVerifier", "DO_NOT_VERIFY", "=", "new", "HostnameVerifier", "(", ")", "{", "public", "boolean", "verify", "(", "String", "hostname", ",", "SSLSession", "session", ")", "{", "return", "true", ";", "}", "}", ";", "private", "void", "trustAllHosts", "(", ")", "{", "TrustManager", "[", "]", "trustAllCerts", "=", "new", "TrustManager", "[", "]", "{", "new", "X509TrustManager", "(", ")", "{", "public", "java", ".", "security", ".", "cert", ".", "X509Certificate", "[", "]", "getAcceptedIssuers", "(", ")", "{", "return", "new", "java", ".", "security", ".", "cert", ".", "X509Certificate", "[", "]", "{", "}", ";", "}", "public", "void", "checkClientTrusted", "(", "X509Certificate", "[", "]", "chain", ",", "String", "authType", ")", "throws", "CertificateException", "{", "}", "public", "void", "checkServerTrusted", "(", "X509Certificate", "[", "]", "chain", ",", "String", "authType", ")", "throws", "CertificateException", "{", "}", "}", "}", ";", "try", "{", "defaultSSLSocketFactory", "=", "HttpsURLConnection", ".", "getDefaultSSLSocketFactory", "(", ")", ";", "SSLContext", "sc", "=", "SSLContext", ".", "getInstance", "(", "\"TLS\"", ")", ";", "sc", ".", "init", "(", "null", ",", "trustAllCerts", ",", "new", "java", ".", "security", ".", "SecureRandom", "(", ")", ")", ";", "HttpsURLConnection", ".", "setDefaultSSLSocketFactory", "(", "sc", ".", "getSocketFactory", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "Log", ".", "e", "(", "LOG_TAG", ",", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "}", "private", "JSONObject", "createFileTransferError", "(", "int", "errorCode", ",", "String", "source", ",", "String", "target", ")", "{", "JSONObject", "error", "=", "null", ";", "try", "{", "error", "=", "new", "JSONObject", "(", ")", ";", "error", ".", "put", "(", "\"code\"", ",", "errorCode", ")", ";", "error", ".", "put", "(", "\"source\"", ",", "source", ")", ";", "error", ".", "put", "(", "\"target\"", ",", "target", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "Log", ".", "e", "(", "LOG_TAG", ",", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "return", "error", ";", "}", "private", "String", "getArgument", "(", "JSONArray", "args", ",", "int", "position", ",", "String", "defaultString", ")", "{", "String", "arg", "=", "defaultString", ";", "if", "(", "args", ".", "length", "(", ")", ">=", "position", ")", "{", "arg", "=", "args", ".", "optString", "(", "position", ")", ";", "if", "(", "arg", "==", "null", "||", "\"null\"", ".", "equals", "(", "arg", ")", ")", "{", "arg", "=", "defaultString", ";", "}", "}", "return", "arg", ";", "}", "public", "FileUploadResult", "upload", "(", "String", "file", ",", "String", "server", ",", "final", "String", "fileKey", ",", "final", "String", "fileName", ",", "final", "String", "mimeType", ",", "JSONObject", "params", ",", "boolean", "trustEveryone", ",", "boolean", "chunkedMode", ")", "throws", "IOException", ",", "SSLException", "{", "FileUploadResult", "result", "=", "new", "FileUploadResult", "(", ")", ";", "InputStream", "fileInputStream", "=", "getPathFromUri", "(", "file", ")", ";", "HttpURLConnection", "conn", "=", "null", ";", "DataOutputStream", "dos", "=", "null", ";", "int", "bytesRead", ",", "bytesAvailable", ",", "bufferSize", ";", "long", "totalBytes", ";", "byte", "[", "]", "buffer", ";", "int", "maxBufferSize", "=", "8096", ";", "URL", "url", "=", "new", "URL", "(", "server", ")", ";", "if", "(", "url", ".", "getProtocol", "(", ")", ".", "toLowerCase", "(", ")", ".", "equals", "(", "\"https\"", ")", ")", "{", "if", "(", "!", "trustEveryone", ")", "{", "conn", "=", "(", "HttpsURLConnection", ")", "url", ".", "openConnection", "(", ")", ";", "}", "else", "{", "trustAllHosts", "(", ")", ";", "HttpsURLConnection", "https", "=", "(", "HttpsURLConnection", ")", "url", ".", "openConnection", "(", ")", ";", "defaultHostnameVerifier", "=", "https", ".", "getHostnameVerifier", "(", ")", ";", "https", ".", "setHostnameVerifier", "(", "DO_NOT_VERIFY", ")", ";", "conn", "=", "https", ";", "}", "}", "else", "{", "conn", "=", "(", "HttpURLConnection", ")", "url", ".", "openConnection", "(", ")", ";", "}", "conn", ".", "setDoInput", "(", "true", ")", ";", "conn", ".", "setDoOutput", "(", "true", ")", ";", "conn", ".", "setUseCaches", "(", "false", ")", ";", "conn", ".", "setRequestMethod", "(", "\"POST\"", ")", ";", "conn", ".", "setRequestProperty", "(", "\"Connection\"", ",", "\"Keep-Alive\"", ")", ";", "conn", ".", "setRequestProperty", "(", "\"Content-Type\"", ",", "\"\"", "+", "BOUNDRY", ")", ";", "String", "cookie", "=", "CookieManager", ".", "getInstance", "(", ")", ".", "getCookie", "(", "server", ")", ";", "if", "(", "cookie", "!=", "null", ")", "{", "conn", ".", "setRequestProperty", "(", "\"Cookie\"", ",", "cookie", ")", ";", "}", "if", "(", "chunkedMode", ")", "{", "conn", ".", "setChunkedStreamingMode", "(", "maxBufferSize", ")", ";", "}", "dos", "=", "new", "DataOutputStream", "(", "conn", ".", "getOutputStream", "(", ")", ")", ";", "try", "{", "for", "(", "Iterator", "iter", "=", "params", ".", "keys", "(", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "Object", "key", "=", "iter", ".", "next", "(", ")", ";", "dos", ".", "writeBytes", "(", "LINE_START", "+", "BOUNDRY", "+", "LINE_END", ")", ";", "dos", ".", "writeBytes", "(", "\"\"", "+", "key", ".", "toString", "(", ")", "+", "\"\\\";\"", ")", ";", "dos", ".", "writeBytes", "(", "LINE_END", "+", "LINE_END", ")", ";", "dos", ".", "write", "(", "params", ".", "getString", "(", "key", ".", "toString", "(", ")", ")", ".", "getBytes", "(", ")", ")", ";", "dos", ".", "writeBytes", "(", "LINE_END", ")", ";", "}", "}", "catch", "(", "JSONException", "e", ")", "{", "Log", ".", "e", "(", "LOG_TAG", ",", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "dos", ".", "writeBytes", "(", "LINE_START", "+", "BOUNDRY", "+", "LINE_END", ")", ";", "dos", ".", "writeBytes", "(", "\"\"", "+", "fileKey", "+", "\"\\\";\"", "+", "\"", "filename=\\\"\"", "+", "fileName", "+", "\"\\\"\"", "+", "LINE_END", ")", ";", "dos", ".", "writeBytes", "(", "\"\"", "+", "mimeType", "+", "LINE_END", ")", ";", "dos", ".", "writeBytes", "(", "LINE_END", ")", ";", "bytesAvailable", "=", "fileInputStream", ".", "available", "(", ")", ";", "bufferSize", "=", "Math", ".", "min", "(", "bytesAvailable", ",", "maxBufferSize", ")", ";", "buffer", "=", "new", "byte", "[", "bufferSize", "]", ";", "bytesRead", "=", "fileInputStream", ".", "read", "(", "buffer", ",", "0", ",", "bufferSize", ")", ";", "totalBytes", "=", "0", ";", "while", "(", "bytesRead", ">", "0", ")", "{", "totalBytes", "+=", "bytesRead", ";", "result", ".", "setBytesSent", "(", "totalBytes", ")", ";", "dos", ".", "write", "(", "buffer", ",", "0", ",", "bufferSize", ")", ";", "bytesAvailable", "=", "fileInputStream", ".", "available", "(", ")", ";", "bufferSize", "=", "Math", ".", "min", "(", "bytesAvailable", ",", "maxBufferSize", ")", ";", "bytesRead", "=", "fileInputStream", ".", "read", "(", "buffer", ",", "0", ",", "bufferSize", ")", ";", "}", "dos", ".", "writeBytes", "(", "LINE_END", ")", ";", "dos", ".", "writeBytes", "(", "LINE_START", "+", "BOUNDRY", "+", "LINE_START", "+", "LINE_END", ")", ";", "fileInputStream", ".", "close", "(", ")", ";", "dos", ".", "flush", "(", ")", ";", "dos", ".", "close", "(", ")", ";", "StringBuffer", "responseString", "=", "new", "StringBuffer", "(", "\"\"", ")", ";", "DataInputStream", "inStream", ";", "try", "{", "inStream", "=", "new", "DataInputStream", "(", "conn", ".", "getInputStream", "(", ")", ")", ";", "}", "catch", "(", "FileNotFoundException", "e", ")", "{", "throw", "new", "IOException", "(", "\"\"", ")", ";", "}", "String", "line", ";", "while", "(", "(", "line", "=", "inStream", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "responseString", ".", "append", "(", "line", ")", ";", "}", "Log", ".", "d", "(", "LOG_TAG", ",", "\"\"", ")", ";", "Log", ".", "d", "(", "LOG_TAG", ",", "responseString", ".", "toString", "(", ")", ")", ";", "result", ".", "setResponseCode", "(", "conn", ".", "getResponseCode", "(", ")", ")", ";", "result", ".", "setResponse", "(", "responseString", ".", "toString", "(", ")", ")", ";", "inStream", ".", "close", "(", ")", ";", "conn", ".", "disconnect", "(", ")", ";", "if", "(", "trustEveryone", "&&", "url", ".", "getProtocol", "(", ")", ".", "toLowerCase", "(", ")", ".", "equals", "(", "\"https\"", ")", ")", "{", "(", "(", "HttpsURLConnection", ")", "conn", ")", ".", "setHostnameVerifier", "(", "defaultHostnameVerifier", ")", ";", "HttpsURLConnection", ".", "setDefaultSSLSocketFactory", "(", "defaultSSLSocketFactory", ")", ";", "}", "return", "result", ";", "}", "public", "FileDownloadResult", "download", "(", "String", "source", ",", "String", "target", ",", "String", "callbackId", ")", "throws", "IOException", "{", "try", "{", "FileDownloadResult", "result", "=", "new", "FileDownloadResult", "(", ")", ";", "File", "file", "=", "new", "File", "(", "target", ")", ";", "file", ".", "getParentFile", "(", ")", ".", "mkdirs", "(", ")", ";", "URL", "url", "=", "new", "URL", "(", "source", ")", ";", "HttpURLConnection", "connection", "=", "(", "HttpURLConnection", ")", "url", ".", "openConnection", "(", ")", ";", "connection", ".", "setRequestMethod", "(", "\"GET\"", ")", ";", "connection", ".", "setDoOutput", "(", "true", ")", ";", "connection", ".", "connect", "(", ")", ";", "Log", ".", "d", "(", "LOG_TAG", ",", "\"\"", "+", "url", ")", ";", "result", ".", "setResponseCode", "(", "connection", ".", "getResponseCode", "(", ")", ")", ";", "result", ".", "setBytesTotal", "(", "connection", ".", "getContentLength", "(", ")", ")", ";", "InputStream", "inputStream", "=", "connection", ".", "getInputStream", "(", ")", ";", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "4096", "]", ";", "int", "bytesRead", "=", "0", ";", "long", "totalBytes", "=", "0", ";", "FileOutputStream", "outputStream", "=", "new", "FileOutputStream", "(", "file", ")", ";", "bytesRead", "=", "inputStream", ".", "read", "(", "buffer", ")", ";", "PluginResult", "progress", ";", "long", "lastTime", "=", "0", ";", "long", "curTime", "=", "0", ";", "while", "(", "bytesRead", ">", "0", ")", "{", "outputStream", ".", "write", "(", "buffer", ",", "0", ",", "bytesRead", ")", ";", "totalBytes", "+=", "bytesRead", ";", "result", ".", "setBytesReceived", "(", "totalBytes", ")", ";", "bytesRead", "=", "inputStream", ".", "read", "(", "buffer", ")", ";", "curTime", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "if", "(", "(", "bytesRead", "==", "0", ")", "||", "(", "curTime", ">", "(", "lastTime", "+", "200", ")", ")", ")", "{", "progress", "=", "new", "PluginResult", "(", "PluginResult", ".", "Status", ".", "OK", ",", "result", ".", "toJSONObject", "(", ")", ",", "FileDownloadResult", ".", "CAST_CODE", ")", ";", "progress", ".", "setKeepCallback", "(", "true", ")", ";", "success", "(", "progress", ",", "callbackId", ")", ";", "lastTime", "=", "curTime", ";", "}", "}", "inputStream", ".", "close", "(", ")", ";", "connection", ".", "disconnect", "(", ")", ";", "outputStream", ".", "close", "(", ")", ";", "Log", ".", "d", "(", "LOG_TAG", ",", "\"Saved", "file:", "\"", "+", "target", ")", ";", "FileUtils", "fileUtil", "=", "new", "FileUtils", "(", ")", ";", "result", ".", "setFileEntry", "(", "fileUtil", ".", "getEntry", "(", "file", ")", ")", ";", "result", ".", "setCompleted", "(", ")", ";", "return", "result", ";", "}", "catch", "(", "Exception", "e", ")", "{", "Log", ".", "d", "(", "LOG_TAG", ",", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "throw", "new", "IOException", "(", "\"\"", ")", ";", "}", "}", "private", "InputStream", "getPathFromUri", "(", "String", "path", ")", "throws", "FileNotFoundException", "{", "if", "(", "path", ".", "startsWith", "(", "\"content:\"", ")", ")", "{", "Uri", "uri", "=", "Uri", ".", "parse", "(", "path", ")", ";", "return", "ctx", ".", "getContentResolver", "(", ")", ".", "openInputStream", "(", "uri", ")", ";", "}", "else", "if", "(", "path", ".", "startsWith", "(", "\"file://\"", ")", ")", "{", "return", "new", "FileInputStream", "(", "path", ".", "substring", "(", "7", ")", ")", ";", "}", "else", "{", "return", "new", "FileInputStream", "(", "path", ")", ";", "}", "}", "}", "</s>" ]
8,292
[ "<s>", "package", "biz", ".", "sawatzki", ".", "phoneload", ";", "import", "org", ".", "json", ".", "JSONException", ";", "import", "org", ".", "json", ".", "JSONObject", ";", "public", "class", "FileDownloadResult", "extends", "FileTransferResult", "{", "public", "static", "final", "String", "CAST_CODE", "=", "\"\"", ";", "private", "long", "bytesReceived", "=", "0", ";", "private", "long", "bytesTotal", "=", "0", ";", "private", "JSONObject", "fileEntry", ";", "private", "boolean", "completed", "=", "false", ";", "public", "long", "getBytesReceived", "(", ")", "{", "return", "bytesReceived", ";", "}", "public", "void", "setBytesReceived", "(", "long", "bytes", ")", "{", "this", ".", "bytesReceived", "=", "bytes", ";", "}", "public", "long", "getBytesTotal", "(", ")", "{", "return", "bytesTotal", ";", "}", "public", "void", "setBytesTotal", "(", "long", "bytes", ")", "{", "this", ".", "bytesTotal", "=", "bytes", ";", "}", "public", "boolean", "getCompleted", "(", ")", "{", "return", "completed", ";", "}", "public", "void", "setCompleted", "(", ")", "{", "this", ".", "completed", "=", "true", ";", "}", "public", "double", "getPercentCompleted", "(", ")", "{", "if", "(", "bytesTotal", ">", "0", ")", "return", "new", "Double", "(", "bytesReceived", ")", "/", "new", "Double", "(", "bytesTotal", ")", "*", "100.0", ";", "else", "return", "-", "1", ";", "}", "public", "JSONObject", "getFileEntry", "(", ")", "{", "return", "fileEntry", ";", "}", "public", "void", "setFileEntry", "(", "JSONObject", "entry", ")", "{", "this", ".", "fileEntry", "=", "entry", ";", "}", "public", "JSONObject", "toJSONObject", "(", ")", "throws", "JSONException", "{", "JSONObject", "result", "=", "new", "JSONObject", "(", ")", ";", "result", ".", "put", "(", "\"\"", ",", "getBytesReceived", "(", ")", ")", ";", "result", ".", "put", "(", "\"bytesTotal\"", ",", "getBytesTotal", "(", ")", ")", ";", "result", ".", "put", "(", "\"\"", ",", "getPercentCompleted", "(", ")", ")", ";", "result", ".", "put", "(", "\"responseCode\"", ",", "getResponseCode", "(", ")", ")", ";", "result", ".", "put", "(", "\"completed\"", ",", "getCompleted", "(", ")", ")", ";", "if", "(", "fileEntry", "!=", "null", ")", "result", ".", "put", "(", "\"fileEntry\"", ",", "fileEntry", ".", "toString", "(", ")", ")", ";", "return", "result", ";", "}", "}", "</s>" ]
8,293
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ";", "import", "org", ".", "apache", ".", "http", ".", "HttpEntity", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "HttpClient", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "methods", ".", "HttpPost", ";", "import", "org", ".", "apache", ".", "http", ".", "util", ".", "EntityUtils", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "junit", ".", "runner", ".", "RunWith", ";", "import", "org", ".", "mockito", ".", "ArgumentCaptor", ";", "import", "org", ".", "mockito", ".", "Mock", ";", "import", "org", ".", "mockito", ".", "runners", ".", "MockitoJUnitRunner", ";", "import", "org", ".", "payments4j", ".", "core", ".", "TransactionResponse", ";", "import", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ";", "import", "org", ".", "payments4j", ".", "model", ".", "CreditCardBuilder", ";", "import", "org", ".", "payments4j", ".", "model", ".", "Money", ";", "import", "org", ".", "payments4j", ".", "model", ".", "MoneyBuilder", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "Locale", ";", "import", "static", "org", ".", "fest", ".", "assertions", ".", "Assertions", ".", "assertThat", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "verify", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "when", ";", "import", "static", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ".", "Type", ".", "MASTER_CARD", ";", "@", "RunWith", "(", "MockitoJUnitRunner", ".", "class", ")", "public", "class", "PayFlowProPaymentGatewayTest", "{", "private", "static", "final", "String", "USERNAME", "=", "\"LOGIN_ID\"", ";", "private", "static", "final", "String", "PASSWORD", "=", "\"PASSWORD\"", ";", "private", "PayFlowProPaymentGateway_ForTest", "gateway", ";", "private", "Money", "money", ";", "private", "CreditCard", "creditCard", ";", "@", "Mock", "private", "HttpPost", "mockHttpPost", ";", "@", "Mock", "private", "HttpClient", "mockHttpClient", ";", "private", "TransactionResponse", "transactionResponse", ";", "@", "Before", "public", "void", "setUp", "(", ")", "throws", "Exception", "{", "gateway", "=", "new", "PayFlowProPaymentGateway_ForTest", "(", "USERNAME", ",", "PASSWORD", ")", ";", "gateway", ".", "setTest", "(", "true", ")", ";", "money", "=", "new", "MoneyBuilder", "(", ")", ".", "withAmount", "(", "\"10\"", ")", ".", "withCurrency", "(", "Locale", ".", "US", ")", ".", "build", "(", ")", ";", "creditCard", "=", "new", "CreditCardBuilder", "(", ")", ".", "withNumber", "(", "\"\"", ")", ".", "withFirstName", "(", "\"John\"", ")", ".", "withLastName", "(", "\"Doe\"", ")", ".", "withMonth", "(", "\"01\"", ")", ".", "withYear", "(", "\"2012\"", ")", ".", "withType", "(", "MASTER_CARD", ")", ".", "withSecurityCode", "(", "\"123\"", ")", ".", "build", "(", ")", ";", "transactionResponse", "=", "new", "TransactionResponse", "(", ")", ";", "transactionResponse", ".", "setCode", "(", "0", ")", ";", "transactionResponse", ".", "setAuthorizationId", "(", "\"123\"", ")", ";", "transactionResponse", ".", "setReasonCode", "(", "0", ")", ";", "transactionResponse", ".", "setMessage", "(", "\"Verified\"", ")", ";", "when", "(", "mockHttpClient", ".", "execute", "(", "mockHttpPost", ",", "new", "PayFlowResponseHandler", "(", ")", ")", ")", ".", "thenReturn", "(", "transactionResponse", ")", ";", "}", "@", "Test", "public", "void", "testPurchase", "(", ")", "throws", "Exception", "{", "TransactionResponse", "response", "=", "gateway", ".", "purchase", "(", "money", ",", "creditCard", ",", "null", ")", ";", "assertThatParamListEquals", "(", "\"\"", "+", "\"\"", "+", "\"\"", ")", ";", "assertThat", "(", "response", ")", ".", "isEqualTo", "(", "transactionResponse", ")", ";", "}", "@", "Test", "public", "void", "testAuthorize", "(", ")", "throws", "Exception", "{", "TransactionResponse", "response", "=", "gateway", ".", "authorize", "(", "money", ",", "creditCard", ",", "null", ")", ";", "assertThatParamListEquals", "(", "\"\"", "+", "\"\"", "+", "\"\"", ")", ";", "assertThat", "(", "response", ")", ".", "isEqualTo", "(", "transactionResponse", ")", ";", "}", "@", "Test", "public", "void", "testCapture", "(", ")", "throws", "Exception", "{", "TransactionResponse", "response", "=", "gateway", ".", "capture", "(", "money", ",", "\"SOME_ID\"", ",", "null", ")", ";", "assertThatParamListEquals", "(", "\"\"", "+", "\"\"", ")", ";", "assertThat", "(", "response", ")", ".", "isEqualTo", "(", "transactionResponse", ")", ";", "}", "@", "Test", "public", "void", "testRevert", "(", ")", "throws", "Exception", "{", "TransactionResponse", "response", "=", "gateway", ".", "revert", "(", "\"SOME_ID\"", ",", "null", ")", ";", "assertThatParamListEquals", "(", "\"\"", "+", "\"\"", ")", ";", "assertThat", "(", "response", ")", ".", "isEqualTo", "(", "transactionResponse", ")", ";", "}", "@", "Test", "public", "void", "testCredit", "(", ")", "throws", "Exception", "{", "TransactionResponse", "response", "=", "gateway", ".", "credit", "(", "money", ",", "\"SOME_ID\"", ",", "null", ")", ";", "assertThatParamListEquals", "(", "\"\"", "+", "\"\"", ")", ";", "assertThat", "(", "response", ")", ".", "isEqualTo", "(", "transactionResponse", ")", ";", "}", "private", "void", "assertThatParamListEquals", "(", "String", "paramsList", ")", "throws", "IOException", "{", "ArgumentCaptor", "<", "HttpEntity", ">", "entityArgumentCaptor", "=", "ArgumentCaptor", ".", "forClass", "(", "HttpEntity", ".", "class", ")", ";", "verify", "(", "mockHttpPost", ")", ".", "setEntity", "(", "entityArgumentCaptor", ".", "capture", "(", ")", ")", ";", "HttpEntity", "entity", "=", "entityArgumentCaptor", ".", "getValue", "(", ")", ";", "assertThat", "(", "EntityUtils", ".", "toString", "(", "entity", ")", ")", ".", "isEqualTo", "(", "paramsList", ")", ";", "}", "private", "class", "PayFlowProPaymentGateway_ForTest", "extends", "PayFlowProPaymentGateway", "{", "public", "PayFlowProPaymentGateway_ForTest", "(", "String", "username", ",", "String", "password", ")", "{", "super", "(", "username", ",", "password", ")", ";", "}", "@", "Override", "HttpPost", "buildHttpPost", "(", "String", "url", ")", "{", "assertThat", "(", "url", ")", ".", "isEqualTo", "(", "TEST_HOST_ADDRESS", ")", ";", "return", "mockHttpPost", ";", "}", "@", "Override", "HttpClient", "buildHttpClient", "(", ")", "{", "return", "mockHttpClient", ";", "}", "}", "}", "</s>" ]
8,294
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ";", "import", "org", ".", "payments4j", ".", "core", ".", "PaymentGateway", ";", "import", "org", ".", "payments4j", ".", "test", ".", "spi", ".", "AbstractBasePaymentGatewayIntegrationTest", ";", "public", "class", "PayFlowProPaymentGatewayIntegrationTest", "extends", "AbstractBasePaymentGatewayIntegrationTest", "{", "@", "Override", "protected", "PaymentGateway", "buildGateway", "(", ")", "{", "PayFlowProPaymentGateway", "gateway", "=", "new", "PayFlowProPaymentGateway", "(", "credentials", ".", "getProperty", "(", "\"\"", ")", ",", "credentials", ".", "getProperty", "(", "\"\"", ")", ")", ";", "gateway", ".", "setTest", "(", "true", ")", ";", "return", "gateway", ";", "}", "}", "</s>" ]
8,295
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ";", "import", "org", ".", "apache", ".", "http", ".", "HttpResponse", ";", "import", "org", ".", "apache", ".", "http", ".", "HttpVersion", ";", "import", "org", ".", "apache", ".", "http", ".", "entity", ".", "StringEntity", ";", "import", "org", ".", "apache", ".", "http", ".", "message", ".", "BasicHttpResponse", ";", "import", "org", ".", "apache", ".", "http", ".", "message", ".", "BasicStatusLine", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "payments4j", ".", "core", ".", "TransactionResponse", ";", "import", "java", ".", "io", ".", "UnsupportedEncodingException", ";", "import", "static", "org", ".", "fest", ".", "assertions", ".", "Assertions", ".", "assertThat", ";", "public", "class", "PayFlowResponseHandlerTest", "{", "@", "Test", "public", "void", "testHandleResponse", "(", ")", "throws", "Exception", "{", "TransactionResponse", "expectedTransaction", "=", "buildExpectedTransactionResponse", "(", "0", ",", "\"Verified\"", ",", "true", ")", ";", "HttpResponse", "httpResponse", "=", "buildHttpResponse", "(", "\"\"", ")", ";", "PayFlowResponseHandler", "handler", "=", "new", "PayFlowResponseHandler", "(", ")", ";", "TransactionResponse", "transactionResponse", "=", "handler", ".", "handleResponse", "(", "httpResponse", ")", ";", "assertThat", "(", "transactionResponse", ")", ".", "isEqualTo", "(", "expectedTransaction", ")", ";", "}", "@", "Test", "public", "void", "testHandleResponse_Failed", "(", ")", "throws", "Exception", "{", "TransactionResponse", "expectedTransaction", "=", "buildExpectedTransactionResponse", "(", "4", ",", "\"\"", ",", "false", ")", ";", "HttpResponse", "httpResponse", "=", "buildHttpResponse", "(", "\"\"", ")", ";", "PayFlowResponseHandler", "handler", "=", "new", "PayFlowResponseHandler", "(", ")", ";", "TransactionResponse", "transactionResponse", "=", "handler", ".", "handleResponse", "(", "httpResponse", ")", ";", "assertThat", "(", "transactionResponse", ")", ".", "isEqualTo", "(", "expectedTransaction", ")", ";", "}", "private", "TransactionResponse", "buildExpectedTransactionResponse", "(", "int", "code", ",", "String", "message", ",", "boolean", "successful", ")", "{", "TransactionResponse", "expectedTransaction", "=", "new", "TransactionResponse", "(", ")", ";", "expectedTransaction", ".", "setCode", "(", "code", ")", ";", "expectedTransaction", ".", "setAuthorizationId", "(", "\"123\"", ")", ";", "expectedTransaction", ".", "setReasonCode", "(", "code", ")", ";", "expectedTransaction", ".", "setMessage", "(", "message", ")", ";", "expectedTransaction", ".", "setSuccessful", "(", "successful", ")", ";", "return", "expectedTransaction", ";", "}", "private", "HttpResponse", "buildHttpResponse", "(", "String", "responseString", ")", "throws", "UnsupportedEncodingException", "{", "HttpResponse", "httpResponse", "=", "new", "BasicHttpResponse", "(", "new", "BasicStatusLine", "(", "HttpVersion", ".", "HTTP_1_1", ",", "200", ",", "\"\"", ")", ",", "null", ",", "null", ")", ";", "httpResponse", ".", "setEntity", "(", "new", "StringEntity", "(", "responseString", ")", ")", ";", "httpResponse", ".", "setStatusCode", "(", "200", ")", ";", "return", "httpResponse", ";", "}", "}", "</s>" ]
8,296
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ".", "converter", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ".", "Pair", ";", "import", "java", ".", "util", ".", "List", ";", "import", "static", "org", ".", "fest", ".", "assertions", ".", "Assertions", ".", "assertThat", ";", "public", "abstract", "class", "AbstractBaseConverterTest", "{", "@", "Test", "public", "void", "testToParamsList", "(", ")", "throws", "Exception", "{", "AbstractBaseConverter", "converter", "=", "buildConverter", "(", ")", ";", "List", "<", "Pair", ">", "params", "=", "converter", ".", "toParamsList", "(", ")", ";", "assertThat", "(", "params", ")", ".", "containsOnly", "(", "(", "Object", "[", "]", ")", "expectedParams", "(", ")", ")", ";", "}", "protected", "abstract", "Pair", "[", "]", "expectedParams", "(", ")", ";", "protected", "abstract", "AbstractBaseConverter", "buildConverter", "(", ")", ";", "}", "</s>" ]
8,297
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ".", "converter", ";", "import", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ";", "import", "org", ".", "payments4j", ".", "model", ".", "CreditCardBuilder", ";", "import", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ".", "Pair", ";", "import", "static", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ".", "Type", ".", "MASTER_CARD", ";", "public", "class", "CreditCardConverterTest", "extends", "AbstractBaseConverterTest", "{", "@", "Override", "protected", "Pair", "[", "]", "expectedParams", "(", ")", "{", "return", "new", "Pair", "[", "]", "{", "new", "Pair", "(", "\"ACCT\"", ",", "\"\"", ")", ",", "new", "Pair", "(", "\"FIRSTNAME\"", ",", "\"John\"", ")", ",", "new", "Pair", "(", "\"LASTNAME\"", ",", "\"Doe\"", ")", ",", "new", "Pair", "(", "\"EXPDATE\"", ",", "\"0112\"", ")", ",", "new", "Pair", "(", "\"CVV2\"", ",", "\"123\"", ")", ",", "new", "Pair", "(", "\"TENDER\"", ",", "\"C\"", ")", "}", ";", "}", "@", "Override", "protected", "AbstractBaseConverter", "buildConverter", "(", ")", "{", "CreditCard", "creditCard", "=", "new", "CreditCardBuilder", "(", ")", ".", "withNumber", "(", "\"\"", ")", ".", "withFirstName", "(", "\"John\"", ")", ".", "withLastName", "(", "\"Doe\"", ")", ".", "withMonth", "(", "\"01\"", ")", ".", "withYear", "(", "\"2012\"", ")", ".", "withType", "(", "MASTER_CARD", ")", ".", "withSecurityCode", "(", "\"123\"", ")", ".", "build", "(", ")", ";", "return", "new", "CreditCardConverter", "(", "creditCard", ")", ";", "}", "}", "</s>" ]
8,298
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ".", "converter", ";", "import", "org", ".", "payments4j", ".", "model", ".", "Money", ";", "import", "org", ".", "payments4j", ".", "model", ".", "MoneyBuilder", ";", "import", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ".", "Pair", ";", "import", "java", ".", "util", ".", "Locale", ";", "public", "class", "MoneyConverterTest", "extends", "AbstractBaseConverterTest", "{", "@", "Override", "protected", "AbstractBaseConverter", "buildConverter", "(", ")", "{", "Money", "money", "=", "new", "MoneyBuilder", "(", ")", ".", "withAmount", "(", "\"10\"", ")", ".", "withCurrency", "(", "Locale", ".", "US", ")", ".", "build", "(", ")", ";", "return", "new", "MoneyConverter", "(", "money", ")", ";", "}", "protected", "Pair", "[", "]", "expectedParams", "(", ")", "{", "return", "new", "Pair", "[", "]", "{", "new", "Pair", "(", "\"AMT\"", ",", "\"10.00\"", ")", ",", "new", "Pair", "(", "\"CURRENCY\"", ",", "\"USD\"", ")", ",", "}", ";", "}", "}", "</s>" ]
8,299
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ".", "converter", ";", "import", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ".", "Pair", ";", "public", "class", "CredentialsConverterTest", "extends", "AbstractBaseConverterTest", "{", "@", "Override", "protected", "AbstractBaseConverter", "buildConverter", "(", ")", "{", "return", "new", "CredentialsConverter", "(", "\"\"", ",", "\"\"", ")", ";", "}", "@", "Override", "protected", "Pair", "[", "]", "expectedParams", "(", ")", "{", "return", "new", "Pair", "[", "]", "{", "new", "Pair", "(", "\"USER\"", ",", "\"\"", ")", ",", "new", "Pair", "(", "\"VENDOR\"", ",", "\"\"", ")", ",", "new", "Pair", "(", "\"PWD\"", ",", "\"\"", ")", ",", "new", "Pair", "(", "\"PARTNER\"", ",", "\"PayPal\"", ")", "}", ";", "}", "}", "</s>" ]