Home | History | Annotate | Download | only in ui
      1 /*
      2 * Copyright (C) 2015 The Android Open Source Project
      3 *
      4 * Licensed under the Apache License, Version 2.0 (the "License");
      5 * you may not use this file except in compliance with the License.
      6 * You may obtain a copy of the License at
      7 *
      8 *      http://www.apache.org/licenses/LICENSE-2.0
      9 *
     10 * Unless required by applicable law or agreed to in writing, software
     11 * distributed under the License is distributed on an "AS IS" BASIS,
     12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 * See the License for the specific language governing permissions and
     14 * limitations under the License.
     15 */
     16 
     17 package com.android.packageinstaller.permission.ui;
     18 
     19 import android.app.Fragment;
     20 import android.content.Intent;
     21 import android.os.Bundle;
     22 import android.util.Log;
     23 
     24 public final class ManagePermissionsActivity extends OverlayTouchActivity {
     25     private static final String LOG_TAG = "ManagePermissionsActivity";
     26 
     27     @Override
     28     public void onCreate(Bundle savedInstanceState) {
     29         super.onCreate(savedInstanceState);
     30 
     31         if (savedInstanceState != null) {
     32             return;
     33         }
     34 
     35         Fragment fragment;
     36         String action = getIntent().getAction();
     37 
     38         switch (action) {
     39             case Intent.ACTION_MANAGE_PERMISSIONS: {
     40                 fragment = ManagePermissionsFragment.newInstance();
     41             } break;
     42 
     43             case Intent.ACTION_MANAGE_APP_PERMISSIONS: {
     44                 String packageName = getIntent().getStringExtra(Intent.EXTRA_PACKAGE_NAME);
     45                 if (packageName == null) {
     46                     Log.i(LOG_TAG, "Missing mandatory argument EXTRA_PACKAGE_NAME");
     47                     finish();
     48                     return;
     49                 }
     50                 fragment = AppPermissionsFragment.newInstance(packageName);
     51             } break;
     52 
     53             case Intent.ACTION_MANAGE_PERMISSION_APPS: {
     54                 String permissionName = getIntent().getStringExtra(Intent.EXTRA_PERMISSION_NAME);
     55                 if (permissionName == null) {
     56                     Log.i(LOG_TAG, "Missing mandatory argument EXTRA_PERMISSION_NAME");
     57                     finish();
     58                     return;
     59                 }
     60                 fragment = PermissionAppsFragment.newInstance(permissionName);
     61             } break;
     62 
     63             default: {
     64                 Log.w(LOG_TAG, "Unrecognized action " + action);
     65                 finish();
     66                 return;
     67             }
     68         }
     69 
     70         getFragmentManager().beginTransaction().replace(android.R.id.content, fragment).commit();
     71     }
     72 }
     73