2 * Copyright (C) 2013 Koushik Dutta (@koush)
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.koushikdutta.superuser;
19 import com.koushikdutta.superuser.util.Settings;
21 import android.app.Activity;
22 import android.content.Intent;
23 import android.content.pm.PackageInfo;
24 import android.content.pm.PackageManager;
25 import android.os.Bundle;
26 import android.view.View;
27 import android.view.View.OnClickListener;
28 import android.widget.ImageView;
29 import android.widget.TextView;
31 public class NotifyActivity extends Activity {
33 protected void onCreate(Bundle savedInstanceState) {
34 Settings.applyDarkThemeSetting(this, R.style.RequestThemeDark);
35 super.onCreate(savedInstanceState);
37 setContentView(R.layout.notify);
39 Intent intent = getIntent();
44 int callerUid = intent.getIntExtra("caller_uid", -1);
45 if (callerUid == -1) {
50 final View packageInfo = findViewById(R.id.packageinfo);
51 final PackageManager pm = getPackageManager();
52 String[] pkgs = pm.getPackagesForUid(callerUid);
53 TextView unknown = (TextView)findViewById(R.id.unknown);
54 unknown.setText(getString(R.string.unknown_uid, callerUid));
56 if (pkgs != null && pkgs.length > 0) {
57 for (String pkg: pkgs) {
59 PackageInfo pi = pm.getPackageInfo(pkg, PackageManager.GET_PERMISSIONS);
60 ((TextView)findViewById(R.id.request)).setText(getString(R.string.application_request, pi.applicationInfo.loadLabel(pm)));
61 ImageView icon = (ImageView)packageInfo.findViewById(R.id.image);
62 icon.setImageDrawable(pi.applicationInfo.loadIcon(pm));
63 ((TextView)packageInfo.findViewById(R.id.title)).setText(pi.applicationInfo.loadLabel(pm));
65 ((TextView)findViewById(R.id.app_header)).setText(pi.applicationInfo.loadLabel(pm));
66 ((TextView)findViewById(R.id.package_header)).setText(pi.packageName);
68 // could display them all, but screw it...
69 // maybe a better ux for this later
72 catch (Exception ex) {
75 findViewById(R.id.unknown).setVisibility(View.GONE);
78 findViewById(R.id.ok).setOnClickListener(new OnClickListener() {
80 public void onClick(View v) {