1 /* 2 * Copyright (c) 2016, 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 package com.android.car.media.localmediaplayer; 17 18 import android.app.Activity; 19 import android.os.Bundle; 20 21 public class PermissionsActivity extends Activity { 22 private static final int REQUEST_CODE = 42; 23 24 @Override 25 protected void onCreate(Bundle savedInstanceState) { 26 super.onCreate(savedInstanceState); 27 28 // Check again, just in case. 29 if (!Utils.hasRequiredPermissions(this)) { 30 requestPermissions(Utils.PERMISSIONS, REQUEST_CODE); 31 } else { 32 finish(); 33 } 34 } 35 36 @Override 37 public void onRequestPermissionsResult(int request, String[] permissions, int[] results) { 38 // The media browser displays an error anyway if it doesn't have the required permissions 39 // so we call finish irrespective of the grant result. This whole activity exists just 40 // for the purpose of trampolining the permissions request anyway. 41 finish(); 42 } 43 } 44