Thursday, February 13, 2014

cat /system/etc/permissions/handheld_core_hardware.xml on your Android device

This example simple display the file /system/etc/permissions/handheld_core_hardware.xml on my Android device.

handheld_core_hardware.xml of HTC One X
For what:
In my old post "List attached USB devices in USB Host mode", Anonymous commented have to check the xml file "/system/etc/permissions/handheld_core_hardware.xml" for < feature name="android.hardware.usb.host" />. Coincidentally I have a post to "Run Linux command with ProcessBuilder", so I modify it to display the content of "/system/etc/permissions/handheld_core_hardware.xml" using Linux command "cat".

package com.example.androidruncommand;

import java.io.IOException;
import java.io.InputStream;

import android.os.Bundle;
import android.app.Activity;
import android.widget.TextView;

public class MainActivity extends Activity {

 TextView textCommand, textReturn;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  textCommand = (TextView) findViewById(R.id.textcommand);
  textReturn = (TextView) findViewById(R.id.textreturn);

  String[] command = { "cat", "/system/etc/permissions/handheld_core_hardware.xml" };
  StringBuilder cmdReturn = new StringBuilder();
  
  String stringCommand = "$ ";
  for(int i=0; i<command.length; i++){
   stringCommand += command[i] + " ";
  }
  textCommand.setText(stringCommand);

  try {
   ProcessBuilder processBuilder = new ProcessBuilder(command);
   Process process = processBuilder.start();

   InputStream inputStream = process.getInputStream();
   int c;
   while ((c = inputStream.read()) != -1) {
    cmdReturn.append((char) c);
   }

   textReturn.setText(cmdReturn.toString());

  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
 }

}

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:autoLink="web"
        android:text="http://android-er.blogspot.com/"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/textcommand"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textStyle="bold" />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/textreturn"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
        </LinearLayout>
    </ScrollView>

</LinearLayout>

Or, you can pull the file from your device using DDMS of Android Development Tools.

/system/etc/permissions/handheld_core_hardware.xml in HTC One X
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2009 The Android Open Source Project

     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.
-->

<!-- These are the hardware components that all handheld devices
     must include. Devices with optional hardware must also include extra
     hardware files, per the comments below.

     Handheld devices include phones, mobile Internet devices (MIDs),
     Personal Media Players (PMPs), small tablets (7" or less), and similar
     devices.
-->
<permissions>
    <feature name="android.hardware.camera" />
    <feature name="android.hardware.location" />
    <feature name="android.hardware.location.network" />
    <feature name="android.hardware.sensor.compass" />
    <feature name="android.hardware.sensor.accelerometer" />
    <feature name="android.hardware.bluetooth" />
    <feature name="android.hardware.touchscreen" />
    <feature name="android.hardware.microphone" />
    <feature name="android.hardware.screen.portrait" />
    <feature name="android.hardware.screen.landscape" />
    <!-- devices with GPS must include android.hardware.location.gps.xml -->
    <!-- devices with an autofocus camera and/or flash must include either
         android.hardware.camera.autofocus.xml or 
         android.hardware.camera.autofocus-flash.xml -->
    <!-- devices with a front facing camera must include
         android.hardware.camera.front.xml -->
    <!-- devices with WiFi must also include android.hardware.wifi.xml -->
    <!-- devices that support multitouch must include the most appropriate one
         of these files:

         If only partial (non-independent) pointers are supported:
         android.hardware.touchscreen.multitouch.xml

         If up to 4 independently tracked pointers are supported:
         include android.hardware.touchscreen.multitouch.distinct.xml

         If 5 or more independently tracked pointers are supported:
         include android.hardware.touchscreen.multitouch.jazzhand.xml

         ONLY ONE of the above should be included. -->
    <!-- devices with an ambient light sensor must also include
         android.hardware.sensor.light.xml -->
    <!-- devices with a proximity sensor must also include
         android.hardware.sensor.proximity.xml -->
    <!-- GSM phones must also include android.hardware.telephony.gsm.xml -->
    <!-- CDMA phones must also include android.hardware.telephony.cdma.xml -->
    <!-- Devices that have low-latency audio stacks suitable for apps like
         VoIP may include android.hardware.audio.low_latency.xml. ONLY apps
         that meet the requirements specified in the CDD may include this. -->
</permissions>

But...I can't find < feature name="android.hardware.usb.host" /> in my handheld_core_hardware.xml. But it support USB Host mode actually.

No comments: