@RequiresApi(N) @Override public Context createDeviceProtectedStorageContext() { return mBase.createDeviceProtectedStorageContext(); }
@RequiresApi(N) @Override public Context createDeviceProtectedStorageContext() { return mBase.createDeviceProtectedStorageContext(); }
@Override public boolean onInit(Context context, @NonNull Shell shell) { Context de = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? context.createDeviceProtectedStorageContext() : context; File bbPath = new File(de.getFilesDir().getParentFile(), "busybox"); File bb = new File(bbPath, "busybox");
/** * Called at application startup to register preference change listeners. * * @return Always returns {@code true}. */ @Override public boolean onCreate() { // We register the shared preference listeners whenever the provider // is created. This method is called before almost all other code in // the app, which ensures that we never miss a preference change. for (RemotePreferenceFile file : mPrefFiles) { Context context = getContext(); if (file.isDeviceProtected() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { context = context.createDeviceProtectedStorageContext(); } SharedPreferences prefs = context.getSharedPreferences(file.getFileName(), Context.MODE_PRIVATE); prefs.registerOnSharedPreferenceChangeListener(this); mPreferences.put(file.getFileName(), prefs); } return true; }
/** * Listener for preference value changes in the local application. * Re-raises the event through the * {@link ContentResolver#notifyChange(Uri, ContentObserver)} API * to any registered {@link ContentObserver} objects. Note that this * is NOT called for {@link SharedPreferences.Editor#clear()}. * * @param prefs The preference file that changed. * @param prefKey The preference key that changed. */ @Override public void onSharedPreferenceChanged(SharedPreferences prefs, String prefKey) { RemotePreferenceFile prefFile = getSharedPreferencesFile(prefs); Uri uri = getPreferenceUri(prefFile.getFileName(), prefKey); Context context = getContext(); if (prefFile.isDeviceProtected() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { context = context.createDeviceProtectedStorageContext(); } ContentResolver resolver = context.getContentResolver(); resolver.notifyChange(uri, null); }