Example usage for android.os Trace beginSection

List of usage examples for android.os Trace beginSection

Introduction

In this page you can find the example usage for android.os Trace beginSection.

Prototype

public static void beginSection(String sectionName) 

Source Link

Document

Writes a trace message to indicate that a given section of code has begun.

Usage

From source file:com.android.dialer.list.ListsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Trace.beginSection(TAG + " onCreateView");
    Trace.beginSection(TAG + " inflate view");
    final View parentView = inflater.inflate(R.layout.lists_fragment, container, false);
    Trace.endSection();/*from   w  ww .j ava  2 s.c o  m*/
    Trace.beginSection(TAG + " setup views");
    mViewPager = (ViewPager) parentView.findViewById(R.id.lists_pager);
    mViewPagerAdapter = new ViewPagerAdapter(getChildFragmentManager());
    mViewPager.setAdapter(mViewPagerAdapter);
    mViewPager.setOffscreenPageLimit(TAB_COUNT_WITH_VOICEMAIL - 1);
    mViewPager.setOnPageChangeListener(this);
    showTab(TAB_INDEX_SPEED_DIAL);

    mTabTitles = new String[TAB_COUNT_WITH_VOICEMAIL];
    mTabTitles[TAB_INDEX_SPEED_DIAL] = getResources().getString(R.string.tab_speed_dial);
    mTabTitles[TAB_INDEX_HISTORY] = getResources().getString(R.string.tab_history);
    mTabTitles[TAB_INDEX_ALL_CONTACTS] = getResources().getString(R.string.tab_all_contacts);
    mTabTitles[TAB_INDEX_VOICEMAIL] = getResources().getString(R.string.tab_voicemail);

    mTabIcons = new int[TAB_COUNT_WITH_VOICEMAIL];
    mTabIcons[TAB_INDEX_SPEED_DIAL] = R.drawable.ic_grade_24dp;
    mTabIcons[TAB_INDEX_HISTORY] = R.drawable.ic_schedule_24dp;
    mTabIcons[TAB_INDEX_ALL_CONTACTS] = R.drawable.ic_people_24dp;
    mTabIcons[TAB_INDEX_VOICEMAIL] = R.drawable.ic_voicemail_24dp;

    mViewPagerTabs = (ViewPagerTabs) parentView.findViewById(R.id.lists_pager_header);
    mViewPagerTabs.configureTabIcons(mTabIcons);
    mViewPagerTabs.setViewPager(mViewPager);
    addOnPageChangeListener(mViewPagerTabs);

    mRemoveView = (RemoveView) parentView.findViewById(R.id.remove_view);
    mRemoveViewContent = parentView.findViewById(R.id.remove_view_content);

    Trace.endSection();
    Trace.endSection();
    return parentView;
}

From source file:com.android.incallui.CallCardFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Trace.beginSection(TAG + " onCreate");
    mTranslationOffset = getResources().getDimensionPixelSize(R.dimen.call_card_anim_translate_y_offset);
    final View view = inflater.inflate(R.layout.call_card_fragment, container, false);
    Trace.endSection();// w ww .j ava2 s . c om
    return view;
}

From source file:org.tensorflow.demo.Camera2BasicFragment.java

private void classifyImage(Image image) {
    try {/*from  w w  w.  j  av a  2s.c o m*/
        Log.d("predict_class", "1");

        if (image == null) {
            return;
        }

        if (computing) {
            image.close();
            return;
        }
        Log.d("predict_class", "2");
        computing = true;

        Trace.beginSection("imageAvailable");
        Log.d("predict_class", image.getHeight() + "");
        Log.d("predict_class", image.getWidth() + "");

        final Image.Plane[] planes = image.getPlanes();

        fillBytes(planes, yuvBytes);

        final int yRowStride = planes[0].getRowStride();

        final int uvRowStride = planes[1].getRowStride();

        final int uvPixelStride = planes[1].getPixelStride();

        ImageUtils.convertYUV420ToARGB8888(yuvBytes[0], yuvBytes[1], yuvBytes[2], rgbBytes, previewWidth,
                previewHeight, yRowStride, uvRowStride, uvPixelStride, false);

        image.close();

    } catch (final Exception e) {
        Log.d("predict_class", "error: " + e.getMessage());

        if (image != null) {
            image.close();
        }
        LOGGER.e(e, "Exception!");
        Trace.endSection();
        return;
    }

    rgbFrameBitmap.setPixels(rgbBytes, 0, previewWidth, 0, 0, previewWidth, previewHeight);

    final Canvas canvas = new Canvas(croppedBitmap);
    canvas.drawBitmap(rgbFrameBitmap, frameToCropTransform, null);

    // For examining the actual TF input.
    if (SAVE_PREVIEW_BITMAP) {
        ImageUtils.saveBitmap(croppedBitmap);
    }

    runInBackground(new Runnable() {
        @Override
        public void run() {
            final long startTime = SystemClock.uptimeMillis();
            final List<Classifier.Recognition> results = classifier.recognizeImage(croppedBitmap);
            lastProcessingTimeMs = SystemClock.uptimeMillis() - startTime;
            String toastString = "";
            Log.d("predict_class", results.toString());
            for (Classifier.Recognition cr : results) {
                toastString = toastString + " " + cr.getTitle() + ": " + cr.getConfidence() + ";";
            }
            Log.d("predict_class", toastString);

            //showToast(toastString);
            Intent intent = new Intent(getActivity(), ClassifierResultActivity.class);
            Gson gs = new Gson();
            String resultString = gs.toJson(results);
            intent.putExtra("result", resultString);
            startActivity(intent);

            cropCopyBitmap = Bitmap.createBitmap(croppedBitmap);
            computing = false;
        }
    });

    Trace.endSection();
}

From source file:com.android.dialer.DialtactsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Trace.beginSection(TAG + " onCreate");
    super.onCreate(savedInstanceState);

    mFirstLaunch = true;//from ww w  .j  a v a2s.c o  m

    final Resources resources = getResources();
    mActionBarHeight = resources.getDimensionPixelSize(R.dimen.action_bar_height_large);

    Trace.beginSection(TAG + " setContentView");
    setContentView(R.layout.dialtacts_activity);
    Trace.endSection();
    getWindow().setBackgroundDrawable(null);

    Trace.beginSection(TAG + " setup Views");
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setCustomView(R.layout.search_edittext);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setBackgroundDrawable(null);

    SearchEditTextLayout searchEditTextLayout = (SearchEditTextLayout) actionBar.getCustomView()
            .findViewById(R.id.search_view_container);
    searchEditTextLayout.setPreImeKeyListener(mSearchEditTextLayoutListener);

    mActionBarController = new ActionBarController(this, searchEditTextLayout);

    mSearchView = (EditText) searchEditTextLayout.findViewById(R.id.search_view);
    mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener);
    mVoiceSearchButton = searchEditTextLayout.findViewById(R.id.voice_search_button);
    searchEditTextLayout.findViewById(R.id.search_magnifying_glass)
            .setOnClickListener(mSearchViewOnClickListener);
    searchEditTextLayout.findViewById(R.id.search_box_start_search)
            .setOnClickListener(mSearchViewOnClickListener);
    searchEditTextLayout.setOnClickListener(mSearchViewOnClickListener);
    searchEditTextLayout.setCallback(new SearchEditTextLayout.Callback() {
        @Override
        public void onBackButtonClicked() {
            onBackPressed();
        }

        @Override
        public void onSearchViewClicked() {
            // Hide FAB, as the keyboard is shown.
            mFloatingActionButtonController.scaleOut();
        }
    });

    mIsLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    mPreviouslySelectedTabIndex = ListsFragment.TAB_INDEX_SPEED_DIAL;
    final View floatingActionButtonContainer = findViewById(R.id.floating_action_button_container);
    ImageButton floatingActionButton = (ImageButton) findViewById(R.id.floating_action_button);
    floatingActionButton.setOnClickListener(this);
    mFloatingActionButtonController = new FloatingActionButtonController(this, floatingActionButtonContainer,
            floatingActionButton);

    ImageButton optionsMenuButton = (ImageButton) searchEditTextLayout
            .findViewById(R.id.dialtacts_options_menu_button);
    optionsMenuButton.setOnClickListener(this);
    mOverflowMenu = buildOptionsMenu(searchEditTextLayout);
    optionsMenuButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener());

    // Add the favorites fragment but only if savedInstanceState is null. Otherwise the
    // fragment manager is responsible for recreating it.
    if (savedInstanceState == null) {
        getFragmentManager().beginTransaction()
                .add(R.id.dialtacts_frame, new ListsFragment(), TAG_FAVORITES_FRAGMENT).commit();
    } else {
        mSearchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY);
        mInRegularSearch = savedInstanceState.getBoolean(KEY_IN_REGULAR_SEARCH_UI);
        mInDialpadSearch = savedInstanceState.getBoolean(KEY_IN_DIALPAD_SEARCH_UI);
        mFirstLaunch = savedInstanceState.getBoolean(KEY_FIRST_LAUNCH);
        mShowDialpadOnResume = savedInstanceState.getBoolean(KEY_IS_DIALPAD_SHOWN);
        mActionBarController.restoreInstanceState(savedInstanceState);
    }

    final boolean isLayoutRtl = DialerUtils.isRtl();
    if (mIsLandscape) {
        mSlideIn = AnimationUtils.loadAnimation(this,
                isLayoutRtl ? R.anim.dialpad_slide_in_left : R.anim.dialpad_slide_in_right);
        mSlideOut = AnimationUtils.loadAnimation(this,
                isLayoutRtl ? R.anim.dialpad_slide_out_left : R.anim.dialpad_slide_out_right);
    } else {
        mSlideIn = AnimationUtils.loadAnimation(this, R.anim.dialpad_slide_in_bottom);
        mSlideOut = AnimationUtils.loadAnimation(this, R.anim.dialpad_slide_out_bottom);
    }

    mSlideIn.setInterpolator(AnimUtils.EASE_IN);
    mSlideOut.setInterpolator(AnimUtils.EASE_OUT);

    mSlideIn.setAnimationListener(mSlideInListener);
    mSlideOut.setAnimationListener(mSlideOutListener);

    mParentLayout = (CoordinatorLayout) findViewById(R.id.dialtacts_mainlayout);
    mParentLayout.setOnDragListener(new LayoutOnDragListener());
    floatingActionButtonContainer.getViewTreeObserver()
            .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    final ViewTreeObserver observer = floatingActionButtonContainer.getViewTreeObserver();
                    if (!observer.isAlive()) {
                        return;
                    }
                    observer.removeOnGlobalLayoutListener(this);
                    int screenWidth = mParentLayout.getWidth();
                    mFloatingActionButtonController.setScreenWidth(screenWidth);
                    mFloatingActionButtonController.align(getFabAlignment(), false /* animate */);
                }
            });

    Trace.endSection();

    Trace.beginSection(TAG + " initialize smart dialing");
    mDialerDatabaseHelper = DatabaseHelperManager.getDatabaseHelper(this);
    SmartDialPrefix.initializeNanpSettings(this);
    Trace.endSection();
    Trace.endSection();
}

From source file:com.android.dialer.DialtactsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.e(TAG, " --- onCreate(Bundle savedInstanceState) ---  start ");
    Trace.beginSection(TAG + " onCreate");
    View retView = null;//from  w  w  w . j  a va2  s  .co  m
    super.onCreateView(inflater, container, savedInstanceState);

    //??
    iControlDeleteBtn = (IControlDeleteBtn) getActivity();

    //mFirstLaunch = true;

    final Resources resources = getResources();
    int temp = resources.getDimensionPixelSize(R.dimen.floating_action_button_width);
    //?actionbar
    mActionBarHeight = resources.getDimensionPixelSize(R.dimen.action_bar_height_large);

    Trace.beginSection(TAG + " setContentView");
    //setContentView(R.layout.dialtacts_activity);
    retView = inflater.inflate(R.layout.dialtacts_activity, container, false);
    Trace.endSection();

    Trace.beginSection(TAG + " setup Views");
    final ActionBar actionBar = getActivity().getActionBar();
    //actionbar?
    //actionBar.setCustomView(R.layout.dialtacts_actionbar);
    //actionBar.setDisplayShowCustomEnabled(true);
    TextView actionbarNameTxt = (TextView) actionBar.getCustomView().findViewById(R.id.actionbar_name);
    actionbarNameTxt.setOnClickListener(this);
    ImageView actionbarMenu = (ImageView) actionBar.getCustomView().findViewById(R.id.actionbar_menu);
    actionbarMenu.setOnClickListener(this);
    TextView editerToCalldetail = (TextView) actionBar.getCustomView()
            .findViewById(R.id.actionbar_call_dialtacts_action_editer);
    editerToCalldetail.setOnClickListener(this);
    TextView cancelTxt = (TextView) actionBar.getCustomView()
            .findViewById(R.id.actionbar_call_dialtacts_action_cancel);
    cancelTxt.setOnClickListener(this);
    actionbarNameTxt.setText(getString(R.string.all_calls));
    mSearchView = (EditText) actionBar.getCustomView().findViewById(R.id.edittext);
    mSearchView.setVisibility(View.GONE);
    mDialtactsActionBarController = new DialtactsActionBarController(actionbarMenu, editerToCalldetail,
            cancelTxt, actionbarNameTxt, this);
    //        actionBar.setBackgroundDrawable(null);

    SearchEditTextLayout searchEditTextLayout = (SearchEditTextLayout) actionBar.getCustomView()
            .findViewById(R.id.search_view_container);
    //        searchEditTextLayout.setPreImeKeyListener(mSearchEditTextLayoutListener);

    //        mActionBarController = new DialtactsActionBarController(this, searchEditTextLayout);

    //        mSearchView = (EditText) searchEditTextLayout.findViewById(R.id.search_view);
    mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener);
    //        mVoiceSearchButton = searchEditTextLayout.findViewById(R.id.voice_search_button);
    //        mSearchView.setOnClickListener(mSearchViewOnClickListener);
    //        searchEditTextLayout.findViewById(R.id.search_box_start_search)
    //                .setOnClickListener(mSearchViewOnClickListener);
    //        searchEditTextLayout.setOnClickListener(mSearchViewOnClickListener);
    //        searchEditTextLayout.setCallback(new SearchEditTextLayout.Callback() {
    //            @Override
    //            public void onBackButtonClicked() {
    //                onBackPressed();
    //            }
    //
    //            @Override
    //            public void onSearchViewClicked() {
    //                // Hide FAB, as the keyboard is shown.
    ////                mFloatingActionButtonController.scaleOut();
    //            }
    //        });
    mIsLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;

    //        ImageButton optionsMenuButton =
    //                (ImageButton) searchEditTextLayout.findViewById(R.id.dialtacts_options_menu_button);
    //        optionsMenuButton.setOnClickListener(this);
    //        mOverflowMenu = buildOptionsMenu(searchEditTextLayout);
    //        optionsMenuButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener());

    // Add the favorites fragment but only if savedInstanceState is null. Otherwise the
    // fragment manager is responsible for recreating it.
    //???
    if (savedInstanceState == null) {
        getChildFragmentManager().beginTransaction()
                .add(R.id.dialtacts_container, new DialpadFragment(getActivity()), TAG_DIALPAD_FRAGMENT)
                //                   .add(R.id.dialtacts_frame, new ListsFragment(), TAG_FAVORITES_FRAGMENT)
                .commit();
    } else {
        mSearchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY);
        mInRegularSearch = savedInstanceState.getBoolean(KEY_IN_REGULAR_SEARCH_UI);
        mInDialpadSearch = savedInstanceState.getBoolean(KEY_IN_DIALPAD_SEARCH_UI);
        mFirstLaunch = savedInstanceState.getBoolean(KEY_FIRST_LAUNCH);
        mShowDialpadOnResume = savedInstanceState.getBoolean(KEY_IS_DIALPAD_SHOWN);
        //            mActionBarController.restoreInstanceState(savedInstanceState);
    }

    final boolean isLayoutRtl = DialerUtils.isRtl();
    //??????
    if (mIsLandscape) {
        //??
        mSlideIn = AnimationUtils.loadAnimation(getActivity(),
                isLayoutRtl ? R.anim.dialpad_slide_in_left : R.anim.dialpad_slide_in_right);
        mSlideOut = AnimationUtils.loadAnimation(getActivity(),
                isLayoutRtl ? R.anim.dialpad_slide_out_left : R.anim.dialpad_slide_out_right);
    } else {
        mSlideIn = AnimationUtils.loadAnimation(getActivity(), R.anim.dialpad_slide_in_bottom);
        mSlideOut = AnimationUtils.loadAnimation(getActivity(), R.anim.dialpad_slide_out_bottom);
    }

    //        mSlideIn.setInterpolator(AnimUtils.EASE_IN);
    mSlideOut.setInterpolator(AnimUtils.EASE_OUT);

    mSlideIn.setAnimationListener(mSlideInListener);
    mSlideOut.setAnimationListener(mSlideOutListener);

    Trace.endSection();

    Trace.beginSection(TAG + " initialize smart dialing");
    mDialerDatabaseHelper = DatabaseHelperManager.getDatabaseHelper(getActivity());
    SmartDialPrefix.initializeNanpSettings(getActivity());
    Trace.endSection();
    Trace.endSection();
    initFlushHandler();

    Log.e(TAG, " onCreate()  dialerFragment  " + mIsDialpadShown);
    return retView;
}

From source file:com.android.dialer.DialtactsActivity.java

@Override
protected void onResume() {
    Trace.beginSection(TAG + " onResume");
    super.onResume();

    mStateSaved = false;/*from  ww w  .  j a  v a  2  s  .c om*/
    if (mFirstLaunch) {
        displayFragment(getIntent());
    } else if (!phoneIsInUse() && mInCallDialpadUp) {
        hideDialpadFragment(false, true);
        mInCallDialpadUp = false;
    } else if (mShowDialpadOnResume) {
        showDialpadFragment(false);
        mShowDialpadOnResume = false;
    }

    // If there was a voice query result returned in the {@link #onActivityResult} callback, it
    // will have been stashed in mVoiceSearchQuery since the search results fragment cannot be
    // shown until onResume has completed.  Active the search UI and set the search term now.
    if (!TextUtils.isEmpty(mVoiceSearchQuery)) {
        mActionBarController.onSearchBoxTapped();
        mSearchView.setText(mVoiceSearchQuery);
        mVoiceSearchQuery = null;
    }

    mFirstLaunch = false;

    if (mIsRestarting) {
        // This is only called when the activity goes from resumed -> paused -> resumed, so it
        // will not cause an extra view to be sent out on rotation
        if (mIsDialpadShown) {
            Logger.logScreenView(ScreenEvent.DIALPAD, this);
        }
        mIsRestarting = false;
    }

    prepareVoiceSearchButton();
    mDialerDatabaseHelper.startSmartDialUpdateThread();
    mFloatingActionButtonController.align(getFabAlignment(), false /* animate */);

    if (Calls.CONTENT_TYPE.equals(getIntent().getType())) {
        // Externally specified extras take precedence to EXTRA_SHOW_TAB, which is only
        // used internally.
        final Bundle extras = getIntent().getExtras();
        if (extras != null && extras.getInt(Calls.EXTRA_CALL_TYPE_FILTER) == Calls.VOICEMAIL_TYPE) {
            mListsFragment.showTab(ListsFragment.TAB_INDEX_VOICEMAIL);
        } else {
            mListsFragment.showTab(ListsFragment.TAB_INDEX_HISTORY);
        }
    } else if (getIntent().hasExtra(EXTRA_SHOW_TAB)) {
        int index = getIntent().getIntExtra(EXTRA_SHOW_TAB, ListsFragment.TAB_INDEX_SPEED_DIAL);
        if (index < mListsFragment.getTabCount()) {
            mListsFragment.showTab(index);
        }
    }

    setSearchBoxHint();

    Trace.endSection();
}

From source file:com.android.launcher3.Launcher.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (DEBUG_STRICT_MODE) {
        StrictMode.setThreadPolicy(//from ww  w .ja  v  a 2  s .c o  m
                new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork() // or .detectAll() for all detectable problems
                        .penaltyLog().build());
        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects()
                .detectLeakedClosableObjects().penaltyLog().penaltyDeath().build());
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (LauncherAppState.PROFILE_STARTUP) {
            Trace.beginSection("Launcher-onCreate");
        }
    }

    predictiveAppsProvider = new PredictiveAppsProvider(this);

    if (mLauncherCallbacks != null) {
        mLauncherCallbacks.preOnCreate();
    }

    super.onCreate(savedInstanceState);

    app = LauncherAppState.getInstance();

    // Load configuration-specific DeviceProfile
    mDeviceProfile = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE
            ? app.getInvariantDeviceProfile().landscapeProfile
            : app.getInvariantDeviceProfile().portraitProfile;

    mSharedPrefs = Utilities.getPrefs(this);
    mIsSafeModeEnabled = getPackageManager().isSafeMode();
    mModel = app.setLauncher(this);
    mIconCache = app.getIconCache();
    mAccessibilityDelegate = new LauncherAccessibilityDelegate(this);

    mDragController = new DragController(this);
    mAllAppsController = new AllAppsTransitionController(this);
    mStateTransitionAnimation = new LauncherStateTransitionAnimation(this, mAllAppsController);

    mAppWidgetManager = AppWidgetManagerCompat.getInstance(this);

    mAppWidgetHost = new LauncherAppWidgetHost(this, APPWIDGET_HOST_ID);
    mAppWidgetHost.startListening();

    // If we are getting an onCreate, we can actually preempt onResume and unset mPaused here,
    // this also ensures that any synchronous binding below doesn't re-trigger another
    // LauncherModel load.
    mPaused = false;

    setContentView(R.layout.launcher);

    //Shortcuts variable init
    masterLayout = (InsettableFrameLayout) findViewById(R.id.launcher);
    gridSize = new GridSize((int) app.getInvariantDeviceProfile().numColumns,
            (int) app.getInvariantDeviceProfile().numRows);

    IS_ALLOW_MIC = Utilities.isAllowVoiceInSearchBarPrefEnabled(getApplicationContext());

    setupViews();
    mDeviceProfile.layout(this, false /* notifyListeners */);
    mExtractedColors = new ExtractedColors();
    loadExtractedColorsAndColorItems();

    ((AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE)).addAccessibilityStateChangeListener(this);

    lockAllApps();

    mSavedState = savedInstanceState;
    restoreState(mSavedState);

    if (LauncherAppState.PROFILE_STARTUP) {
        Trace.endSection();
    }

    // We only load the page synchronously if the user rotates (or triggers a
    // configuration change) while launcher is in the foreground
    if (!mModel.startLoader(mWorkspace.getRestorePage())) {
        // If we are not binding synchronously, show a fade in animation when
        // the first page bind completes.
        mDragLayer.setAlpha(0);
    } else {
        setWorkspaceLoading(true);
    }

    // For handling default keys
    mDefaultKeySsb = new SpannableStringBuilder();
    Selection.setSelection(mDefaultKeySsb, 0);

    IntentFilter filter = new IntentFilter(ACTION_APPWIDGET_HOST_RESET);
    registerReceiver(mUiBroadcastReceiver, filter);

    mRotationEnabled = getResources().getBoolean(R.bool.allow_rotation);
    // In case we are on a device with locked rotation, we should look at preferences to check
    // if the user has specifically allowed rotation.
    if (!mRotationEnabled) {
        mRotationEnabled = Utilities.isAllowRotationPrefEnabled(getApplicationContext());
        mRotationPrefChangeHandler = new RotationPrefChangeHandler();
        mSharedPrefs.registerOnSharedPreferenceChangeListener(mRotationPrefChangeHandler);
    }

    // On large interfaces, or on devices that a user has specifically enabled screen rotation,
    // we want the screen to auto-rotate based on the current orientation
    setOrientation();

    if (mLauncherCallbacks != null) {
        mLauncherCallbacks.onCreate(savedInstanceState);
    }

    activity = this;
    /*if (!isTaskRoot()) {
    finish();
    return;
    }*/

    adminComponent = new ComponentName(Launcher.this, DarClass.class);
    devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);

    appHasFingerprint = Utilities.getAppHasFingerprint(getApplicationContext());
    appHasPassword = Utilities.getAppHasPassword(getApplicationContext());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        fingerprintManager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
    }

    icons = Utilities.getIconPack(Utilities.getAppIconPackageNamePrefEnabled(getApplicationContext()));
    if (icons == null || icons.isEmpty() || icons.size() == 0) {
        if (Utilities.getAppIconPackageNamePrefEnabled(getApplicationContext()) != null && !Utilities
                .getAppIconPackageNamePrefEnabled(getApplicationContext()).equalsIgnoreCase("NULL")) {
            Utilities.answerToRestoreIconPack(this,
                    Utilities.getAppIconPackageNamePrefEnabled(getApplicationContext()));
        }
    }

    if (FirstRun.isFirstLaunch(getApplicationContext())) {
        WallpaperManager myWallpaperManager = WallpaperManager.getInstance(getApplicationContext());
        try {
            myWallpaperManager.setResource(R.drawable.wallpaper);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    if (Utilities.doCheckPROVersion(getApplicationContext())) {

    }

    mDefaultScreenId = Utilities.getLongCustomDefault(this, Utilities.SETTINGS_UI_HOMESCREEN_DEFAULT_SCREEN_ID,
            1);
}

From source file:com.android.dialer.DialtactsFragment.java

@Override
public void onResume() {
    Trace.beginSection(TAG + " onResume");
    super.onResume();

    if (!isInSearchUi()) {
        //if(mCalllogList != null)
        //   mCalllogList.scrollToTop();
        //            showDialpadFragment(false);
        Log.e(TAG, " ------ onResume() ----    hide 1");
    } else {/*  w ww.  jav a  2  s.c  o  m*/
        showSearchFragment();
        showDialpadFragment(true);
        mFloatingActionButtonController.setVisible(true);
        Log.e(TAG, " ----- onResume() -----  show 2");
    }

    mStateSaved = false;
    if (mFirstLaunch) {
        displayFragment(getActivity().getIntent());
        Log.e(TAG, " onResume show ");
    } else if (!phoneIsInUse() && mInCallDialpadUp) {
        hideDialpadFragment(false, true);
        mInCallDialpadUp = false;
        Log.e(TAG, " ---- onResume() --- show 2");
    } else if (mShowDialpadOnResume) {
        showDialpadFragment(false);
        mShowDialpadOnResume = true;
        Log.e(TAG, " ---- onResume() ---- 3 ");
        if (getCallLogFragment() != null) {
            mCalllogList = (CallLogFragment) getCallLogFragment();
            mCalllogList.setRecyclerViewChangedImpl(mRecyclerViewChangedImpl);
        } else {
            Log.d(TAG, "getCallLogFragment == null importent log ********");
        }
    }

    // If there was a voice query result returned in the {@link #onActivityResult} callback, it
    // will have been stashed in mVoiceSearchQuery since the search results fragment cannot be
    // shown until onResume has completed.  Active the search UI and set the search term now.
    if (!TextUtils.isEmpty(mVoiceSearchQuery)) {
        //            mActionBarController.onSearchBoxTapped();
        mSearchView.setText(mVoiceSearchQuery);
        //            mVoiceSearchQuery = null;
    }

    mFirstLaunch = false;

    //        if (mIsRestarting) {
    //            // This is only called when the activity goes from resumed -> paused -> resumed, so it
    //            // will not cause an extra view to be sent out on rotation
    //            if (mIsDialpadShown) {
    //                AnalyticsUtil.sendScreenView(mDialpadFragment, this);
    //                Log.e(TAG," ----- onResume() ----- 4   mIsDialpadShown is true ");
    //            }
    //            mIsRestarting = false;
    //        }

    prepareVoiceSearchButton();
    mDialerDatabaseHelper.startSmartDialUpdateThread();
    mFloatingActionButtonController.align(getFabAlignment(), false /* animate */);

    if (getActivity().getIntent().hasExtra(EXTRA_SHOW_TAB)) {
        int index = getActivity().getIntent().getIntExtra(EXTRA_SHOW_TAB, ListsFragment.TAB_INDEX_SPEED_DIAL);
        if (index < mListsFragment.getTabCount()) {
            mListsFragment.showTab(index);
        }
    } else if (Calls.CONTENT_TYPE.equals(getActivity().getIntent().getType())) {
        if (mListsFragment != null) {
            mListsFragment.showTab(ListsFragment.TAB_INDEX_RECENTS);
        }
    }

    actionbarMenuOpen();
    Trace.endSection();
    sendMessageToReflushEditerView();

    Log.e(TAG, " onResume mFloatingActionButtonController " + mFloatingActionButtonController.isVisible());

}

From source file:com.android.contacts.quickcontact.QuickContactActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Trace.beginSection("onCreate()");
    super.onCreate(savedInstanceState);

    if (RequestPermissionsActivity.startPermissionActivity(this)
            || RequestDesiredPermissionsActivity.startPermissionActivity(this)) {
        return;//from www . j a v a 2 s .  c  om
    }

    final int previousScreenType = getIntent().getIntExtra(EXTRA_PREVIOUS_SCREEN_TYPE, ScreenType.UNKNOWN);
    Logger.logScreenView(this, ScreenType.QUICK_CONTACT, previousScreenType);

    if (CompatUtils.isLollipopCompatible()) {
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }

    processIntent(getIntent());

    // Show QuickContact in front of soft input
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
            WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);

    setContentView(R.layout.quickcontact_activity);

    mMaterialColorMapUtils = new MaterialColorMapUtils(getResources());

    mScroller = (MultiShrinkScroller) findViewById(R.id.multiscroller);

    mContactCard = (ExpandingEntryCardView) findViewById(R.id.communication_card);
    mNoContactDetailsCard = (ExpandingEntryCardView) findViewById(R.id.no_contact_data_card);
    mRecentCard = (ExpandingEntryCardView) findViewById(R.id.recent_card);
    mAboutCard = (ExpandingEntryCardView) findViewById(R.id.about_card);

    mCollapsedSuggestionCardView = (CardView) findViewById(R.id.collapsed_suggestion_card);
    mExpandSuggestionCardView = (CardView) findViewById(R.id.expand_suggestion_card);
    mCollapasedSuggestionHeader = findViewById(R.id.collapsed_suggestion_header);
    mCollapsedSuggestionCardTitle = (TextView) findViewById(R.id.collapsed_suggestion_card_title);
    mExpandSuggestionCardTitle = (TextView) findViewById(R.id.expand_suggestion_card_title);
    mSuggestionSummaryPhoto = (ImageView) findViewById(R.id.suggestion_icon);
    mSuggestionForName = (TextView) findViewById(R.id.suggestion_for_name);
    mSuggestionContactsNumber = (TextView) findViewById(R.id.suggestion_for_contacts_number);
    mSuggestionList = (LinearLayout) findViewById(R.id.suggestion_list);
    mSuggestionsCancelButton = (Button) findViewById(R.id.cancel_button);
    mSuggestionsLinkButton = (Button) findViewById(R.id.link_button);
    if (savedInstanceState != null) {
        mIsSuggestionListCollapsed = savedInstanceState.getBoolean(KEY_IS_SUGGESTION_LIST_COLLAPSED, true);
        mPreviousContactId = savedInstanceState.getLong(KEY_PREVIOUS_CONTACT_ID);
        mSuggestionsShouldAutoSelected = savedInstanceState.getBoolean(KEY_SUGGESTIONS_AUTO_SELECTED, true);
        mSelectedAggregationIds = (TreeSet<Long>) savedInstanceState
                .getSerializable(KEY_SELECTED_SUGGESTION_CONTACTS);
    } else {
        mIsSuggestionListCollapsed = true;
        mSelectedAggregationIds.clear();
    }
    if (mSelectedAggregationIds.isEmpty()) {
        disableLinkButton();
    } else {
        enableLinkButton();
    }
    mCollapasedSuggestionHeader.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            mCollapsedSuggestionCardView.setVisibility(View.GONE);
            mExpandSuggestionCardView.setVisibility(View.VISIBLE);
            mIsSuggestionListCollapsed = false;
            mExpandSuggestionCardTitle.requestFocus();
            mExpandSuggestionCardTitle.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
        }
    });

    mSuggestionsCancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            mCollapsedSuggestionCardView.setVisibility(View.VISIBLE);
            mExpandSuggestionCardView.setVisibility(View.GONE);
            mIsSuggestionListCollapsed = true;
        }
    });

    mNoContactDetailsCard.setOnClickListener(mEntryClickHandler);
    mContactCard.setOnClickListener(mEntryClickHandler);
    mContactCard.setExpandButtonText(getResources().getString(R.string.expanding_entry_card_view_see_all));
    mContactCard.setOnCreateContextMenuListener(mEntryContextMenuListener);

    mRecentCard.setOnClickListener(mEntryClickHandler);
    mRecentCard.setTitle(getResources().getString(R.string.recent_card_title));

    mAboutCard.setOnClickListener(mEntryClickHandler);
    mAboutCard.setOnCreateContextMenuListener(mEntryContextMenuListener);

    mPhotoView = (QuickContactImageView) findViewById(R.id.photo);
    final View transparentView = findViewById(R.id.transparent_view);
    if (mScroller != null) {
        transparentView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                mScroller.scrollOffBottom();
            }
        });
    }

    // Allow a shadow to be shown under the toolbar.
    ViewUtil.addRectangularOutlineProvider(findViewById(R.id.toolbar_parent), getResources());

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setActionBar(toolbar);
    getActionBar().setTitle(null);
    // Put a TextView with a known resource id into the ActionBar. This allows us to easily
    // find the correct TextView location & size later.
    toolbar.addView(getLayoutInflater().inflate(R.layout.quickcontact_title_placeholder, null));

    mHasAlreadyBeenOpened = savedInstanceState != null;
    mIsEntranceAnimationFinished = mHasAlreadyBeenOpened;
    mWindowScrim = new ColorDrawable(SCRIM_COLOR);
    mWindowScrim.setAlpha(0);
    getWindow().setBackgroundDrawable(mWindowScrim);

    mScroller.initialize(mMultiShrinkScrollerListener, mExtraMode == MODE_FULLY_EXPANDED);
    // mScroller needs to perform asynchronous measurements after initalize(), therefore
    // we can't mark this as GONE.
    mScroller.setVisibility(View.INVISIBLE);

    setHeaderNameText(R.string.missing_name);

    mSelectAccountFragmentListener = (SelectAccountDialogFragmentListener) getFragmentManager()
            .findFragmentByTag(FRAGMENT_TAG_SELECT_ACCOUNT);
    if (mSelectAccountFragmentListener == null) {
        mSelectAccountFragmentListener = new SelectAccountDialogFragmentListener();
        getFragmentManager().beginTransaction()
                .add(0, mSelectAccountFragmentListener, FRAGMENT_TAG_SELECT_ACCOUNT).commit();
        mSelectAccountFragmentListener.setRetainInstance(true);
    }
    mSelectAccountFragmentListener.setQuickContactActivity(this);

    SchedulingUtils.doOnPreDraw(mScroller, /* drawNextFrame = */ true, new Runnable() {
        @Override
        public void run() {
            if (!mHasAlreadyBeenOpened) {
                // The initial scrim opacity must match the scrim opacity that would be
                // achieved by scrolling to the starting position.
                final float alphaRatio = mExtraMode == MODE_FULLY_EXPANDED ? 1
                        : mScroller.getStartingTransparentHeightRatio();
                final int duration = getResources().getInteger(android.R.integer.config_shortAnimTime);
                final int desiredAlpha = (int) (0xFF * alphaRatio);
                ObjectAnimator o = ObjectAnimator.ofInt(mWindowScrim, "alpha", 0, desiredAlpha)
                        .setDuration(duration);

                o.start();
            }
        }
    });

    if (savedInstanceState != null) {
        final int color = savedInstanceState.getInt(KEY_THEME_COLOR, 0);
        SchedulingUtils.doOnPreDraw(mScroller, /* drawNextFrame = */ false, new Runnable() {
            @Override
            public void run() {
                // Need to wait for the pre draw before setting the initial scroll
                // value. Prior to pre draw all scroll values are invalid.
                if (mHasAlreadyBeenOpened) {
                    mScroller.setVisibility(View.VISIBLE);
                    mScroller.setScroll(mScroller.getScrollNeededToBeFullScreen());
                }
                // Need to wait for pre draw for setting the theme color. Setting the
                // header tint before the MultiShrinkScroller has been measured will
                // cause incorrect tinting calculations.
                if (color != 0) {
                    setThemeColor(mMaterialColorMapUtils.calculatePrimaryAndSecondaryColor(color));
                }
            }
        });
    }

    Trace.endSection();
}

From source file:com.android.contacts.quickcontact.QuickContactActivity.java

/**
 * Handle the result from the ContactLoader
 *///from   w w w .  j  ava  2s. com
private void bindContactData(final Contact data) {
    Trace.beginSection("bindContactData");
    mContactData = data;
    invalidateOptionsMenu();

    Trace.endSection();
    Trace.beginSection("Set display photo & name");

    mPhotoView.setIsBusiness(mContactData.isDisplayNameFromOrganization());
    mPhotoSetter.setupContactPhoto(data, mPhotoView);
    extractAndApplyTintFromPhotoViewAsynchronously();
    final String displayName = ContactDisplayUtils.getDisplayName(this, data).toString();
    setHeaderNameText(displayName, mContactData.getDisplayNameSource() == DisplayNameSources.PHONE);
    final String phoneticName = ContactDisplayUtils.getPhoneticName(this, data);
    if (mScroller != null) {
        // Show phonetic name only when it doesn't equal the display name.
        if (!TextUtils.isEmpty(phoneticName) && !phoneticName.equals(displayName)) {
            mScroller.setPhoneticName(phoneticName);
        } else {
            mScroller.setPhoneticNameGone();
        }
    }

    Trace.endSection();

    mEntriesAndActionsTask = new AsyncTask<Void, Void, Cp2DataCardModel>() {

        @Override
        protected Cp2DataCardModel doInBackground(Void... params) {
            return generateDataModelFromContact(data);
        }

        @Override
        protected void onPostExecute(Cp2DataCardModel cardDataModel) {
            super.onPostExecute(cardDataModel);
            // Check that original AsyncTask parameters are still valid and the activity
            // is still running before binding to UI. A new intent could invalidate
            // the results, for example.
            if (data == mContactData && !isCancelled()) {
                bindDataToCards(cardDataModel);
                showActivity();
            }
        }
    };
    mEntriesAndActionsTask.execute();
}