/*
 * Copyright 2016 Peter Kenji Yamanaka
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.pyamsoft.powermanager.app.manager.backend;

import android.support.annotation.NonNull;
import com.pyamsoft.powermanager.dagger.manager.backend.ManagerInteractor;
import javax.inject.Inject;
import javax.inject.Named;
import rx.Scheduler;
import timber.log.Timber;

public final class ManagerData extends BaseManager {

  @NonNull private final ManagerInteractor interactor;

  @Inject public ManagerData(@NonNull @Named("data") ManagerInteractor interactor,
      @NonNull @Named("io") Scheduler ioScheduler,
      @NonNull @Named("main") Scheduler mainScheduler) {
    super(interactor, mainScheduler, ioScheduler);
    Timber.d("new ManagerData");
    this.interactor = interactor;
  }

  @Override void onEnableComplete() {
    Timber.d("Enable complete");
    cleanup();
  }

  @Override void onDisableComplete() {
    Timber.d("Disable complete");
    cleanup();
  }
}

@@ -654,16 +654,187 @@
 ckend;%0A%0A
+import android.Manifest;%0Aimport android.content.Context;%0Aimport android.content.pm.PackageManager;%0Aimport android.os.Build;%0Aimport android.support.annotation.CheckResult;%0A
 import a
@@ -1466,24 +1466,358 @@
 actor;%0A  %7D%0A%0A
+  @CheckResult public static boolean checkWriteSettingsPermission(@NonNull Context context) %7B%0A    return context.getApplicationContext()%0A        .checkCallingOrSelfPermission(Manifest.permission.WRITE_SECURE_SETTINGS)%0A        == PackageManager.PERMISSION_GRANTED%0A        && Build.VERSION.SDK_INT %3E= Build.VERSION_CODES.LOLLIPOP;%0A  %7D%0A%0A
   @Override 

Add function to check that permission is granted on needed apis