<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          SWT 重啟案例分析(六)

          共 3486字,需瀏覽 7分鐘

           ·

          2020-11-04 00:07

          和你一起終身學(xué)習(xí),這里是程序員Android

          經(jīng)典好文推薦,通過(guò)閱讀本文,您將收獲以下知識(shí)點(diǎn):

          一、Service not registered 異常導(dǎo)致手機(jī)重啟
          二、Service not registered 解決方案

          一、Service not registered 異常導(dǎo)致手機(jī)重啟

          1.重啟 的部分Log如下:

          Service not registered 重啟異常

          二、Service not registered 解決方案

          從 Log 中分析發(fā)現(xiàn)異常信息,并嘗試進(jìn)行如下修改。

          1.修改ContextImpl類(lèi)

          文件路徑如下:
          \frameworks\base\core\java\android\app\ContextImpl.java文件

          優(yōu)化unbindService方法實(shí)現(xiàn)如下:

              @Override
          public void unbindService(ServiceConnection conn) {
          if (conn == null) {
          throw new IllegalArgumentException("connection is null");
          }
          if (mPackageInfo != null) {
          IServiceConnection sd = mPackageInfo.forgetServiceDispatcher(
          getOuterContext(), conn);
          try {
          ActivityManager.getService().unbindService(sd);
          } catch (RemoteException e) {
          throw e.rethrowFromSystemServer();
          // add for Service not registered unbindService() triger reboot exception
          } catch (IllegalArgumentException e) {
          //com.google.android.gms.ui Service not registered Crash
          android.util.Log.e("wjwj","---ContextImpl GMS Crash---");
          e.printStackTrace();
          }
          // add for Service not registered unbindService() triger reboot exception
          } else {
          throw new RuntimeException("Not supported in system context");
          }
          }

          2.修改 TransportManager 類(lèi)

          文件路徑如下:
          frameworks\base\services\backup\java\com\android\server\backup\TransportManager.java 將異常捕獲,防止重啟。

          優(yōu)化unbindService方法實(shí)現(xiàn)如下:

              void onPackageRemoved(String packageName) {
          // Package removed. Remove all its transports from our list. These transports have already
          // been removed from mBoundTransports because onServiceDisconnected would already been
          // called on TransportConnection objects.
          synchronized (mTransportLock) {
          Iterator<Map.Entry<ComponentName, TransportConnection>> iter =
          mValidTransports.entrySet().iterator();
          while (iter.hasNext()) {
          Map.Entry<ComponentName, TransportConnection> validTransport = iter.next();
          ComponentName componentName = validTransport.getKey();
          if (componentName.getPackageName().equals(packageName)) {
          TransportConnection transportConnection = validTransport.getValue();
          iter.remove();
          if (transportConnection != null) {
          /* 360OS begin */
          /* unbindService() triger reboot exception,
          * catch it && add log to find out witch package do it. */

          try {
          Slog.d(TAG, "onPackageRemoved trace, componentName:"
          + componentName.toString(), new Throwable());
          mContext.unbindService(transportConnection);
          } catch (IllegalArgumentException e) {
          Slog.e(TAG, "unbindService fail.", e);
          }
          /* 360OS end */
          log_verbose("Package removed, removing transport: "
          + componentName.flattenToShortString());
          }
          }
          }
          }
          }

          至此,本篇已結(jié)束。轉(zhuǎn)載網(wǎng)絡(luò)的文章,小編覺(jué)得很優(yōu)秀,歡迎點(diǎn)擊閱讀原文,支持原創(chuàng)作者,如有侵權(quán),懇請(qǐng)聯(lián)系小編刪除。同時(shí)感謝您的閱讀,期待您的關(guān)注。

          瀏覽 46
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  亚洲 成人 在线 | 色五月综合 | 成人三级在线视频 | 人人尻人人摸 | 四虎无码影院 |