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 android.app.Activity;
20 import android.content.Intent;
21 import android.content.pm.PackageInfo;
22 import android.content.pm.PackageManager;
23 import android.os.Bundle;
24 import android.view.View;
25 import android.view.View.OnClickListener;
26 import android.widget.ImageView;
27 import android.widget.TextView;
29 public class NotifyActivity extends Activity {
31 protected void onCreate(Bundle savedInstanceState) {
32 super.onCreate(savedInstanceState);
34 setContentView(R.layout.notify);
36 Intent intent = getIntent();
41 int callerUid = intent.getIntExtra("caller_uid", -1);
42 if (callerUid == -1) {
47 final View packageInfo = findViewById(R.id.packageinfo);
48 final PackageManager pm = getPackageManager();
49 String[] pkgs = pm.getPackagesForUid(callerUid);
50 TextView unknown = (TextView)findViewById(R.id.unknown);
51 unknown.setText(getString(R.string.unknown_uid, callerUid));
53 if (pkgs != null && pkgs.length > 0) {
54 for (String pkg: pkgs) {
56 PackageInfo pi = pm.getPackageInfo(pkg, PackageManager.GET_PERMISSIONS);
57 ((TextView)findViewById(R.id.request)).setText(getString(R.string.application_request, pi.applicationInfo.loadLabel(pm)));
58 ImageView icon = (ImageView)packageInfo.findViewById(R.id.image);
59 icon.setImageDrawable(pi.applicationInfo.loadIcon(pm));
60 ((TextView)packageInfo.findViewById(R.id.title)).setText(pi.applicationInfo.loadLabel(pm));
62 ((TextView)findViewById(R.id.app_header)).setText(pi.applicationInfo.loadLabel(pm));
63 ((TextView)findViewById(R.id.package_header)).setText(pi.packageName);
65 // could display them all, but screw it...
66 // maybe a better ux for this later
69 catch (Exception ex) {
72 findViewById(R.id.unknown).setVisibility(View.GONE);
75 findViewById(R.id.ok).setOnClickListener(new OnClickListener() {
77 public void onClick(View v) {