private void setEnabledFunctions(String functions, boolean makeDefault) {

      // Do not update persystent.sys.usb.config if the device is booted up
      // with OEM specific mode.
      if (functions != null && makeDefault && !needsOemUsbOverride()) {

        if (mAdbEnabled) {
          functions = addFunction(functions, UsbManager.USB_FUNCTION_ADB);
        } else {
          functions = removeFunction(functions, UsbManager.USB_FUNCTION_ADB);
        }
        if (!mDefaultFunctions.equals(functions)) {
          if (!setUsbConfig("none")) {
            Slog.e(TAG, "Failed to disable USB");
            // revert to previous configuration if we fail
            setUsbConfig(mCurrentFunctions);
            return;
          }
          // setting this property will also change the current USB state
          // via a property trigger
          SystemProperties.set("persist.sys.usb.config", functions);
          if (waitForState(functions)) {
            mCurrentFunctions = functions;
            mDefaultFunctions = functions;
          } else {
            Slog.e(TAG, "Failed to switch persistent USB config to " + functions);
            // revert to previous configuration if we fail
            SystemProperties.set("persist.sys.usb.config", mDefaultFunctions);
          }
        }
      } else {
        if (functions == null) {
          functions = mDefaultFunctions;
        }

        // Override with bootmode specific usb mode if needed
        functions = processOemUsbOverride(functions);

        if (mAdbEnabled) {
          functions = addFunction(functions, UsbManager.USB_FUNCTION_ADB);
        } else {
          functions = removeFunction(functions, UsbManager.USB_FUNCTION_ADB);
        }
        if (!mCurrentFunctions.equals(functions)) {
          if (!setUsbConfig("none")) {
            Slog.e(TAG, "Failed to disable USB");
            // revert to previous configuration if we fail
            setUsbConfig(mCurrentFunctions);
            return;
          }
          if (setUsbConfig(functions)) {
            mCurrentFunctions = functions;
          } else {
            Slog.e(TAG, "Failed to switch USB config to " + functions);
            // revert to previous configuration if we fail
            setUsbConfig(mCurrentFunctions);
          }
        }
      }
    }
  /* Sets the default subscription. If only one phone instance is active that
   * subscription is set as default subscription. If both phone instances
   * are active the first instance "0" is set as default subscription
   */
  public static void setDefaultSubscription(int subId) {
    SystemProperties.set(PROPERTY_DEFAULT_SUBSCRIPTION, Integer.toString(subId));
    int phoneId = SubscriptionController.getInstance().getPhoneId(subId);

    synchronized (sLockProxyPhones) {
      // Set the default phone in base class
      if (phoneId >= 0 && phoneId < sProxyPhones.length) {
        sProxyPhone = sProxyPhones[phoneId];
        sCommandsInterface = sCommandsInterfaces[phoneId];
        sMadeDefaults = true;
      }
    }

    // Update MCC MNC device configuration information
    String defaultMccMnc = TelephonyManager.getDefault().getSimOperatorNumericForPhone(phoneId);
    if (DBG) Rlog.d(LOG_TAG, "update mccmnc=" + defaultMccMnc);
    MccTable.updateMccMncConfiguration(sContext, defaultMccMnc, false);

    // Broadcast an Intent for default sub change
    Intent intent = new Intent(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED);
    intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
    SubscriptionManager.putPhoneIdAndSubIdExtra(intent, phoneId);
    Rlog.d(
        LOG_TAG,
        "setDefaultSubscription : " + subId + " Broadcasting Default Subscription Changed...");
    sContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
  }
 @Override
 public boolean onPreferenceChange(Preference preference, Object newValue) {
   if (HDCP_CHECKING_KEY.equals(preference.getKey())) {
     SystemProperties.set(HDCP_CHECKING_PROPERTY, newValue.toString());
     updateHdcpValues();
     pokeSystemProperties();
     return true;
   } else if (preference == mWindowAnimationScale) {
     writeAnimationScaleOption(0, mWindowAnimationScale, newValue);
     return true;
   } else if (preference == mTransitionAnimationScale) {
     writeAnimationScaleOption(1, mTransitionAnimationScale, newValue);
     return true;
   } else if (preference == mAnimatorDurationScale) {
     writeAnimationScaleOption(2, mAnimatorDurationScale, newValue);
     return true;
   } else if (preference == mOverlayDisplayDevices) {
     writeOverlayDisplayDevicesOptions(newValue);
     return true;
   } else if (preference == mOpenGLTraces) {
     writeOpenGLTracesOptions(newValue);
     return true;
   } else if (preference == mEnableTracesPref) {
     writeEnableTracesOptions();
     return true;
   } else if (preference == mAppProcessLimit) {
     writeAppProcessLimitOptions(newValue);
     return true;
   }
   return false;
 }
 private boolean setUsbConfig(String config) {
   if (DEBUG) Slog.d(TAG, "setUsbConfig(" + config + ")");
   // set the new configuration
   // we always set it due to b/23631400, where adbd was getting killed
   // and not restarted due to property timeouts on some devices
   SystemProperties.set(USB_CONFIG_PROPERTY, config);
   return waitForState(config);
 }
 @SmallTest
 public void testStressMemoryPropertyConsistency() throws Exception {
   for (int i = 0; i < 100; ++i) {
     SystemProperties.set(KEY, Long.toString(i));
     long ret = SystemProperties.getLong(KEY, -1);
     assertEquals(i, ret);
   }
 }
 @Override
 public void setText(String text) {
   if (text == null) {
     return;
   }
   SystemProperties.set(PROP_HOSTNAME, text);
   persistHostname(text);
   setSummary(text);
 }
 public void onClick(DialogInterface dialog, int which) {
   if (which == DialogInterface.BUTTON_POSITIVE) {
     mOkClicked = true;
     Settings.Secure.putInt(getContentResolver(), Settings.Secure.ADB_ENABLED, 1);
     SystemProperties.set("persist.service.adb.enable", "1");
   } else {
     // Reset the toggle
     mEnableAdb.setChecked(false);
   }
 }
  /**
   * Command-line entry point.
   *
   * @param args The command-line arguments
   */
  public static void main(String[] args) {
    // Set ro.monkey if it's not set yet.
    SystemProperties.set("ro.monkey", "true");

    // Set the process name showing in "ps" or "top"
    Process.setArgV0("com.android.commands.monkey");

    int resultCode = (new Monkey()).run(args);
    System.exit(resultCode);
  }
Exemplo n.º 9
0
  boolean translateAndSendNativeEvents(KeyEvent event) {
    if (mNativeImeAdapterAndroid == 0) return false;

    int action = event.getAction();
    if (action != KeyEvent.ACTION_DOWN && action != KeyEvent.ACTION_UP) {
      // action == KeyEvent.ACTION_MULTIPLE
      // TODO(bulach): confirm the actual behavior. Apparently:
      // If event.getKeyCode() == KEYCODE_UNKNOWN, we can send a
      // composition key down (229) followed by a commit text with the
      // string from event.getUnicodeChars().
      // Otherwise, we'd need to send an event with a
      // WebInputEvent::IsAutoRepeat modifier. We also need to verify when
      // we receive ACTION_MULTIPLE: we may receive it after an ACTION_DOWN,
      // and if that's the case, we'll need to review when to send the Char
      // event.
      return false;
    }

    // Begin add by TCL zhanghangzhi, mail: [email protected]
    if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_CENTER
        && (event.getFlags() & KeyEvent.FLAG_FROM_SYSTEM) != 0) {
      android.os.SystemProperties.set(
          "webviewchromium.tv_enterKeyFlag", String.valueOf(event.getFlags()));
      android.util.Log.e("ImeAdapter", "[ESTALENT] sys.tv_enterKeyFlag: " + event.getFlags());
    } else {
      android.os.SystemProperties.set("webviewchromium.tv_enterKeyFlag", "");
      android.util.Log.e("ImeAdapter", "[ESTALENT] clean sys.tv_enterKeyFlag");
    }
    // End of TCL

    mViewEmbedder.onImeEvent(false);
    return nativeSendKeyEvent(
        mNativeImeAdapterAndroid,
        event,
        event.getAction(),
        getModifiers(event.getMetaState()),
        event.getEventTime(),
        event.getKeyCode(),
        event.isSystem(),
        event.getUnicodeChar());
  }
  @SmallTest
  public void testProperties() throws Exception {
    String value;

    SystemProperties.set(KEY, "");
    value = SystemProperties.get(KEY, "default");
    assertEquals("default", value);

    SystemProperties.set(KEY, "SA");
    value = SystemProperties.get(KEY, "default");
    assertEquals("SA", value);

    value = SystemProperties.get(KEY);
    assertEquals("SA", value);

    SystemProperties.set(KEY, "");
    value = SystemProperties.get(KEY, "default");
    assertEquals("default", value);

    value = SystemProperties.get(KEY);
    assertEquals("", value);
  }
Exemplo n.º 11
0
  @DSGenerator(
      tool_name = "Doppelganger",
      tool_version = "2.0",
      generated_on = "2013-12-30 12:58:54.921 -0500",
      hash_original_method = "E50365918A8B4813331E3A24E11292EF",
      hash_generated_method = "3CBE59FC5B8ED7B8F451502F6184DC1C")
  @Override
  protected void onAllRecordsLoaded() {
    Log.d(LOG_TAG, "RuimRecords: record load complete");

    // Further records that can be inserted are Operator/OEM dependent

    String operator = getRUIMOperatorNumeric();
    SystemProperties.set(PROPERTY_ICC_OPERATOR_NUMERIC, operator);

    if (mImsi != null) {
      SystemProperties.set(
          PROPERTY_ICC_OPERATOR_ISO_COUNTRY,
          MccTable.countryCodeForMcc(Integer.parseInt(mImsi.substring(0, 3))));
    }
    recordsLoadedRegistrants.notifyRegistrants(new AsyncResult(null, null, null));
    phone.mIccCard.broadcastIccStateChangedIntent(RuimCard.INTENT_VALUE_ICC_LOADED, null);
  }
Exemplo n.º 12
0
  private void attachOrDetachGprs() {
    if ((mOperatorOption & DOCOMO_OPTION) != 0 || (mOperatorOption & SOFTBANK_OPTION) != 0) {
      Elog.v(TAG, "Attach GPRS for DoCoMo/Softband");
      SystemProperties.set("persist.radio.gprs.attach.type", "1");

      String cmdStr[] = {"AT+EGTYPE=1,1", ""};
      mPhone.invokeOemRilRequestStrings(cmdStr, null);

      SharedPreferences preference = getSharedPreferences(PREFERENCE_GPRS, 0);
      SharedPreferences.Editor editor = preference.edit();
      editor.putInt(PREF_ATTACH_MODE, ATTACH_MODE_ALWAYS);
    } else {
      Elog.v(TAG, "Dettach GPRS for DoCoMo/Softband");
      SystemProperties.set("persist.radio.gprs.attach.type", "0");

      String cmdStr[] = {"AT+EGTYPE=0,1", ""};
      mPhone.invokeOemRilRequestStrings(cmdStr, null);

      SharedPreferences preference = getSharedPreferences(PREFERENCE_GPRS, 0);
      SharedPreferences.Editor editor = preference.edit();
      editor.putInt(PREF_ATTACH_MODE, ATTACH_MODE_NOT_SPECIFY);
    }
  }
  private void enable() {
    mTvOut._SetTvSystem(mSystem);
    mTvOut._TvOutSetImageString(
        "TV-out not supported while application running. Phone display only");

    Display display =
        ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    mTvOut._SetOrientation(display.getRotation());

    mTvOut._EnableTvOut();
    mTvOut._setTvoutCableConnected(1);

    // Start tvouthack service used to bombard screen refresh messages
    SystemProperties.set("ctl.start", "tvouthack");
  }
 private void applyUpdate() throws IOException, ErrnoException {
   Slog.i(TAG, "Applying SELinux policy");
   File contexts = new File(updateDir.getParentFile(), "contexts");
   File current = new File(updateDir.getParentFile(), "current");
   File update = new File(updateDir.getParentFile(), "update");
   File tmp = new File(updateDir.getParentFile(), "tmp");
   if (current.exists()) {
     Libcore.os.symlink(updateDir.getPath(), update.getPath());
     Libcore.os.rename(update.getPath(), current.getPath());
   } else {
     Libcore.os.symlink(updateDir.getPath(), current.getPath());
   }
   contexts.mkdirs();
   backupContexts(contexts);
   copyUpdate(contexts);
   Libcore.os.symlink(contexts.getPath(), tmp.getPath());
   Libcore.os.rename(tmp.getPath(), current.getPath());
   SystemProperties.set("selinux.reload_policy", "1");
 }
  @Override
  public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {

    if (Utils.isMonkeyRunning()) {
      return false;
    }

    if (preference == mEnableAdb) {
      if (mEnableAdb.isChecked()) {
        mOkClicked = false;
        if (mOkDialog != null) dismissDialog();
        mOkDialog =
            new AlertDialog.Builder(this)
                .setMessage(getResources().getString(R.string.adb_warning_message))
                .setTitle(R.string.adb_warning_title)
                .setIcon(android.R.drawable.ic_dialog_alert)
                .setPositiveButton(android.R.string.yes, this)
                .setNegativeButton(android.R.string.no, this)
                .show();
        mOkDialog.setOnDismissListener(this);
      } else {
        Settings.Secure.putInt(getContentResolver(), Settings.Secure.ADB_ENABLED, 0);
        SystemProperties.set("persist.service.adb.enable", "0");
      }
    } else if (preference == mAdbNotify) {
      Settings.Secure.putInt(
          getContentResolver(), Settings.Secure.ADB_NOTIFY, mAdbNotify.isChecked() ? 1 : 0);
    } else if (preference == mKeepScreenOn) {
      Settings.System.putInt(
          getContentResolver(),
          Settings.System.STAY_ON_WHILE_PLUGGED_IN,
          mKeepScreenOn.isChecked()
              ? (BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB)
              : 0);
    } else if (preference == mAllowMockLocation) {
      Settings.Secure.putInt(
          getContentResolver(),
          Settings.Secure.ALLOW_MOCK_LOCATION,
          mAllowMockLocation.isChecked() ? 1 : 0);
    }

    return false;
  }
  /* method to handle mods */
  private boolean doMod(String persist, String key, String value) {

    if (persist != null) {
      SystemProperties.set(persist, value);
    }
    Log.d(TAG, String.format("Calling script with args '%s' and '%s'", key, value));
    backupBuildProp();
    if (!mount("rw")) {
      throw new RuntimeException("Could not remount /system rw");
    }
    boolean success = true;
    try {
      if (!propExists(key) && value.equals(DISABLE)) {
        Log.d(
            TAG,
            String.format(
                "We want {%s} DISABLED however it doesn't exist so we do nothing and move on",
                key));
      } else if (propExists(key)) {
        if (value.equals(DISABLE)) {
          Log.d(TAG, String.format("value == %s", DISABLE));
          success = cmd.su.runWaitFor(String.format(KILL_PROP_CMD, key)).success();
        } else {
          Log.d(TAG, String.format("value != %s", DISABLE));
          success = cmd.su.runWaitFor(String.format(REPLACE_CMD, key, key, value)).success();
        }
      } else {
        Log.d(TAG, "append command starting");
        success = cmd.su.runWaitFor(String.format(APPEND_CMD, key, value)).success();
      }
      if (success) {
        restoreBuildProp();
      } else {
        updateScreen();
      }
    } finally {
      mount("ro");
    }

    return success;
  }
    private void setAdbEnabled(boolean enable) {
      if (DEBUG) Slog.d(TAG, "setAdbEnabled: " + enable);
      if (enable != mAdbEnabled) {
        mAdbEnabled = enable;

        // Due to the persist.sys.usb.config property trigger, changing adb state requires
        // persisting default function
        String oldFunctions = getDefaultFunctions();
        String newFunctions = applyAdbFunction(oldFunctions);
        if (!oldFunctions.equals(newFunctions)) {
          SystemProperties.set(USB_PERSISTENT_CONFIG_PROPERTY, newFunctions);
        }

        // After persisting them use the lock-down aware function set
        setEnabledFunctions(mCurrentFunctions, false);
        updateAdbNotification();
      }

      if (mDebuggingManager != null) {
        mDebuggingManager.setAdbEnabled(mAdbEnabled);
      }
    }
    public UsbHandler(Looper looper) {
      super(looper);
      try {
        // persist.sys.usb.config should never be unset.  But if it is, set it to "adb"
        // so we have a chance of debugging what happened.
        mDefaultFunctions = SystemProperties.get("persist.sys.usb.config", "adb");

        // Check if USB mode needs to be overridden depending on OEM specific bootmode.
        mDefaultFunctions = processOemUsbOverride(mDefaultFunctions);

        // sanity check the sys.usb.config system property
        // this may be necessary if we crashed while switching USB configurations
        String config = SystemProperties.get("sys.usb.config", "none");
        if (!config.equals(mDefaultFunctions)) {
          Slog.w(TAG, "resetting config to persistent property: " + mDefaultFunctions);
          SystemProperties.set("sys.usb.config", mDefaultFunctions);
        }

        mCurrentFunctions = mDefaultFunctions;
        String state = FileUtils.readTextFile(new File(STATE_PATH), 0, null).trim();
        updateState(state);
        mAdbEnabled = containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_ADB);

        // Upgrade step for previous versions that used persist.service.adb.enable
        String value = SystemProperties.get("persist.service.adb.enable", "");
        if (value.length() > 0) {
          char enable = value.charAt(0);
          if (enable == '1') {
            setAdbEnabled(true);
          } else if (enable == '0') {
            setAdbEnabled(false);
          }
          SystemProperties.set("persist.service.adb.enable", "");
        }

        // register observer to listen for settings changes
        mContentResolver.registerContentObserver(
            Settings.Global.getUriFor(Settings.Global.ADB_ENABLED),
            false,
            new AdbSettingsObserver());
        mContentResolver.registerContentObserver(
            Settings.Secure.getUriFor(Settings.Secure.ADB_NOTIFY),
            false,
            new ContentObserver(null) {
              public void onChange(boolean selfChange) {
                updateAdbNotification();
              }
            });

        // Watch for USB configuration changes
        mUEventObserver.startObserving(USB_STATE_MATCH);
        mUEventObserver.startObserving(ACCESSORY_START_MATCH);

        mContext.registerReceiver(
            mBootCompletedReceiver, new IntentFilter(Intent.ACTION_BOOT_COMPLETED));
        mContext.registerReceiver(
            mUserSwitchedReceiver, new IntentFilter(Intent.ACTION_USER_SWITCHED));
      } catch (Exception e) {
        Slog.e(TAG, "Error initializing UsbHandler", e);
      }
    }
Exemplo n.º 19
0
 private void writeHardwareUiOptions() {
   SystemProperties.set(HARDWARE_UI_PROPERTY, mForceHardwareUi.isChecked() ? "true" : "false");
 }
Exemplo n.º 20
0
 private void setUsbMode(String value) {
   Xlog.v(TAG, "setUsbMode(), value: " + value);
   SystemProperties.set(KEY_USB_PORT, value);
 }
  private void logBootEvents(Context ctx) throws IOException {
    final DropBoxManager db = (DropBoxManager) ctx.getSystemService(Context.DROPBOX_SERVICE);
    final SharedPreferences prefs = ctx.getSharedPreferences("log_files", Context.MODE_PRIVATE);
    final String headers =
        new StringBuilder(512)
            .append("Build: ")
            .append(Build.FINGERPRINT)
            .append("\n")
            .append("Hardware: ")
            .append(Build.BOARD)
            .append("\n")
            .append("Bootloader: ")
            .append(Build.BOOTLOADER)
            .append("\n")
            .append("Radio: ")
            .append(Build.RADIO)
            .append("\n")
            .append("Kernel: ")
            .append(FileUtils.readTextFile(new File("/proc/version"), 1024, "...\n"))
            .append("\n")
            .toString();

    String recovery = RecoverySystem.handleAftermath();
    if (recovery != null && db != null) {
      db.addText("SYSTEM_RECOVERY_LOG", headers + recovery);
    }

    if (SystemProperties.getLong("ro.runtime.firstboot", 0) == 0) {
      String now = Long.toString(System.currentTimeMillis());
      SystemProperties.set("ro.runtime.firstboot", now);
      if (db != null) db.addText("SYSTEM_BOOT", headers);

      // Negative sizes mean to take the *tail* of the file (see FileUtils.readTextFile())
      addFileToDropBox(db, prefs, headers, "/proc/last_kmsg", -LOG_SIZE, "SYSTEM_LAST_KMSG");
      addFileToDropBox(db, prefs, headers, "/cache/recovery/log", -LOG_SIZE, "SYSTEM_RECOVERY_LOG");
      addFileToDropBox(
          db, prefs, headers, "/data/dontpanic/apanic_console", -LOG_SIZE, "APANIC_CONSOLE");
      addFileToDropBox(
          db, prefs, headers, "/data/dontpanic/apanic_threads", -LOG_SIZE, "APANIC_THREADS");
    } else {
      if (db != null) db.addText("SYSTEM_RESTART", headers);
    }

    // Scan existing tombstones (in case any new ones appeared)
    File[] tombstoneFiles = TOMBSTONE_DIR.listFiles();
    for (int i = 0; tombstoneFiles != null && i < tombstoneFiles.length; i++) {
      addFileToDropBox(
          db, prefs, headers, tombstoneFiles[i].getPath(), LOG_SIZE, "SYSTEM_TOMBSTONE");
    }

    // Start watching for new tombstone files; will record them as they occur.
    // This gets registered with the singleton file observer thread.
    sTombstoneObserver =
        new FileObserver(TOMBSTONE_DIR.getPath(), FileObserver.CLOSE_WRITE) {
          @Override
          public void onEvent(int event, String path) {
            try {
              String filename = new File(TOMBSTONE_DIR, path).getPath();
              addFileToDropBox(db, prefs, headers, filename, LOG_SIZE, "SYSTEM_TOMBSTONE");
            } catch (IOException e) {
              Slog.e(TAG, "Can't log tombstone", e);
            }
          }
        };

    sTombstoneObserver.startWatching();
  }
 @Override
 @ServiceThreadOnly
 protected void setPreferredAddress(int addr) {
   assertRunOnServiceThread();
   SystemProperties.set(Constants.PROPERTY_PREFERRED_ADDRESS_PLAYBACK, String.valueOf(addr));
 }
Exemplo n.º 23
0
  /**
   * Makes sure we handle the shutdown gracefully. Shuts off power regardless of radio and bluetooth
   * state if the alloted time has passed.
   */
  public void run() {
    BroadcastReceiver br =
        new BroadcastReceiver() {
          @Override
          public void onReceive(Context context, Intent intent) {
            // We don't allow apps to cancel this, so ignore the result.
            actionDone();
          }
        };

    /*
     * Write a system property in case the system_server reboots before we
     * get to the actual hardware restart. If that happens, we'll retry at
     * the beginning of the SystemServer startup.
     */
    {
      String reason = (mReboot ? "1" : "0") + (mRebootReason != null ? mRebootReason : "");
      SystemProperties.set(SHUTDOWN_ACTION_PROPERTY, reason);
    }

    /*
     * If we are rebooting into safe mode, write a system property
     * indicating so.
     */
    if (mRebootSafeMode) {
      SystemProperties.set(REBOOT_SAFEMODE_PROPERTY, "1");
    }

    Log.i(TAG, "Sending shutdown broadcast...");

    // First send the high-level shut down broadcast.
    mActionDone = false;
    mContext.sendOrderedBroadcastAsUser(
        new Intent(Intent.ACTION_SHUTDOWN), UserHandle.ALL, null, br, mHandler, 0, null, null);

    final long endTime = SystemClock.elapsedRealtime() + MAX_BROADCAST_TIME;
    synchronized (mActionDoneSync) {
      while (!mActionDone) {
        long delay = endTime - SystemClock.elapsedRealtime();
        if (delay <= 0) {
          Log.w(TAG, "Shutdown broadcast timed out");
          break;
        }
        try {
          mActionDoneSync.wait(delay);
        } catch (InterruptedException e) {
        }
      }
    }

    Log.i(TAG, "Shutting down activity manager...");

    final IActivityManager am =
        ActivityManagerNative.asInterface(ServiceManager.checkService("activity"));
    if (am != null) {
      try {
        am.shutdown(MAX_BROADCAST_TIME);
      } catch (RemoteException e) {
      }
    }

    // Shutdown radios.
    shutdownRadios(MAX_RADIO_WAIT_TIME);

    // Shutdown MountService to ensure media is in a safe state
    IMountShutdownObserver observer =
        new IMountShutdownObserver.Stub() {
          public void onShutDownComplete(int statusCode) throws RemoteException {
            Log.w(TAG, "Result code " + statusCode + " from MountService.shutdown");
            actionDone();
          }
        };

    Log.i(TAG, "Shutting down MountService");

    // Set initial variables and time out time.
    mActionDone = false;
    final long endShutTime = SystemClock.elapsedRealtime() + MAX_SHUTDOWN_WAIT_TIME;
    synchronized (mActionDoneSync) {
      try {
        final IMountService mount =
            IMountService.Stub.asInterface(ServiceManager.checkService("mount"));
        if (mount != null) {
          mount.shutdown(observer);
        } else {
          Log.w(TAG, "MountService unavailable for shutdown");
        }
      } catch (Exception e) {
        Log.e(TAG, "Exception during MountService shutdown", e);
      }
      while (!mActionDone) {
        long delay = endShutTime - SystemClock.elapsedRealtime();
        if (delay <= 0) {
          Log.w(TAG, "Shutdown wait timed out");
          break;
        }
        try {
          mActionDoneSync.wait(delay);
        } catch (InterruptedException e) {
        }
      }
    }

    rebootOrShutdown(mReboot, mRebootReason);
  }
 /** Request that the init daemon restart a named service. */
 public static void restart(String name) {
   SystemProperties.set("ctl.restart", name);
 }
 /** Request that the init daemon stop a named service. */
 public static void stop(String name) {
   SystemProperties.set("ctl.stop", name);
 }
Exemplo n.º 26
0
  public GSMPhone(
      Context context, CommandsInterface ci, PhoneNotifier notifier, boolean unitTestMode) {
    super(notifier, context, ci, unitTestMode);

    if (ci instanceof SimulatedRadioControl) {
      mSimulatedRadioControl = (SimulatedRadioControl) ci;
    }

    mCM.setPhoneType(Phone.PHONE_TYPE_GSM);
    mCT = new GsmCallTracker(this);
    mSST = new GsmServiceStateTracker(this);
    mSMS = new GsmSMSDispatcher(this);
    mIccFileHandler = new SIMFileHandler(this);
    mSIMRecords = new SIMRecords(this);
    mDataConnection = new GsmDataConnectionTracker(this);
    mSimCard = new SimCard(this);
    if (!unitTestMode) {
      mSimPhoneBookIntManager = new SimPhoneBookInterfaceManager(this);
      mSimSmsIntManager = new SimSmsInterfaceManager(this, mSMS);
      mSubInfo = new PhoneSubInfo(this);
    }
    mStkService =
        CatService.getInstance(
            mCM, mSIMRecords, mContext, (SIMFileHandler) mIccFileHandler, mSimCard);

    mCM.registerForAvailable(this, EVENT_RADIO_AVAILABLE, null);
    mSIMRecords.registerForRecordsLoaded(this, EVENT_SIM_RECORDS_LOADED, null);
    mCM.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);
    mCM.registerForOn(this, EVENT_RADIO_ON, null);
    mCM.setOnUSSD(this, EVENT_USSD, null);
    mCM.setOnSuppServiceNotification(this, EVENT_SSN, null);
    mSST.registerForNetworkAttach(this, EVENT_REGISTERED_TO_NETWORK, null);

    if (false) {
      try {
        // debugSocket = new LocalServerSocket("com.android.internal.telephony.debug");
        debugSocket = new ServerSocket();
        debugSocket.setReuseAddress(true);
        debugSocket.bind(new InetSocketAddress("127.0.0.1", 6666));

        debugPortThread =
            new Thread(
                new Runnable() {
                  public void run() {
                    for (; ; ) {
                      try {
                        Socket sock;
                        sock = debugSocket.accept();
                        Log.i(LOG_TAG, "New connection; resetting radio");
                        mCM.resetRadio(null);
                        sock.close();
                      } catch (IOException ex) {
                        Log.w(LOG_TAG, "Exception accepting socket", ex);
                      }
                    }
                  }
                },
                "GSMPhone debug");

        debugPortThread.start();

      } catch (IOException ex) {
        Log.w(LOG_TAG, "Failure to open com.android.internal.telephony.debug socket", ex);
      }
    }

    // Change the system property
    SystemProperties.set(
        TelephonyProperties.CURRENT_ACTIVE_PHONE, new Integer(Phone.PHONE_TYPE_GSM).toString());
  }
 private void writeEnableTracesOptions(long value) {
   SystemProperties.set(Trace.PROPERTY_TRACE_TAG_ENABLEFLAGS, "0x" + Long.toString(value, 16));
   pokeSystemProperties();
 }
  private void disable() {
    SystemProperties.set("ctl.stop", "tvouthack");

    mTvOut._DisableTvOut();
    mTvOut._setTvoutCableConnected(0);
  }
 private static boolean writeFile(File dir, String filename, String contents) {
   SystemProperties.set(propertyFromFilename(filename), contents);
   return waitForState(USB_TYPEC_STATE, contents);
 }
 private boolean setUsbConfig(String config) {
   if (DEBUG) Slog.d(TAG, "setUsbConfig(" + config + ")");
   // set the new configuration
   SystemProperties.set("sys.usb.config", config);
   return waitForState(config);
 }