Search in sources :

Example 76 with IMountService

use of android.os.storage.IMountService in project android_frameworks_base by AOSPA.

the class LockPatternUtils method setVisiblePatternEnabled.

/**
     * Set whether the visible pattern is enabled.
     */
public void setVisiblePatternEnabled(boolean enabled, int userId) {
    setBoolean(Settings.Secure.LOCK_PATTERN_VISIBLE, enabled, userId);
    // Update for crypto if owner
    if (userId != UserHandle.USER_SYSTEM) {
        return;
    }
    IBinder service = ServiceManager.getService("mount");
    if (service == null) {
        Log.e(TAG, "Could not find the mount service to update the user info");
        return;
    }
    IMountService mountService = IMountService.Stub.asInterface(service);
    try {
        mountService.setField(StorageManager.PATTERN_VISIBLE_KEY, enabled ? "1" : "0");
    } catch (RemoteException e) {
        Log.e(TAG, "Error changing pattern visible state", e);
    }
}
Also used : IBinder(android.os.IBinder) IMountService(android.os.storage.IMountService) RemoteException(android.os.RemoteException)

Example 77 with IMountService

use of android.os.storage.IMountService in project android_frameworks_base by ResurrectionRemix.

the class PackageHelperTests method cleanupContainers.

private void cleanupContainers() throws RemoteException {
    Log.d(TAG, "cleanUp");
    IMountService ms = getMs();
    String[] containers = ms.getSecureContainerList();
    for (int i = 0; i < containers.length; i++) {
        if (containers[i].startsWith(PREFIX)) {
            Log.d(TAG, "cleaing up " + containers[i]);
            ms.destroySecureContainer(containers[i], true);
        }
    }
}
Also used : IMountService(android.os.storage.IMountService)

Example 78 with IMountService

use of android.os.storage.IMountService in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DevelopmentSettings method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    mWindowManager = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
    mBackupManager = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE));
    mWebViewUpdateService = IWebViewUpdateService.Stub.asInterface(ServiceManager.getService("webviewupdate"));
    mOemUnlockManager = (PersistentDataBlockManager) getActivity().getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
    mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    mDpm = (DevicePolicyManager) getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
    mUm = (UserManager) getSystemService(Context.USER_SERVICE);
    mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    setIfOnlyAvailableForAdmins(true);
    if (isUiRestricted() || !Utils.isDeviceProvisioned(getActivity())) {
        // Block access to developer options if the user is not the owner, if user policy
        // restricts it, or if the device has not been provisioned
        mUnavailable = true;
        setPreferenceScreen(new PreferenceScreen(getPrefContext(), null));
        return;
    }
    addPreferencesFromResource(R.xml.development_prefs);
    final PreferenceGroup debugDebuggingCategory = (PreferenceGroup) findPreference(DEBUG_DEBUGGING_CATEGORY_KEY);
    mEnableAdb = findAndInitSwitchPref(ENABLE_ADB);
    mAdbAlwaysNotify = findAndInitSwitchPref(ADB_ALWAYS_NOTIFY);
    mAdbOverNetwork = findAndInitSwitchPref(ADB_TCPIP);
    mClearAdbKeys = findPreference(CLEAR_ADB_KEYS);
    if (!SystemProperties.getBoolean("ro.adb.secure", false)) {
        if (debugDebuggingCategory != null) {
            debugDebuggingCategory.removePreference(mClearAdbKeys);
        }
    }
    mAllPrefs.add(mClearAdbKeys);
    mEnableTerminal = findAndInitSwitchPref(ENABLE_TERMINAL);
    if (!isPackageInstalled(getActivity(), TERMINAL_APP_PACKAGE)) {
        debugDebuggingCategory.removePreference(mEnableTerminal);
        mEnableTerminal = null;
    }
    mBugreport = findPreference(BUGREPORT);
    mBugreportInPower = findAndInitSwitchPref(BUGREPORT_IN_POWER_KEY);
    mKeepScreenOn = (RestrictedSwitchPreference) findAndInitSwitchPref(KEEP_SCREEN_ON);
    mBtHciSnoopLog = findAndInitSwitchPref(BT_HCI_SNOOP_LOG);
    mEnableOemUnlock = (RestrictedSwitchPreference) findAndInitSwitchPref(ENABLE_OEM_UNLOCK);
    if (!showEnableOemUnlockPreference()) {
        removePreference(mEnableOemUnlock);
        mEnableOemUnlock = null;
    }
    mDebugViewAttributes = findAndInitSwitchPref(DEBUG_VIEW_ATTRIBUTES);
    mForceAllowOnExternal = findAndInitSwitchPref(FORCE_ALLOW_ON_EXTERNAL_KEY);
    mPassword = (PreferenceScreen) findPreference(LOCAL_BACKUP_PASSWORD);
    mAllPrefs.add(mPassword);
    mForceAuthorizeSubstratumPackages = findAndInitSwitchPref(FORCE_AUTHORIZE_SUBSTRATUM_PACKAGES);
    if (!mUm.isAdminUser()) {
        disableForUser(mEnableAdb);
        disableForUser(mClearAdbKeys);
        disableForUser(mEnableTerminal);
        disableForUser(mPassword);
        disableForUser(mForceAuthorizeSubstratumPackages);
    }
    mDebugAppPref = findPreference(DEBUG_APP_KEY);
    mAllPrefs.add(mDebugAppPref);
    mWaitForDebugger = findAndInitSwitchPref(WAIT_FOR_DEBUGGER_KEY);
    mMockLocationAppPref = findPreference(MOCK_LOCATION_APP_KEY);
    mAllPrefs.add(mMockLocationAppPref);
    mVerifyAppsOverUsb = findAndInitSwitchPref(VERIFY_APPS_OVER_USB_KEY);
    if (!showVerifierSetting()) {
        if (debugDebuggingCategory != null) {
            debugDebuggingCategory.removePreference(mVerifyAppsOverUsb);
        } else {
            mVerifyAppsOverUsb.setEnabled(false);
        }
    }
    mStrictMode = findAndInitSwitchPref(STRICT_MODE_KEY);
    mPointerLocation = findAndInitSwitchPref(POINTER_LOCATION_KEY);
    mShowTouches = findAndInitSwitchPref(SHOW_TOUCHES_KEY);
    mShowScreenUpdates = findAndInitSwitchPref(SHOW_SCREEN_UPDATES_KEY);
    mDisableOverlays = findAndInitSwitchPref(DISABLE_OVERLAYS_KEY);
    mShowCpuInfo = findAndInitSwitchPref(SHOW_CPU_INFO_KEY);
    mForceHardwareUi = findAndInitSwitchPref(FORCE_HARDWARE_UI_KEY);
    mForceMsaa = findAndInitSwitchPref(FORCE_MSAA_KEY);
    mTrackFrameTime = addListPreference(TRACK_FRAME_TIME_KEY);
    mShowNonRectClip = addListPreference(SHOW_NON_RECTANGULAR_CLIP_KEY);
    mShowHwScreenUpdates = findAndInitSwitchPref(SHOW_HW_SCREEN_UPDATES_KEY);
    mShowHwLayersUpdates = findAndInitSwitchPref(SHOW_HW_LAYERS_UPDATES_KEY);
    mDebugLayout = findAndInitSwitchPref(DEBUG_LAYOUT_KEY);
    mForceRtlLayout = findAndInitSwitchPref(FORCE_RTL_LAYOUT_KEY);
    mDebugHwOverdraw = addListPreference(DEBUG_HW_OVERDRAW_KEY);
    mWifiDisplayCertification = findAndInitSwitchPref(WIFI_DISPLAY_CERTIFICATION_KEY);
    mWifiVerboseLogging = findAndInitSwitchPref(WIFI_VERBOSE_LOGGING_KEY);
    mWifiAggressiveHandover = findAndInitSwitchPref(WIFI_AGGRESSIVE_HANDOVER_KEY);
    mWifiAllowScansWithTraffic = findAndInitSwitchPref(WIFI_ALLOW_SCAN_WITH_TRAFFIC_KEY);
    mMobileDataAlwaysOn = findAndInitSwitchPref(MOBILE_DATA_ALWAYS_ON);
    mLogdSize = addListPreference(SELECT_LOGD_SIZE_KEY);
    if ("1".equals(SystemProperties.get("ro.debuggable", "0"))) {
        mLogpersist = addListPreference(SELECT_LOGPERSIST_KEY);
    } else {
        mLogpersist = (ListPreference) findPreference(SELECT_LOGPERSIST_KEY);
        if (mLogpersist != null) {
            mLogpersist.setEnabled(false);
            if (debugDebuggingCategory != null) {
                debugDebuggingCategory.removePreference(mLogpersist);
            }
        }
        mLogpersist = null;
    }
    mUsbConfiguration = addListPreference(USB_CONFIGURATION_KEY);
    mWebViewProvider = addListPreference(WEBVIEW_PROVIDER_KEY);
    mWebViewMultiprocess = findAndInitSwitchPref(WEBVIEW_MULTIPROCESS_KEY);
    mBluetoothDisableAbsVolume = findAndInitSwitchPref(BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_KEY);
    mOverlayDisplayDevices = addListPreference(OVERLAY_DISPLAY_DEVICES_KEY);
    mSimulateColorSpace = addListPreference(SIMULATE_COLOR_SPACE);
    mUSBAudio = findAndInitSwitchPref(USB_AUDIO_KEY);
    mForceResizable = findAndInitSwitchPref(FORCE_RESIZABLE_KEY);
    mWindowAnimationScale = findAndInitAnimationScalePreference(WINDOW_ANIMATION_SCALE_KEY);
    mTransitionAnimationScale = findAndInitAnimationScalePreference(TRANSITION_ANIMATION_SCALE_KEY);
    mAnimatorDurationScale = findAndInitAnimationScalePreference(ANIMATOR_DURATION_SCALE_KEY);
    mImmediatelyDestroyActivities = (SwitchPreference) findPreference(IMMEDIATELY_DESTROY_ACTIVITIES_KEY);
    mAllPrefs.add(mImmediatelyDestroyActivities);
    mResetSwitchPrefs.add(mImmediatelyDestroyActivities);
    mAppProcessLimit = addListPreference(APP_PROCESS_LIMIT_KEY);
    mShowAllANRs = (SwitchPreference) findPreference(SHOW_ALL_ANRS_KEY);
    mAllPrefs.add(mShowAllANRs);
    mResetSwitchPrefs.add(mShowAllANRs);
    Preference hdcpChecking = findPreference(HDCP_CHECKING_KEY);
    if (hdcpChecking != null) {
        mAllPrefs.add(hdcpChecking);
        removePreferenceForProduction(hdcpChecking);
    }
    PreferenceScreen convertFbePreference = (PreferenceScreen) findPreference(KEY_CONVERT_FBE);
    try {
        IBinder service = ServiceManager.getService("mount");
        IMountService mountService = IMountService.Stub.asInterface(service);
        if (!mountService.isConvertibleToFBE()) {
            removePreference(KEY_CONVERT_FBE);
        } else if ("file".equals(SystemProperties.get("ro.crypto.type", "none"))) {
            convertFbePreference.setEnabled(false);
            convertFbePreference.setSummary(getResources().getString(R.string.convert_to_file_encryption_done));
        }
    } catch (RemoteException e) {
        removePreference(KEY_CONVERT_FBE);
    }
    mOtaDisableAutomaticUpdate = findAndInitSwitchPref(OTA_DISABLE_AUTOMATIC_UPDATE_KEY);
    if (!SystemProperties.getBoolean("ro.build.ab_update", false)) {
        removePreference(mOtaDisableAutomaticUpdate);
        mOtaDisableAutomaticUpdate = null;
    }
    mColorModePreference = (ColorModePreference) findPreference(KEY_COLOR_MODE);
    mColorModePreference.updateCurrentAndSupported();
    if (mColorModePreference.getColorModeCount() < 2) {
        removePreference(KEY_COLOR_MODE);
        mColorModePreference = null;
    }
    updateWebViewProviderOptions();
    mColorTemperaturePreference = (SwitchPreference) findPreference(COLOR_TEMPERATURE_KEY);
    if (getResources().getBoolean(R.bool.config_enableColorTemperature)) {
        mAllPrefs.add(mColorTemperaturePreference);
        mResetSwitchPrefs.add(mColorTemperaturePreference);
    } else {
        removePreference(COLOR_TEMPERATURE_KEY);
        mColorTemperaturePreference = null;
    }
    mRootAccess = (ListPreference) findPreference(ROOT_ACCESS_KEY);
    mRootAccess.setOnPreferenceChangeListener(this);
    mRootAppops = (Preference) findPreference(ROOT_APPOPS_KEY);
    mRootAppops.setOnPreferenceClickListener(this);
    if (!removeRootOptionsIfRequired()) {
        if (FileUtils.fileExists("/system/xbin/su")) {
            mRootAccess.setEntries(R.array.root_access_entries);
            mRootAccess.setEntryValues(R.array.root_access_values);
        } else {
            mRootAccess.setEntries(R.array.root_access_entries_adb);
            mRootAccess.setEntryValues(R.array.root_access_values_adb);
        }
        mAllPrefs.add(mRootAccess);
        mAllPrefs.add(mRootAppops);
    }
    mDevelopmentTools = (PreferenceScreen) findPreference(DEVELOPMENT_TOOLS);
    mAllPrefs.add(mDevelopmentTools);
}
Also used : IBinder(android.os.IBinder) PreferenceScreen(android.support.v7.preference.PreferenceScreen) ListPreference(android.support.v7.preference.ListPreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) IMountService(android.os.storage.IMountService) PreferenceGroup(android.support.v7.preference.PreferenceGroup) RemoteException(android.os.RemoteException)

Example 79 with IMountService

use of android.os.storage.IMountService in project android_frameworks_base by ResurrectionRemix.

the class LockSettingsService method addUserKeyAuth.

private void addUserKeyAuth(int userId, byte[] token, byte[] secret) throws RemoteException {
    final UserInfo userInfo = UserManager.get(mContext).getUserInfo(userId);
    final IMountService mountService = getMountService();
    final long callingId = Binder.clearCallingIdentity();
    try {
        mountService.addUserKeyAuth(userId, userInfo.serialNumber, token, secret);
    } finally {
        Binder.restoreCallingIdentity(callingId);
    }
}
Also used : IMountService(android.os.storage.IMountService) UserInfo(android.content.pm.UserInfo)

Example 80 with IMountService

use of android.os.storage.IMountService in project android_frameworks_base by ResurrectionRemix.

the class LockPatternUtils method updateEncryptionPassword.

/** Update the encryption password if it is enabled **/
private void updateEncryptionPassword(final int type, final String password) {
    if (!isDeviceEncryptionEnabled()) {
        return;
    }
    final IBinder service = ServiceManager.getService("mount");
    if (service == null) {
        Log.e(TAG, "Could not find the mount service to update the encryption password");
        return;
    }
    new AsyncTask<Void, Void, Void>() {

        @Override
        protected Void doInBackground(Void... dummy) {
            IMountService mountService = IMountService.Stub.asInterface(service);
            try {
                mountService.changeEncryptionPassword(type, password);
            } catch (RemoteException e) {
                Log.e(TAG, "Error changing encryption password", e);
            }
            return null;
        }
    }.execute();
}
Also used : IBinder(android.os.IBinder) IMountService(android.os.storage.IMountService) RemoteException(android.os.RemoteException)

Aggregations

IMountService (android.os.storage.IMountService)89 RemoteException (android.os.RemoteException)70 IBinder (android.os.IBinder)23 IOException (java.io.IOException)15 Context (android.content.Context)10 UserInfo (android.content.pm.UserInfo)10 FileNotFoundException (java.io.FileNotFoundException)10 Intent (android.content.Intent)9 ErrnoException (android.system.ErrnoException)9 IActivityManager (android.app.IActivityManager)6 BroadcastReceiver (android.content.BroadcastReceiver)6 IMountShutdownObserver (android.os.storage.IMountShutdownObserver)6 SettingNotFoundException (android.provider.Settings.SettingNotFoundException)5 ArraySet (android.util.ArraySet)5 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)5 InvalidKeyException (java.security.InvalidKeyException)5 KeyStoreException (java.security.KeyStoreException)5 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)5 UnrecoverableKeyException (java.security.UnrecoverableKeyException)5 CertificateException (java.security.cert.CertificateException)5