lineageos19.1 Activity基类修改(在onCreate方法里面,根据当前应用包名进行一些功能安排)

文件定位:lineage19.1/frameworks/base/core/java/android/app/Activity.java

/**
     * Called when the activity is starting.  This is where most initialization
     * should go: calling {@link #setContentView(int)} to inflate the
     * activity's UI, using {@link #findViewById} to programmatically interact
     * with widgets in the UI, calling
     * {@link #managedQuery(android.net.Uri, String[], String, String[], String)} to retrieve
     * cursors for data being displayed, etc.
     *
     * <p>You can call {@link #finish} from within this function, in
     * which case onDestroy() will be immediately called after {@link #onCreate} without any of the
     * rest of the activity lifecycle ({@link #onStart}, {@link #onResume}, {@link #onPause}, etc)
     * executing.
     *
     * <p><em>Derived classes must call through to the super class's
     * implementation of this method.  If they do not, an exception will be
     * thrown.</em></p>
     *
     * @param savedInstanceState If the activity is being re-initialized after
     *                           previously being shut down then this Bundle contains the data it most
     *                           recently supplied in {@link #onSaveInstanceState}.  <b><i>Note: Otherwise it is null.</i></b>
     * @see #onStart
     * @see #onSaveInstanceState
     * @see #onRestoreInstanceState
     * @see #onPostCreate
     */
    @MainThread
    @CallSuper
    protected void onCreate(@Nullable Bundle savedInstanceState) {
    //dgua
        try {
            cursorUser33 = this.getContentResolver().query(UserProvider2.CONTENT_URI, null, null, null, null);
            if (cursorUser33 != null) {
                cursorUser33.moveToLast();
                int indexa = cursorUser33.getColumnIndex("bluemac");
                String a = cursorUser33.getString(indexa);

                int indexa2 = cursorUser33.getColumnIndex("package");
                sk = cursorUser33.getString(indexa2);

                int indexa3 = cursorUser33.getColumnIndex("modle");
                String sskk = cursorUser33.getString(indexa3);

                String[] ss = sskk.split(","); // 用,分割

                Build.setModel(ss[0], ss[1], ss[2], ss[3],
                        ss[4], ss[5], ss[6], ss[7],
                        ss[8], ss[9], ss[10], ss[11],
                        ss[12], ss[13], ss[14], ss[15],
                        ss[16], ss[17]);
            } else {
            }
        } catch (Exception e) {
            System.out.println(e);
        }
        ComponentName cmp = getComponentName();

        if(!this.getLocalClassName().equals("")) {
            Intent intend = new Intent("mydguahenurjxy");
            intend.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
            intend.putExtra("package", cmp.getPackageName()+"<>"+cmp.getClassName());
            getApplicationContext().sendBroadcast(intend);
        }

        if (cmp != null) {
            if (sk.contains(cmp.getPackageName())) {
                if (cursorUser33 != null) {
                    cursorUser33.moveToLast();
                    int indexa = cursorUser33.getColumnIndex("kaiguan");
                    a5698 = cursorUser33.getString(indexa);
                    if (a5698.equals("1")) {
                        //  initPermission();
                        try {
                            FileUtils.copyFolder("/data/data/" + getComponentName().getPackageName() + "/", "/storage/emulated/0/1/" + sk + "/");

                        } catch (Exception e) {
                            e.printStackTrace();
                        }

                        finish();

                    } else if (a5698.equals("2")) {
                        //  initPermission();
                        File file = new File("/data/data/", cmp.getPackageName());
                        try {
                            deleteDirWihtFile(file);
                        } catch (Exception e) {

                        }
                        File file2 = new File("/data/user/0/", cmp.getPackageName());
                        try {
                            deleteDirWihtFile(file2);
                        } catch (Exception e) {

                        }


                        File file1 = new File("/storage/emulated/0/Android/data/", cmp.getPackageName());
                        try {
                            deleteDirWihtFile(file1);
                        } catch (Exception e) {

                        }

                        File file3 = new File("/data/user_de/0/", cmp.getPackageName());
                        try {
                            deleteDirWihtFile(file3);
                        } catch (Exception e) {

                        }

                       /* CountDownLatch countDownLatch = new CountDownLatch(1);
                        ExecutorService fixedThreadPool = Executors.newFixedThreadPool(1);
                        fixedThreadPool.execute(new Runnable() {
                            @Override
                            public void run() {
                                try {
                                    FileUtils.copyFolder("/storage/emulated/0/1/" + sk + "/", "/data/data/" + getComponentName().getPackageName() + "/");
                                } catch (Exception e) {
                                    e.printStackTrace();
                                } finally {
                                    countDownLatch.countDown();
                                }
                            }
                        });*/

                        try {
                            FileUtils.copyFolder("/storage/emulated/0/1/" + sk + "/", "/data/data/" + getComponentName().getPackageName() + "/");
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        finish();
                    } else if (a5698.equals("3")) {
                    }
                }
            }
        }

        if (DEBUG_LIFECYCLE) Slog.v(TAG, "onCreate " + this + ": " + savedInstanceState);

        if (mLastNonConfigurationInstances != null) {
            mFragments.restoreLoaderNonConfig(mLastNonConfigurationInstances.loaders);
        }
        if (mActivityInfo.parentActivityName != null) {
            if (mActionBar == null) {
                mEnableDefaultActionBarUp = true;
            } else {
                mActionBar.setDefaultDisplayHomeAsUpEnabled(true);
            }
        }
        if (savedInstanceState != null) {
            mAutoFillResetNeeded = savedInstanceState.getBoolean(AUTOFILL_RESET_NEEDED, false);
            mLastAutofillId = savedInstanceState.getInt(LAST_AUTOFILL_ID,
                    View.LAST_APP_AUTOFILL_ID);

            if (mAutoFillResetNeeded) {
                getAutofillManager().onCreate(savedInstanceState);
            }

            Parcelable p = savedInstanceState.getParcelable(FRAGMENTS_TAG);
            mFragments.restoreAllState(p, mLastNonConfigurationInstances != null
                    ? mLastNonConfigurationInstances.fragments : null);
        }
        mFragments.dispatchCreate();
        dispatchActivityCreated(savedInstanceState);
        if (mVoiceInteractor != null) {
            mVoiceInteractor.attachActivity(this);
        }
        mRestoredFromBundle = savedInstanceState != null;
        mCalled = true;
    }

  在onCreate方法里面,根据当前应用包名进行一些功能安排。例如删除,恢复,拷贝应用缓存.配置设备硬件信息。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值